UXPathComp
UXPathComp is one segment of a UXPath: a
single directory or file name, with no separators.
#use <UXKit> // or #import "UXPath.xc"Overview
Section titled “Overview”class UXPathComp : Object { u8* s; // the name, NUL-terminated, no '/'}The class has one field.
Why it exists at all
Section titled “Why it exists at all”UXPath keeps its components in an Array, and an
Array holds Objects, so a bare u8* cannot go in
one. UXPathComp is the box that lets a C string live in a collection.
UXStrItem and
UXKVEntry exist for the same reason. Boxing
is explicit, so the wrapper appears in the type and not only in the
implementation.
You rarely name it directly: UXPath.component(i) unwraps it and returns the
u8*.
for (i32 i = 0; i < p.count(); i = i + 1) { Stdio.printf(" %s\n", p.component(i)); // no UXPathComp in sight}It matters for the breadcrumb bar. A path bar shows a normalized path’s components, one control per box, and each crumb needs something with identity to hang a target/action on.
The name is a plain pointer
Section titled “The name is a plain pointer”u8* ss is not owned in any managed sense. It is a raw pointer, and whoever
allocated it decides who frees it. In practice UXPath always gives it bytes it
allocated itself (parse and
appendingComponent both
copy), so the component owns its name for as long as the path lives.
The exception is UXPath.copy, which makes
new boxes that share the original’s buffers. Nothing in the toolkit writes
through a component pointer, so the sharing is invisible. Do not write through
one yourself.
init sets s to "" instead of null, so a new component is safe to print
before it is filled in.
Fields
Section titled “Fields”u8* sThe component name. No separators, never null after init.
Conforms to
Section titled “Conforms to”- Inherits
Object