strutil Class Reference

String utility class. More...

#include <strutil.h>

List of all members.

Static Public Member Functions

static valuesplitspace (const string &)
static valuesplit (const string &str, char sep)
static valuesplitescaped (const string &str, char sep, const string &escapees="")
static valuesplit (const string &str, const string &seq)
static valuesplitquoted (const string &str, char sep=0, bool forxml=false)
static valuesplitcsv (const string &)
static stringencodecsv (const string &)
static valueparsehdr (const string &hdr)
static bool crlfornot (const string &str)
static valueparsemime (const string &dat)
static valuesplitlines (const string &str)
static stringurlencode (const string &str)
static stringurldecode (const string &)
static valueparsenv (const string &line, char split=';', char nvsplit='=')
static valuehttpurldecode (const string &str)
static stringhttpurlencode (value &v)
static stringunescape (const string &str)
static stringregexp (const string &str, const string &exp)
static stringwrap (const string &str, unsigned int marg)
static stringhtmlize (const string &)
static void xmlreadtag (xmltag *, const string *)
static stringtitlecaps (const string &)
static stringvalueparse (const string &str, const value &env)
static stringmakepath (const string &str)
static stringuuid (void)

Detailed Description

String utility class.

Contains solely static methods for advanced string parsing and manipulation.


Member Function Documentation

bool strutil::crlfornot ( const string str  )  [static]

Scan text to determine whether to use CRLF or just LF for end-of-line parsing.

Parameters:
str Text data with newlines.
Returns:
Status, true if CRLF should be used or false if LF is the native newline.

References string::strchr(), and string::strstr().

Referenced by parsemime(), and splitlines().

Here is the call graph for this function:

string * strutil::encodecsv ( const string data  )  [static]

Encode string data using CSV rules.

Returns:
New encoded string object.

References string::strcat(), and string::strlen().

Referenced by value::savecsv(), and value::tocsv().

Here is the call graph for this function:

string * strutil::htmlize ( const string src  )  [static]

Create a copy of a text block that converts ASCII to escaped valid html data.

Returns:
New copied object.

References string::strcat(), and string::strlen().

Here is the call graph for this function:

value * strutil::httpurldecode ( const string str  )  [static]

Derive variables from a GET request.

Parameters:
str Text data in QUERY_STRING format.
Returns:
New value object with key/value pairs out of the query string.

References string::cutat(), split(), string::strlen(), and urldecode().

Referenced by httpdscriptparser::run(), and serverpage::run().

Here is the call graph for this function:

string * strutil::httpurlencode ( value v  )  [static]

Encode a keyed list of values as a GET request.

Parameters:
v A value object containing a flat collection of key/value pairs.
Returns:
New string object with encoded data.

References string::printf(), string::str(), and urlencode().

Here is the call graph for this function:

string * strutil::makepath ( const string str  )  [static]

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().

Here is the call graph for this function:

value * strutil::parsehdr ( const string hdr  )  [static]

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.

Parameters:
hdr The header string.
Returns:
New value object.

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().

Here is the call graph for this function:

value * strutil::parsemime ( const string dat  )  [static]

Parse a MIME multipart text block.

Parameters:
dat Text data with multipart mime.
Returns:
New value object with parsed mime data.

References crlfornot(), string::cutat(), parsehdr(), and splitlines().

Referenced by cgi::cgi().

Here is the call graph for this function:

value * strutil::parsenv ( const string line,
char  split = ';',
char  nvsplit = '=' 
) [static]

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:

  • foo=bar;test=42;zed="dead, baby"
  • foo = bar; test = 42; zed = dead, baby
  • foo="bar" ; test="42"; zed="dead, baby"
    Parameters:
    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().

Here is the call graph for this function:

string * strutil::regexp ( const string str,
const string exp 
) [static]

Perform a regular expression on a string.

Parameters:
str The source string.
exp The regular expression.
Returns:
New copied object.

Referenced by value::decode(), smtpsocket::dosmtp(), httpsocket::get(), value::load(), httpsocket::post(), httpdrewrite::run(), and cmdtoken_set::run().

value * strutil::split ( const string str,
const string seq 
) [static]

Split string into array of words.

Looks for a specified separator sequence.

Parameters:
str The string data.
sep The separator sequence.

References string::mid(), string::strlen(), and string::strstr().

Here is the call graph for this function:

value * strutil::split ( const string str,
char  sep 
) [static]

Split string into array of words.

Looks for a specified separator character.

Parameters:
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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

value * strutil::splitlines ( const string str  )  [static]

Split a text block into an array of lines.

Parameters:
str Text data with multiple lines.
Returns:
New value object with numbered array.

References value::count(), crlfornot(), value::rmindex(), and split().

Referenced by value::fromcsv(), and parsemime().

Here is the call graph for this function:

value * strutil::splitquoted ( const string str,
char  sep = 0,
bool  forxml = false 
) [static]

Split string into array of arguments.

Accepts double and single quotes as means of escaping the separator.

Parameters:
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().

Here is the call graph for this function:

value * strutil::splitspace ( const string str  )  [static]

Split string into array of words.

The string is split on whitespace boundaries, with any whitespace at the start ignored:

  • "one two three" -> "one","two","three"
  • " hi \tthere" -> "hi","there"

References string::mid(), and string::strlen().

Referenced by httpdfileshare::httpdfileshare(), and titlecaps().

Here is the call graph for this function:

string * strutil::titlecaps ( const string src  )  [static]

Convert a string to title caps.

Capitalizes every word except for certqain words like 'the', 'of', 'de', etc.

Returns:
New copied object.

References string::capitalize(), value::exists(), and splitspace().

Here is the call graph for this function:

string * strutil::unescape ( const string str  )  [static]

Create an unescaped copy of a string.

Parameters:
str Escaped data.
Returns:
New copied object.

References string::strlen().

Referenced by splitquoted().

Here is the call graph for this function:

string * strutil::urldecode ( const string src  )  [static]

Decode a string from a HTTP GET request.

Parameters:
str The encoded string.
Returns:
New string object with decoded data.

References string::strcat(), and string::strlen().

Referenced by cgi::cgi(), and httpurldecode().

Here is the call graph for this function:

string * strutil::urlencode ( const string str  )  [static]

Encode a string suitable for encoding as a parameter in a HTTP GET request.

Parameters:
str The unencoded string.
Returns:
New string object with encoded data.

References string::strcat(), and string::strlen().

Referenced by httpurlencode(), and httpsocket::post().

Here is the call graph for this function:

string * strutil::valueparse ( const string str,
const value env 
) [static]

Parses a string of text using the scriptparser.

Parameters:
str The text data.
env The variable space.
Returns:
New string object.

References split().

Here is the call graph for this function:

string * strutil::wrap ( const string str,
unsigned int  marg 
) [static]

Create a copy of a text block that applies word wrapping.

Parameters:
str The original string.
marg The right margin to apply.
Returns:
New copied object.

References string::left(), string::mid(), string::printf(), split(), string::str(), and string::strlen().

Here is the call graph for this function:


The documentation for this class was generated from the following files:

Generated on Sun Feb 28 10:36:45 2010 for GRACE by  doxygen 1.6.1