NAME
src/pmc/string.pmc - String PMC Class
DESCRIPTION
String
extends scalar
to provide a string for languages that want a string
type without going to an S register.
It acts as a wrapper for the functions in src/string.c.
Methods
void init()
Initializes the string.
void mark()
Marks the string as live.
PMC *clone()
Creates a copy of the string.
INTVAL get_integer()
Returns the integer representation of the string.
FLOATVAL get_number()
Returns the floating-point representation of the string.
STRING *get_string()
Returns the string itself.
INTVAL get_bool()
Returns the boolean value of the string.
VOID set_integer_native(INTVAL value)
VOID set_bool(INTVAL value)
Sets the value of the string to the integer VOID set_number_native(FLOATVAL value)
Sets the value of the string to the floating-point VOID set_string_native(STRING *value)
Sets the value of the string to that of the specified VOID assign_string_native(STRING *value)
Sets the value of the string to a copy of the specified VOID set_pmc(PMC *value)
Sets the value of the string to the string value of the specified INTVAL is_equal(PMC *value)
Compares the string with INTVAL is_equal_num(PMC *value)
Compares the numerical value of the string with that of INTVAL is_equal_string(PMC *value)
Compares the string with INTVAL cmp(PMC *value)
Compares the string with INTVAL cmp_num(PMC *value)
Compares the numerical value of the string with that of INTVAL cmp_string(PMC *value)
Compares the string with void substr(INTVAL offset, INTVAL length, PMC *dest)
Extracts the substring starting at STRING *substr_str(INTVAL offset, INTVAL length)
Extracts the substring starting at INTVAL exists_keyed(PMC *key)
Returns true if the STRING *get_string_keyed(PMC *key)
Returns the INTVAL get_integer_keyed(PMC *key)
Returns the integer value (ord) at void set_string_keyed(PMC *key, STRING *val)
Replace the string at void set_integer_keyed(PMC *key, INTVAL val)
Replace the string at void replace(STRING *orig, STRING *_new)
Replace every occurrence of PMC *to_int(INTVAL base)
Return the integer equivalent of SELF,
which is assumed to be a
value
.
value
.
string
.
string
.
PMC
.
value
; returns true if they match.
value
; returns true if they match.
value
; returns FALSE if they match.
value
; returns -1 if the string is smaller,
0 if they are equal,
and 1 if value
is smaller.
value
; returns -1 if the string is smaller,
0 if they are equal,
and 1 if value
is smaller.
value
; returns -1 if the string is smaller,
0 if they are equal,
and 1 if value
is smaller.
offset
,
with size length
,
and places it in dest
.
offset
,
with size length
,
and returns it.
key
'th character in the string exists.
Negative numbers count from the end.
key
'th character in the string.
Negative numbers count from the end.
*key
.
key
with value
.
key
with the chr of value
.
orig
with _new
.
base
digit string.
The String is assumed to be in an ascii-compatible encoding.
The String is considered being unsigned,
and no + or - chars are processed.
base
has to be within [2..36].If any chars in the String aren't converted,
an exception is thrown.TODO Currently overflow to BigInt is not handled nor detected.Iterator Interface
PMC *get_iter(PMC *key)
Return a new iterator for this string.
INTVAL elements()
Return length of the string.
Freeze/thaw Interface
void freeze(PMC *info)
Used to archive the string.
void thaw(PMC *info)
Used to unarchive the string.
NCI methods
PMC *lower()
Downcase this string
void trans(STRING *src, PMC *trams_table)
Translate ascii string void reverse(STRING *src)
Reverse the ascii STRING INTEGER is_integer(STRING *src)
Checks if the ascii STRING INTEGER reverse_index(STRING *substring, INTVAL start)
Find last occurrence of
src
with entries from trans_table
.
src
in place.
str
is just an integer.
substring
,
but not after the start
position.