Previous: strstr, Up: String Functions [Contents][Index]
strtok
strtok
is a helper for tokenizing strings. The synopsis of
this API are:
type String_Tokenizer = struct { uint<64> i; string str; computed uint<32> more; method get_more = uint<32>: { … } method peek = char: { … } method pop = char: { … } method pop_number = (int<32> base = 10) int<64>: { … } method popdelim = (string delimiters) string: { … } method poprdelim = (string delimiters) string: { … } method raise_exception = (Exception base, string message) void: { … } } fun strtok = (string a) String_Tokenizer: { … }
Creates a new tokenizer for the string a, initially on the zero position.
The members of the String_Tokenizer
class are:
Offset to the next character to be tokenized, i.e. to the first character that has not already been consumed.
The string being tokenized. This string is never tokenized.
A read-only computed property whose value is truthy if there’s more characters and falsey otherwise.
Returns the first unread character of the string, but does not advance the i offset.
Raises E_out_of_bounds
if at the end of the string.
Returns the first unread character of the string, and advances the tokenizer.
Raises E_out_of_bounds
if at the end of the string.
Returns the number at the start of the string and advances the
tokenizer in the given base. The bases that are supported are
the same as for strtoi
.
See strtoi for a list of supported bases.
Raises E_out_of_bounds
if at the end of the string.
Returns the substring up to the first character also present in the string delim. Advances the tokenizer to after the delimiter character (i.e. it consumes the delimiter character).
Raises E_out_of_bounds
if at the end of the string.
Returns the substring up to the last character also present in the string delim. Advances the tokenizer to after the delimiter character (i.e. it consumes the delimiter character).
Raises E_out_of_bounds
if at the end of the string.
Raises a copy of base augmented so that it contains a description of the tokenizers current position, as well as the programmer-specified message.
Previous: strstr, Up: String Functions [Contents][Index]