UXStrItem
UXStrItem is one string, boxed so it can go in a collection.
#use <UXKit> // or #import "UXText.xc"Overview
Section titled “Overview”class UXStrItem : Object { u8* s; // the string, NUL-terminated}The class has one field.
Why it exists
Section titled “Why it exists”Array holds Objects, and a
bare u8* is not one, so a list of strings needs a wrapper. UXStrItem is that
wrapper.
UXPathComp and
UXKVEntry exist for the same reason. Boxing
is explicit in xtc, not automatic, so the wrapper appears in signatures:
static Array<UXStrItem>* split(u8* s, u8 delim)You mostly do not touch it
Section titled “You mostly do not touch it”UXText.partAt unwraps for you, so the
common loop never names the type:
Array<UXStrItem>* parts = UXText.split(line, (u8)',');for (i32 i = 0; i < (i32)parts.count(); i = i + 1) { Stdio.printf(" [%s]\n", UXText.partAt(parts, i));}UXText.join takes the whole array back,
so a split → filter → join never builds one by hand.
Building one yourself
Section titled “Building one yourself”Two cases need it: making a list to hand to join, and holding strings that did
not come from a split.
Array<UXStrItem>* items = new Array();UXStrItem* it = new UXStrItem();it.s = UXStr.dup(name); // copy if `name` is borroweditems.add(it);init sets s to "", not null, so a new item is safe to print before it is
filled in. join relies on this because it
walks every element.
Fields
Section titled “Fields”u8* sThe string. Never null after init.
Conforms to
Section titled “Conforms to”- Inherits
Object
See also
Section titled “See also”UXText: split, join, and everything else that produces or consumes theseUXStr:dup, for when the string is borrowedUXPathComp: the same boxing for a path component