String utility class. More...
#include <strutil.h>
Static Public Member Functions | |
| static value * | splitspace (const string &) |
| static value * | split (const string &str, char sep) |
| static value * | splitescaped (const string &str, char sep, const string &escapees="") |
| static value * | split (const string &str, const string &seq) |
| static value * | splitquoted (const string &str, char sep=0, bool forxml=false) |
| static value * | splitcsv (const string &) |
| static string * | encodecsv (const string &) |
| static value * | parsehdr (const string &hdr) |
| static bool | crlfornot (const string &str) |
| static value * | parsemime (const string &dat) |
| static value * | splitlines (const string &str) |
| static string * | urlencode (const string &str) |
| static string * | urldecode (const string &) |
| static value * | parsenv (const string &line, char split=';', char nvsplit='=') |
| static value * | httpurldecode (const string &str) |
| static string * | httpurlencode (value &v) |
| static string * | unescape (const string &str) |
| static string * | regexp (const string &str, const string &exp) |
| static string * | wrap (const string &str, unsigned int marg) |
| static string * | htmlize (const string &) |
| static void | xmlreadtag (xmltag *, const string *) |
| static string * | titlecaps (const string &) |
| static string * | valueparse (const string &str, const value &env) |
| static string * | makepath (const string &str) |
| static string * | uuid (void) |
String utility class.
Contains solely static methods for advanced string parsing and manipulation.
| bool strutil::crlfornot | ( | const string & | str | ) | [static] |
Scan text to determine whether to use CRLF or just LF for end-of-line parsing.
| str | Text data with newlines. |
References string::strchr(), and string::strstr().
Referenced by parsemime(), and splitlines().

Encode string data using CSV rules.
References string::strcat(), and string::strlen().
Referenced by value::savecsv(), and value::tocsv().

Create a copy of a text block that converts ASCII to escaped valid html data.
References string::strcat(), and string::strlen().

Derive variables from a GET request.
| str | Text data in QUERY_STRING format. |
References string::cutat(), split(), string::strlen(), and urldecode().
Referenced by httpdscriptparser::run(), and serverpage::run().

Encode a keyed list of values as a GET request.
| v | A value object containing a flat collection of key/value pairs. |
References string::printf(), string::str(), and urlencode().

Convert a relative or absolute path with trailing filename into a string containing only the path component.
References string::crop(), string::cutatlast(), string::left(), and string::strchr().

Parse an internet header.
Stores the header, with its headername as the key, inside a value object that can be merged by the caller into a value object that is to keep all headers. Parameters inside a header are also parsed, so a situation like "Foo: bar/baz; x=25" will yield a res["foo"] containing "bar/baz" with an attribute res["foo"]("x") valued as 25.
| hdr | The header string. |
References value::count(), string::left(), string::mid(), value::rmindex(), value::setattrib(), split(), splitquoted(), string::strchr(), and value::sval().
Referenced by cgi::cgi(), parsemime(), and httpdworker::run().

Parse a MIME multipart text block.
| dat | Text data with multipart mime. |
References crlfornot(), string::cutat(), parsehdr(), and splitlines().
Referenced by cgi::cgi().

Parse a list of name/value pairs, as seen in e.g., the http cookie header.
Is liberal with whitespace and allows for quote-escpaping of the right-hand value part of a pair, making the following all equivalent:
| line | The line to parse. | |
| split | The split between each name/value pair. | |
| nvsplit | The split character between each name/value. |
References string::chomp(), string::cutat(), splitquoted(), string::strcat(), and string::strlen().

Perform a regular expression on a string.
| str | The source string. | |
| exp | The regular expression. |
Referenced by value::decode(), smtpsocket::dosmtp(), httpsocket::get(), value::load(), httpsocket::post(), httpdrewrite::run(), and cmdtoken_set::run().
Split string into array of words.
Looks for a specified separator sequence.
| str | The string data. | |
| sep | The separator sequence. |
References string::mid(), string::strlen(), and string::strstr().

Split string into array of words.
Looks for a specified separator character.
| str | The string data. | |
| sep | The separator character. |
References string::mid(), and string::strchr().
Referenced by scriptparser::build(), cgi::cgi(), cmdtoken_data::cmdtoken_data(), dbfile::decode(), httpurldecode(), value::ipval(), keypath::keypath(), value::loadinitree(), parsehdr(), timestamp::rfc822(), cmdtoken_set::run(), cmdtoken_if::run(), splitlines(), valueparse(), and wrap().

| value * strutil::splitescaped | ( | const string & | str, | |
| char | sep, | |||
| const string & | escapees = "" | |||
| ) | [static] |
Split by a character, but mind backslash- escapes.
References string::crop(), string::strcat(), string::strchr(), and string::strlen().

Split a text block into an array of lines.
| str | Text data with multiple lines. |
References value::count(), crlfornot(), value::rmindex(), and split().
Referenced by value::fromcsv(), and parsemime().

Split string into array of arguments.
Accepts double and single quotes as means of escaping the separator.
| str | The string data. | |
| sep | The separator sequence. |
References string::mid(), string::strlen(), and unescape().
Referenced by cmdtoken_if::cmdtoken_if(), cmdtoken_set::cmdtoken_set(), value::decode(), dbfile::decode(), value::fromcsv(), value::load(), parsehdr(), parsenv(), cmdtoken_data::run(), smtpsocket::setsender(), cliutil::splitwords(), systemprocess::systemprocess(), and xmlreadtag().

Split string into array of words.
The string is split on whitespace boundaries, with any whitespace at the start ignored:
References string::mid(), and string::strlen().
Referenced by httpdfileshare::httpdfileshare(), and titlecaps().

Convert a string to title caps.
Capitalizes every word except for certqain words like 'the', 'of', 'de', etc.
References string::capitalize(), value::exists(), and splitspace().

Create an unescaped copy of a string.
| str | Escaped data. |
References string::strlen().
Referenced by splitquoted().

Decode a string from a HTTP GET request.
| str | The encoded string. |
References string::strcat(), and string::strlen().
Referenced by cgi::cgi(), and httpurldecode().

Encode a string suitable for encoding as a parameter in a HTTP GET request.
| str | The unencoded string. |
References string::strcat(), and string::strlen().
Referenced by httpurlencode(), and httpsocket::post().

Parses a string of text using the scriptparser.
| str | The text data. | |
| env | The variable space. |
References split().

Create a copy of a text block that applies word wrapping.
| str | The original string. | |
| marg | The right margin to apply. |
References string::left(), string::mid(), string::printf(), split(), string::str(), and string::strlen().

1.6.1