Skip to content

UXCSVField

UXCSVField is one cell of a UXCSV table.

#use <UXKit> // or #import "UXCSV.xc"
class UXCSVField : Object {
u8* s; // the field's text, unquoted
}

It is boxed because Array holds Objects and a bare u8* is not one. The same reason applies to UXStrItem and UXPathComp.

You seldom name it: UXCSVRow.field unwraps and UXCSVRow.add boxes.

Get this right when building a table to write out.

field.s; // hello, world — with a real comma in it

A field holds what the value is, never how CSV spells it. The quotes and the doubled quotes exist only in the serialised bytes:

in the files holds
"hello, world"hello, world
"say ""hi"""say "hi"
plainplain

serialize adds quoting when the text needs it, and parse removes it. Doing either yourself double-encodes: a value you pre-quote comes out with its quotes as data.

Assignment stores the pointer; nothing is copied and nothing is managed.

Fields produced by parse are freshly allocated and belong to the row, so a parsed table owns its text. A field you fill in yourself must point at something that outlives the row: a literal, or a copy made with UXStr.dup.

init sets s to "" rather than null, so a fresh field is safe to serialise before it is filled in. It produces an empty cell, not a crash.

u8* s

The field’s text. Never null after init.