next up previous index
Next: Lists Up: Indexed collections: vector, array, Previous: Implementations   Index

Strings

In string.cecil:

abstract object string isa indexed[char];
method copy_mutable(s@:string):m_string;
The string type is an abstract class representing an indexed sequence of characters. Methods operating on generic strings that both take and return strings, in most cases produce a new string as a result.

method ||(s1@:string, s2@:string):string;
method ||(s1@:string, c@:char):string;
method ||(c@:char, s2@:string):string;
method to_upper_case(s@:string):string;
method to_lower_case(s@:string):string;
In addition to all the operations available on other indexed collections, characters can be concatenated onto the front or back of a string using the || infix operator. (The || operator can also concatenate two strings. This behavior is inherited from sequences.)

method copy_from(s@:string, start:int):string;
method copy_from(s@:string, start:int, up_to:int):string;
method has_prefix(s@:string, prefix@:string):bool;
method has_suffix(s@:string, suffix@:string):bool;
method remove_prefix(s@:string, prefix@:string):string;
method remove_suffix(s@:string, suffix@:string):string;
The copy_from method copies a portion of a string from a start index up to (but not including) a stop index (or the end of the string, if the stop index is not specified). The has_{prefix,suffix} functions test whether a string starts with or ends with a particular string; the remove_{prefix,suffix} functions return a new string with the specified prefix or suffix removed, if present, or the original string otherwise.

method pad(s@:string, len:int):string;
method pad_right(s@:string, len:int):string;
method pad_right(s@:string, len:int, padding:char):string;
method pad_left(s@:string, len:int):string;
method pad_left(s@:string, len:int, padding:char):string;
method  open_brace(@:string):string;
method close_brace(@:string):string;
method collection_name(@:string):string;
method elems_print_string(s@:string):string;
method elem_print_string(@:string, char:char, :bool):string;
method print(s@:string):void;
The pad functions add either blanks or a specified padding character to either the front or the back of the string to make it be of at least the specified length.

abstract object i_string isa string, i_indexed[char];
abstract object m_string isa string, m_indexed[char];
  method copy(s@:m_string):m_string;
  method write_into_string_at_pos(s1:string, s2:m_string, pos:int):void;
As usual, there are immutable and mutable varieties of strings.

abstract object vstring isa string;
method length(s@:vstring):int;
method fetch(s@:vstring, index:int, if_absent:&():char):char;
method as_vstring(s@:vstring):vstring;
method print(s@:vstring):void;
extend i_vstring isa i_string, vstring;
method new_i_vstring(size@:int):i_vstring;
method new_i_vstring(size@:int, filler_oop@:char):i_vstring;
method new_i_vstring_init(size@:int, cl:&(int):char):i_vstring;
method new_i_vstring_init_from(c@:ordered_collection[`T],
                               cl:&(T):char):i_vstring;
method new_i_vstring_init_from(c@:indexed[`T], cl:&(T):char
                               ):i_vstring;
extend m_vstring isa m_string, vstring;
method new_m_vstring(size@:int):m_vstring;
method new_m_vstring_no_init(size@:int):m_vstring;
method new_m_vstring(size@:int, filler_oop@:char):m_vstring;
method new_m_vstring_init(size@:int, cl:&(int):char):m_vstring;
method new_m_vstring_init_from(c@:ordered_collection[`T],
                               cl:&(T):char):m_vstring;
method new_m_vstring_init_from(c@:indexed[`T], cl:&(T):char
                               ):m_vstring;
method store(s@:m_vstring, index:int, c:char, if_absent:&():void):void;
method as_m_vstring(s@:m_vstring):m_vstring;
The vstring class and its two concrete subclasses, i_vstring and m_vstring, provide a primitive fixed-length packed string implementation. Cecil string literals (e.g., "hello") are instances of i_vstring. Various constructors for vstrings are provided, analogously to vectors and arrays.


next up previous index
Next: Lists Up: Indexed collections: vector, array, Previous: Implementations   Index

Cecil/Vortex Project