class SPList<T> A list of any type specified by T.T& operator[n] returns a reference to the element at index n (0-based). Generates an ASSERT error if n < 0, can be used as an lvalue. Using an index greater than the current size of the list will cause the list to grow up to that index. The values in between will be undefined if <T> is a built-in type.
operator void*() returns NULL if the list is empty, can be used like: if(list) // not empty.
int isempty() returns TRUE if the list is empty, as an alternative for the previous technique.
void reset() clears all elements in the list, but doesn't actually free up the storage until it is destroyed.
int count() returns the number of elements in the list
int scalar() Perl-like Synonym (alias) for count ().
T pop() removes and returns the last element on the list. If the list is empty the value returned is usually undefined.
void push(T x) puts the single value x at the end of the list.
void push(SPList<T> l) puts all the elements in the list l at the end of the list.
T shift() removes and returns the first element in the list.
int unshift(T x) puts the single value x at the start of the list.
int unshift(SPList<T> l) puts all the elements in the list l at the start of the list.
SPList<T> reverse() returns a list that is in the reverse order.
SPList<T> splice(offset, len, SPList<T> l) removes len elements from offset (0-based) and inserts all the elements in the list l at the same position
SPList<T> splice(offset, len) removes len elements from offset (0-based).
SPList<T> splice(offset) removes all the elements from offset (0-based).
SPList<T> sort() returns a list that has been sorted according to the rules that T::operator<() returns for the type T.
class SPStringList everything SPList does and ...
int split(str [,pat] [,limit]) appends the results of splitting the string str to the list. If pat is specified then any string that matches the RE (Regular Expression) pat is considered a separator to split on; the default is white-space. If limit is specified then no more than that number of elements is generated. If limit is not specified, then empty entries are stripped from the end of the list. If the RE includes subexpressions then they are inserted into the list as well. If pat is equal to the string "' '" then a special case is done which matches awk's handling of whitespace. If pat is an empty string "", then all characters are split into the list.
SPString join([pat]) Returns the string that is the result of combining all the elements in the list, and separating them by pat. If pat is omitted then the elements are separated by a space.
int m(const char *exp, targ [,opts]) Appends to the list all the subexpression matches that occured when applying the regular expression exp to the string targ. The number of matches is returned. The first element generated is the entire matched string.
opts: (a const char * with default "")
i Forces case insensitive match.
SPStringList grep(const char *exp [,opts]) returns a list of all the elements that matched the regular expression exp.
opts: (a const char * with default "")
i Forces the search to be case insensitive.
class SPString A Standard C null-terminated string may be used anywhere that a SPString can be used and vice-versa. Individual characters may be read with the [] operator.
int length() returns the length of the string.
char chop() removes and returns the last character in the string.
int index(SPString str [, offset]) returns the offset in the string that matches the string str, starting at position offset if specified, otherwise searches the entire string. Returns -1 if no match is found.
int rindex(SPString str [, offset]) returns the offset in the string that matches the string str, starting at the end of the string offset if specified, otherwise searches the entire string. Returns -1 if no match is found.
substring substr(offset [, len]) returns the substring within the string that starts at offset and is len characters, if len is omitted the rest of the string is returned. This may be used as an lvalue, in which case the characters are removed, and the RHS of the expression is inserted at the same postion.
SPStringList split([,pat] [,limit])- same as S-PStringList::split() but returns a list of splits.
operator< operator> operator<= operator>= operator== operator!= These operators do what you would expect.
operator+ returns the result of concatenating two or more strings.
operator+= replaces the LHS of the expression with the concatenation of the LHS with the RHS.
int m(const char *exp [,opts]) returns 0 if the regular expression exp fails to match the string. Returns 1 if a match was made.
opts: (a const char * with default "")
i Forces case insensitive match.
int m(const Regexp& exp) Same as above but takes a precompiled regular expression.
int m(const char *exp, SPStringList& l [,opts]) Loads the list l with all subexpression matches of the regular expression exp with the string. Returns 0 if no matches were made. Returns the number of matches if any.
opts: (a const char * with default "")
i Forces case insensitive match.
int m(const Regexp& exp, SPStringList& l) Same as above but takes a precompiled regular expression.
int tr(search, repl [,opts]) replaces all occurrences of characters in search with the equivalent character in repl. If repl is empty then just counts the characters.
opts: (a const char *, default is "")
c complements the search pattern. Replaces all characters that are not in search, with the last character specified in repl.
d deletes characters in search that don't have an equivalent repl.
cd deletes characters not in search.
s compresses sequences of translated characters in resulting string.
int s(exp, repl [,opts]) substitute the first substring matched by exp with the string repl. $& in repl will be replaced by the entire matching string, $1 - $9 will be replaced by the respective subexpression match. \$ or \\ will insert a $ or \ respectively.
opts: (a const char *, default is "")
g causes all occurrences of exp in the string to be replaced by repl.
i Forces case insensitive matching.
class Regexp Henry Spencer's, regular expression package, OO-ized.
Regexp(exp [,opts]) Compiles a regular expression that can be passed to one of the m() functions.
opts: (an int with default 0)
Regexp::nocase Forces case insensitive match.
int match (targ) returns 1 if the compiled RE matches targ returns 0 if not.
int groups () returns 1 + the number of subexpression matches found in the last match(). If the previous match() succeeded then the whole match is included in the count (hence + 1).
Range getgroup(n) returns the range of the nth sub-group.n = 0 is the range of the entire match.
SPStringList m(exp, targ [,opts]) returns a list of all the subexpression matches that occured when applying the regular expression exp to the string targ. element 0 of the list is the first subexpression, element 1 the next, etc.
opts: (a const char * with default "")
i Forces case insensitive match.
xin >> astring Text from the stream xin is loaded into astring; the text is expected to be terminated by \n, which is removed from the stream, but not put into astring.astring is cleared first.
xin >> astringlist Each Text line, as defined above, is loaded into an element of astringlist, which is reset first.