« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Examples

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


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.

Definition

struct String {
  char* val;
};

Derives

Implements

  • Assignassign
  • C_Strc_str
  • Cmpcmp eq neq gt lt ge le
  • Concatappend concat
  • Docname brief description definition
  • Formatformat_to format_from
  • Getget set mem rem key_type val_type
  • Hashhash hash_data
  • Lenlen
  • Newnew del construct destruct
  • Resizeresize
  • Showshow look print scan

Back