Usage
var s0 = $(String, "Hello");
var s1 = new(String, $S("Hello"));
append(s1, $S(" There"));
show(s0); /* Hello */
show(s1); /* Hello There */
Manipulation
var s0 = new(String, $S("Balloons"));
show($I(len(s0))); /* 8 */
show($I(mem(s0, $S("Ball")))); /* 1 */
show($I(mem(s0, $S("oon")))); /* 1 */
show($I(mem(s0, $S("Balloons")))); /* 1 */
show($I(mem(s0, $S("l")))); /* 1 */
rem(s0, $S("oons"));
show($I(eq(s0, $S("Ball")))); /* 1 */
resize(s0, 0);
show($I(len(s0))); /* 0 */
show($I(eq(s0, $S("")))); /* 1 */
String Object
The String type is a wrapper around the native C string type. This includes strings that are allocated on either the Stack or the Heap.
For strings allocated on the heap a number of extra operations are provided overs standard C strings such as concatenation.
struct String {
char* val;
};
assign c_str cmp eq neq gt lt ge le append concat name brief description definition format_to format_from get set mem rem key_type val_type hash hash_data len new del construct destruct resize show look print scan