Skip to content

UXCSVRow

UXCSVRow is one line of a UXCSV table: an ordered list of fields, already unquoted.

#use <UXKit> // or #import "UXCSV.xc"
class UXCSVRow : Object {
Array<UXCSVField>* fields;
}
row.count(); // how many fields
row.field(1); // the field's text, unwrapped
row.add((u8*)"hello"); // append, boxing for you

With these three methods you never need to name UXCSVField: field unwraps and add boxes.

for (u16 r = 0; r < rows.count(); r = r + 1) {
UXCSVRow* row = (UXCSVRow* ?)rows.get(r);
for (i32 c = 0; c < row.count(); c = c + 1) {
Stdio.printf(" [%s]", row.field(c));
}
}

Fields are in file order, and the text is what the field meant: quotes stripped, doubled quotes collapsed, embedded newlines intact.

UXCSVRow* r = new UXCSVRow();
r.add((u8*)"greeting");
r.add((u8*)"hello, world"); // no quoting needed here
rows.add(r);

Add the field’s real text, not a pre-quoted version. serialize decides what needs quoting and quotes it. If you quote it yourself, the file gets """hello, world""", with the quotes as data.

Inside the toolkit, text is plain. The format’s syntax exists only in the serialised bytes. The same rule applies to UXJSONValue.str.

count · field · add

i32 count(void)

Fields in this row. 0 is possible: a blank line parses as a row with one empty field, but a row you built and never added to has none.

u8* field(i32 i)

One field’s text, unwrapped from its UXCSVField box. No bounds check.

void add(u8* s)

Append a field, boxing the string.

Array<UXCSVField>* fields

The boxed fields, held strongly. Never null.