UXCSVField
UXCSVField is one cell of a UXCSV table.
#use <UXKit> // or #import "UXCSV.xc"Overview
Section titled “Overview”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.
s is the text, not the syntax
Section titled “s is the text, not the syntax”Get this right when building a table to write out.
field.s; // hello, world — with a real comma in itA 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 file | s holds |
|---|---|
"hello, world" | hello, world |
"say ""hi""" | say "hi" |
plain | plain |
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.
s is a borrowed pointer
Section titled “s is a borrowed pointer”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.
Fields
Section titled “Fields”u8* sThe field’s text. Never null after init.
Conforms to
Section titled “Conforms to”- Inherits
Object