string Class Reference

Generic string storage. More...

#include <str.h>

Inheritance diagram for string:
Inheritance graph
[legend]
Collaboration diagram for string:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 string (void)
 string (const char *)
 string (const unsigned char *)
 string (const string &)
 string (const class statstring &)
 string (string *)
 string (unsigned int sz)
char * visitchild (int pos) const
 operator bool (void) const
 operator const char * (void) const
void printf (const char *,...)
void printf_va (const char *, va_list *)
stringstriplf (void)
unsigned int strlen (void) const
unsigned int utf8len (void) const
unsigned int utf8pos (int i) const
void utf8pad (int i, char with= ' ')
void strcat (const char *)
void strcat (const string &)
void strcat (string *)
void strcat (const char *dt, size_t sz)
void strcat (char s)
void strcat (int)
void strcat (double)
void strcat (const class value &)
void strcat (const class statstring &)
void insert (const string &)
void strcpy (const char *)
void strcpy (const string &)
void strclone (const string &)
void strcpy (const char *dt, size_t sz)
int strstr (const char *dat, size_t sz, int offset=0) const
int strstr (const char *, int offset=0) const
int strstr (const string &, int offset=0) const
int countchr (char c, int endpos=0) const
int strcmp (const char *) const
int strcmp (const string &) const
int strncmp (const string &, int sz=0) const
int strcasecmp (const string &) const
int strcasecmp (const char *) const
int strncasecmp (const string &, int sz=0) const
bool globcmp (const string &str) const
bool regcmp (const string &str) const
bool globcmp (const char *str) const
bool eq (const char *s) const
bool eq (const string &s) const
size_t binputopc (size_t offset, const char *opcode)
size_t binputnum64 (size_t offset, const char *opcode, long long value)
size_t binputnum32 (size_t offset, const char *opcode, unsigned int value)
size_t binputnum16 (size_t offset, const char *opcode, unsigned int value)
size_t binputstr (size_t offset, const char *opcode, const string &value)
size_t binputnum8 (size_t offset, const char *opcode, unsigned int value)
size_t binputvint (size_t offset, unsigned int val)
size_t bingetvint (size_t atoffset, unsigned int &into) const
size_t binputvstr (size_t offset, const string &str)
size_t bingetvstr (size_t atoffset, string &into) const
size_t binputieee (size_t offset, double val)
size_t bingetieee (size_t offset, double &into) const
void escape (void)
void unescape (void)
void escapexml (void)
void unescapexml (void)
void flush (void)
void crop (void)
void clear (void)
void crop (int sz)
void pad (int sz, char filler)
stringmid (int pos, int sz=0) const
stringleft (int sz) const
stringright (int sz) const
stringencode64 (void) const
stringdecode64 (void) const
void docopyonwrite (void)
const char * str (void) const
const char * cval (void) const
bool validate (const string &set) const
stringfilter (const string &set) const
stringstripchar (char stripchar)
stringstripchars (const string &stripset)
stringtrim (const string &set=" ") const
stringltrim (const string &set=" ") const
stringrtrim (const string &set=" ") const
void replace (const string &set, char with)
void replace (const class value &set)
int strchr (char c, int left=0) const
void cropat (char c)
void cropat (const char *c)
void cropatlast (char c)
void cropatlast (const char *c)
void cropafter (char c)
void cropafter (const char *c)
void cropafterlast (char c)
void cropafterlast (const char *c)
stringcutat (char c)
stringcutatlast (char c)
stringcutat (const char *c)
stringcutatlast (const char *c)
stringcutafter (const string &str)
stringcutafter (char c)
stringcutafterlast (const string &str)
stringcutafterlast (char c)
stringcopyuntil (const string &s) const
stringcopyuntil (char c) const
stringcopyuntillast (const string &s) const
stringcopyuntillast (char c) const
stringcopyafter (const string &s) const
stringcopyafter (char c) const
stringcopyafterlast (const string &s) const
stringcopyafterlast (char c) const
void ctolower (void)
void ctoupper (void)
stringlower (void) const
stringupper (void) const
void capitalize (void)
int toint (int base=10) const
void chomp (void)
void chomp (const string &set)
virtual void init (bool first=true)



const char operator[] (int n) const
char & operator[] (int n)
bool operator== (const char *str) const
bool operator== (const class value &) const
bool operator== (const string &str) const
bool operator== (const class statstring &) const
bool operator!= (const class statstring &) const
stringoperator= (const string &str)
stringoperator= (class value &)
stringoperator= (const class value &)
stringoperator= (const char *str)
stringoperator= (const unsigned char *str)
stringoperator= (string *str)
stringoperator= (class statstring *str)
stringoperator= (const class statstring &str)
bool operator!= (const class value &v) const
bool operator!= (const string &str) const
bool operator!= (const char *str) const
stringoperator+= (const string &str)
stringoperator+= (string *str)
stringoperator+= (class value *)
stringoperator+= (class value &)
stringoperator+= (const char *str)
stringoperator+ (const string &str) const
size_t binput64 (size_t offset, long long val)
size_t binput64u (size_t offset, unsigned long long val)
size_t binput32u (size_t offset, unsigned int val)
size_t binput32 (size_t offset, int)
size_t binput32o (size_t offset, const char *offs)
size_t binput16u (size_t offset, unsigned short val)
size_t binput16 (size_t offset, short)
size_t binput8u (size_t offset, unsigned char val)
size_t binput8 (size_t offset, char)
size_t binget8 (size_t offset, char &) const
size_t binget8u (size_t offset, unsigned char &) const
size_t binget16 (size_t offset, short &) const
size_t binget16u (size_t offset, unsigned short &) const
size_t binget32 (size_t offset, int &) const
size_t binget32u (size_t offset, unsigned int &) const
size_t binget64 (size_t offset, long long &) const
size_t binget64u (size_t offset, unsigned long long &) const

Protected Attributes

unsigned int size
unsigned int offs
unsigned int alloc
refblockdata

Detailed Description

Generic string storage.

Uses copy-on-write shared storage for efficiency.


Constructor & Destructor Documentation

string::string ( const string s  ) 

Copy-constructor.

Shares the other object's refblock.

References alloc, data, offs, refblock::refcount, size, strclone(), strlen(), and refblock::threadref.

Here is the call graph for this function:

string::string ( string s  ) 

Copy-constructor (deletes original).

Takes over the other object's refblock, unlinks the refblock from the original owner and then deletes the old object.

References alloc, data, offs, size, and strlen().

Here is the call graph for this function:

string::string ( unsigned int  sz  ) 

Constructor (pre-allocated).

Sets up the buffer for the string to at least the required size.

Parameters:
sz Requested array size.

References alloc, data, offs, refblock::refcount, size, and refblock::threadref.


Member Function Documentation

size_t string::binputvint ( size_t  offset,
unsigned int  val 
)

Add a SHOX variable int.

The shox output format uses variable length integers to represent internal counters and ids. The general idea is to not use more bytes than strictly necessary. The integer is always encoded in little-endian order, with the highest two bits indicating the length of the integer, yielding a maximum of 30 available bits. If the two upper bits are set to '00' the value is sized 1 byte with 6 bits left. If they are set to '01' the size grows to 2 bytes for 14 bits of storage, &c.

References data, docopyonwrite(), offs, pad(), size, and refblock::v.

Referenced by binputvstr(), and value::printshox().

Here is the call graph for this function:

size_t string::binputvstr ( size_t  offset,
const string str 
)

Write a SHOX variable string.

A shox string is a shox vint followed by string data. For string sizes up to 63 bytes this is the same as a pascal string.

References binputvint(), data, offs, pad(), size, str(), strlen(), and refblock::v.

Referenced by value::printshox().

Here is the call graph for this function:

void string::chomp ( const string set  ) 

Strip leading and trailing characters.

Parameters:
set The set of characters to strip.

References trim().

Here is the call graph for this function:

void string::clear ( void   )  [inline]

Alias to align naming with class value.

Calls crop().

References crop().

Here is the call graph for this function:

string * string::copyafter ( char  c  )  const

Get a copy of the string after the first occurence of a separator.

Parameters:
c The separator.
Returns:
Copied object.

References mid(), and strchr().

Here is the call graph for this function:

string * string::copyafter ( const string s  )  const

Get a copy of the string after the first occurence of a separator.

Parameters:
s The separator.
Returns:
Copied object.

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

Referenced by filesystem::ls().

Here is the call graph for this function:

string * string::copyafterlast ( char  c  )  const

Get a copy of the string after the last occurence of a separator.

Parameters:
c The separator.
Returns:
Copied object.

References mid(), and strchr().

Here is the call graph for this function:

string * string::copyafterlast ( const string s  )  const

Get a copy of the string after the last occurence of a separator.

Parameters:
s The separator.
Returns:
Copied object.

References mid(), and strstr().

Here is the call graph for this function:

string * string::copyuntil ( char  c  )  const

Get a copy of the string until the first occurence of a separator.

Parameters:
c The separator.
Returns:
Copied object.

References left(), and strchr().

Here is the call graph for this function:

string * string::copyuntil ( const string s  )  const

Get a copy of the string until the first occurence of a separator.

Parameters:
s The separator.
Returns:
Copied object.

References left(), and strstr().

Referenced by filesystem::ls().

Here is the call graph for this function:

string * string::copyuntillast ( char  c  )  const

Get a copy of the string until the last occurence of a separator.

Parameters:
c The separator.
Returns:
Copied object.

References left(), and strchr().

Here is the call graph for this function:

string * string::copyuntillast ( const string s  )  const

Get a copy of the string until the last occurence of a separator.

Parameters:
s The separator.
Returns:
Copied object.

References left(), and strstr().

Here is the call graph for this function:

int string::countchr ( char  c,
int  endpos = 0 
) const

Count the number of occurences of a character in the string (optionally up to a given position).

References data, offs, and refblock::v.

Referenced by strutil::xmlreadtag().

void string::crop ( int  sz  ) 

Crop the buffer to a set size.

Parameters:
sz Desired maximum size. If negative, keep the rightmost part of the original.

References alloc, tune::str::cropcopylimit, data, offs, refblock::refcount, size, refblock::threadref, and refblock::v.

void string::crop ( void   ) 
void string::cropafter ( const char *  c  ) 

Crop the string to contain only the data to the right of the first occurence of a sequence.

If the character is not found, the string is cropped to zero size.

References crop(), strlen(), and strstr().

Here is the call graph for this function:

void string::cropafter ( char  c  ) 

Crop the string to contain only the data to the right of the first occurence of a character.

If the character is not found, the string is cropped to zero size.

References crop(), strchr(), and strlen().

Here is the call graph for this function:

void string::cropafterlast ( const char *  c  ) 

Crop the string to contain only the data to the right of the last occurence of a sequence.

If the character is not found, the string is cropped to zero size.

References crop(), strlen(), and strstr().

Here is the call graph for this function:

void string::cropafterlast ( char  c  ) 

Crop the string to contain only the data to the right of the last occurence of a character.

If the character is not found, the string is cropped to zero size.

References crop(), strchr(), and strlen().

Here is the call graph for this function:

void string::cropat ( const char *  c  ) 

Crop the string until the first occurence of a sequence.

If none are found the string is left intact.

Parameters:
c The character sequence to look for

References crop(), and strstr().

Here is the call graph for this function:

void string::cropat ( char  c  ) 

Crop the string until the first occurence of a character.

If none are found the string is left intact.

Parameters:
c The character to look for

References crop(), and strchr().

Referenced by httpd::handle(), httpdfileshare::run(), and smtpsocket::setsender().

Here is the call graph for this function:

void string::cropatlast ( const char *  c  ) 

Crop the string until the last occurence of a sequence.

If none are found the string is left intact.

Parameters:
c The character sequence to look for

References crop(), and strstr().

Here is the call graph for this function:

void string::cropatlast ( char  c  ) 

Crop the string until the last occurence of a character.

If none are found the string is left intact.

Parameters:
c The character to look for

References crop(), and strchr().

Here is the call graph for this function:

string * string::cutafter ( char  c  ) 

Split the string in two parts.

Returns a new object containing the right half.

Parameters:
c The separation char.
Returns:
Cut data.

References mid(), and strchr().

Here is the call graph for this function:

string * string::cutafter ( const string str  ) 

Split the string in two parts.

Returns a new object containing the right half.

Parameters:
str The separation sequence.
Returns:
Cut data.

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

Referenced by httpdlogger::handle().

Here is the call graph for this function:

string * string::cutafterlast ( char  c  ) 

Split the string in two parts.

Returns a new object containing the right half. The split is performed at the last location of the separator.

Parameters:
c The separation char.
Returns:
Cut data.

References mid(), and strchr().

Here is the call graph for this function:

string * string::cutafterlast ( const string str  ) 

Split the string in two parts.

Returns a new object containing the right half. The split is performed at the last location of the separator.

Parameters:
str The separation sequence.
Returns:
Cut data.

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

Here is the call graph for this function:

string * string::cutat ( const char *  c  ) 

Split the string in two parts.

Returns a new object containing the left half. The first occurence of a separator sequence is used as a splitting point.

Parameters:
c The string to be used as a separator. It will be included in neither of the two. If the sequence is not found, an empty string object is returned and the local string data is left untouched.
Returns:
Cut data.

References crop(), left(), offs, strlen(), and strstr().

Here is the call graph for this function:

string * string::cutat ( char  c  ) 

Split the string in two parts.

Returns a new object containing the left half. The first occurence of a separator character is used as a splitting point.

Parameters:
c The character to be used as a separator. It will be included in neither of the two. If the sequence is not found, an empty string object is returned and the local string data is left untouchd.
Returns:
Cut data.

References crop(), left(), offs, and strchr().

Referenced by application::application(), scriptparser::build(), value::decode(), dbfile::decode(), filesystem::exists(), timestamp::format(), httpsocket::get(), filesystem::getresource(), strutil::httpurldecode(), timestamp::iso(), filesystem::mkdir(), filesystem::mv(), xmlschema::nstransattr(), xmlschema::nstranstype(), strutil::parsemime(), strutil::parsenv(), httpsocket::post(), filesystem::rm(), httpdbasicauth::run(), httpdworker::run(), and cmdtoken_data::run().

Here is the call graph for this function:

string * string::cutatlast ( const char *  c  ) 

Split the string in two parts.

Returns a new object containing the left half. The last occurence of a separator sequence is used as a splitting point.

Parameters:
c The string to be used as a separator. It will be included in neither of the two. If the sequence is not found, an empty string object is returned and the local string data is left untouched.
Returns:
Cut data.

References crop(), left(), offs, strlen(), and strstr().

Here is the call graph for this function:

string * string::cutatlast ( char  c  ) 

Split the string in two parts.

Returns a new object containing the left half. The last occurence of a separator character is used as a splitting point.

Parameters:
c The character to be used as a separator. It will be included in neither of the two. If the sequence is not found, an empty string object is returned and the local string data is left untouched.

Usage example:

void myclass::printFileNames (value &listOfFileNames)
{
    for (int i=0; i < listOfFileNames.count(); ++i)
    {
        string fName = listOfFileNames[i];
        string fBase;
        
        fBase = fName.cutatlast ('.');
        if (fBase)
        {
            // Print out filename sans extension.
            fout.printf ("%s\n", fBase.str());
        }
        else // Filename had no extension.
        {
            fout.printf ("%s\n", fName.str());
        }
    }
}
Returns:
Cut data.

References crop(), left(), offs, and strchr().

Referenced by strutil::makepath().

Here is the call graph for this function:

string * string::decode64 ( void   )  const

Create base64-decoded version of self.

Returns:
New decoded object.

References data, offs, strlen(), and refblock::v.

Referenced by value::fromxml(), and httpdbasicauth::run().

Here is the call graph for this function:

void string::docopyonwrite ( void   )  [inline]

Create private reference.

If the string data is shared with other references, a new unique copy is allocated so that we can mess with our data without interfering with that of other string objects.

References alloc, data, offs, refblock::refcount, size, refblock::threadref, and refblock::v.

Referenced by binput64(), binputieee(), binputopc(), binputvint(), ctolower(), ctoupper(), pad(), replace(), and str().

string * string::encode64 ( void   )  const

Create base64-encoded version of self.

Returns:
New encoded object.

References data, offs, strlen(), and refblock::v.

Referenced by httpsocket::authentication(), md5checksum::base64(), and value::printxml().

Here is the call graph for this function:

void string::escape ( void   ) 

Escape data in the buffer.

Useful for SQL or other areas where quotes, backslashes, the percent-sign and control characters are unwanted.

References alloc, data, offs, refblock::refcount, size, strcat(), and refblock::v.

Here is the call graph for this function:

void string::escapexml ( void   ) 

Escape data in the buffer for XML.

Encodes any characters that would mess up with CDATA-like situations:

  • The ampersand '&' is replaced by the sequence '&'
  • The less-than symbol '<' is replaced by the sequence '<'
  • Although not strictly necessary, the greather-than symbol '>' is replaced by the sequence '>'

References alloc, data, offs, printf(), refblock::refcount, size, strcat(), and refblock::v.

Here is the call graph for this function:

string * string::filter ( const string set  )  const

Create a new string with only a subset of characters.

Parameters:
set The character set.
Returns:
Copy with all characters not in the set omitted.

References data, offs, size, strchr(), and refblock::v.

Referenced by smtpd::normalizeaddr().

Here is the call graph for this function:

void string::flush ( void   ) 

Remove buffer data without resizing the buffer.

The strlen() will be reset to 0 but there will be no reallocation of the buffer.

References alloc, data, refblock::refcount, size, and refblock::v.

bool string::globcmp ( const char *  str  )  const

Perform a glob match against a wildcard.

Parameters:
str The glob-style wildcard statement.
Returns:
Match result, true if positive.

References str().

Here is the call graph for this function:

bool string::globcmp ( const string str  )  const

Perform a glob match against a wildcard.

Parameters:
str The glob-style wildcard statement.
Returns:
Match result, true if positive.

References str().

Referenced by httpsocket::get(), httpd::handle(), httpsocket::post(), and cmdtoken_if::run().

Here is the call graph for this function:

void string::insert ( const string s  ) 

Add string data at the start.

Inserts the data from the other string at the left side of the buffer.

References alloc, data, offs, refblock::refcount, size, str(), strcpy(), strlen(), refblock::threadref, and refblock::v.

Here is the call graph for this function:

string* string::left ( int  sz  )  const [inline]

Derive new string from left range.

Parameters:
sz Number of bytes from the left to copy.
Returns:
New object with the result.

References mid().

Referenced by cgi::cgi(), chomp(), copyuntil(), copyuntillast(), cutat(), cutatlast(), value::left(), ltrim(), strutil::makepath(), strutil::parsehdr(), rtrim(), httpdvhost::run(), filesystem::transr(), filesystem::transw(), trim(), and strutil::wrap().

Here is the call graph for this function:

string * string::ltrim ( const string set = " "  )  const

Trims charcters from the left of the current string until it finds a character not in the set.

Parameters:
set Set of special characters
Returns:
New trimmed string

References data, left(), mid(), offs, size, strchr(), and refblock::v.

Referenced by cli< ctlclass >::tabhandler().

Here is the call graph for this function:

string * string::mid ( int  pos,
int  sz = 0 
) const
const char string::operator[] ( int  n  )  const [inline]

Array access.

Out-of-range indices return a ''.

Parameters:
n Position. Use negative for position from the right.

References data, offs, size, and refblock::v.

void string::pad ( int  sz,
char  filler 
)

Pad/crop the buffer.

Useful for creating aligned layouts with fixed space fonts.

Parameters:
sz Desired size (only positive).
filler Filler character to use for padding.

References alloc, crop(), data, docopyonwrite(), offs, size, strcat(), and refblock::v.

Referenced by binput64(), binputieee(), binputopc(), binputstr(), binputvint(), binputvstr(), logthread::run(), and utf8pad().

Here is the call graph for this function:

void string::printf ( const char *  fmtx,
  ... 
)

Add data with libc-style format string.

There are some extra format characters to keep in mind:

  • %L formats as long long
  • %U formats as unsigned long long
  • %S Escapes a string argument.
  • %Z Escapes a string argument for XML.

Keep in mind that the formatted text is added to the string buffer. Use string::crop() to empty the buffer first if you want to start with a clear string.

References printf_va().

Referenced by cgi::addschema(), cgi::cgi(), tcpsocket::connect(), thread::dorun(), escapexml(), value::fromxml(), filesystem::getinfo(), systemclass::userdbFunctions::getpwuid(), file::gets(), strutil::httpurlencode(), fswatch::list(), configdb< appclass >::load(), value::loadini(), value::loadinitree(), filesystem::ls(), value::parsecompressed(), value::phpdeserialize(), value::print(), value::printphp(), value::printstr(), value::printxml(), filesystem::pwdize(), file::read(), file::readbuffer(), smtpworker::run(), httpdbasicauth::run(), logthread::run(), value::savecsv(), value::tocsv(), tcpsocket::uconnect(), file::waitforline(), strutil::wrap(), and strutil::xmlreadtag().

Here is the call graph for this function:

bool string::regcmp ( const string str  )  const

Perform a regular expression match.

Parameters:
str The expression.
Returns:
Match result, true if positive.

References str().

Here is the call graph for this function:

void string::replace ( const class value set  ) 

Do a complex character substitution.

The input set is a value dict, with each key representing a sequence of characters in the string that should be replaced by the sequence in the entry's value.

void string::replace ( const string set,
char  with 
)

Filter the string with a subset of characters replaced by a single replacement.

Parameters:
set The character set.
with The character to replace characters in the set with.
Returns:
Copy with all characters not in the set omitted.

References data, docopyonwrite(), offs, size, strchr(), and refblock::v.

Here is the call graph for this function:

string* string::right ( int  sz  )  const [inline]

Derive new string from right range.

Parameters:
sz Number of bytes from the right to copy.
Returns:
New object with the result.

References mid(), size, and string().

Referenced by chomp(), rtrim(), and trim().

Here is the call graph for this function:

string * string::rtrim ( const string set = " "  )  const

Trims charcters from the right of the current string until it finds a character not in the set.

Parameters:
set Set of special characters
Returns:
New trimmed string

References data, left(), offs, right(), size, strchr(), and refblock::v.

Referenced by striplf(), and cli< ctlclass >::tabhandler().

Here is the call graph for this function:

void string::strcat ( double   ) 

Add a printed floating point number.

Converts the double to an ASCII representation of the floating point data.

void string::strcat ( int   ) 

Add a printed integer.

Converts the integer to a base 10 ASCII string and adds this representation to the buffer.

void string::strcat ( const char *  dt,
size_t  sz 
)

Add binary data.

Parameters:
dt The data block.
sz Number of bytes to copy.

References alloc, data, offs, refblock::refcount, size, refblock::threadref, and refblock::v.

void string::strcat ( string s  ) 

Add string data (remove original).

Concatenates the buffer data from the original string then removes the original string and its refblock.

References strcat().

Here is the call graph for this function:

int string::strchr ( char  c,
int  left = 0 
) const
void string::strclone ( const string s  ) 

Clone from other string.

Ensures that no reference is shared with the original.

References alloc, data, offs, refblock::refcount, size, strlen(), refblock::threadref, and refblock::v.

Referenced by strcpy(), and string().

Here is the call graph for this function:

void string::strcpy ( const char *  dt,
size_t  sz 
)

Copy from binary data.

Buffer will be cleared.

Parameters:
dt The data location.
sz The number of ytes to copy.

References alloc, data, offs, refblock::refcount, size, refblock::threadref, and refblock::v.

string * string::stripchar ( char  stripchar  ) 

Create a new string without the given character.

Parameters:
stripchar The character to strip
Returns:
Copy with the given character stripped

References data, offs, size, and refblock::v.

string * string::stripchars ( const string stripset  ) 

Create a new string without the given characters.

Parameters:
stripset Strips a set of characters
Returns:
Copy without the given characters

References data, offs, size, strchr(), and refblock::v.

Here is the call graph for this function:

string * string::striplf ( void   ) 

Remove trailing newline.

Takes away a trailing \n or \r\n sequence.

Returns:
new string without trailing linefeed

References rtrim().

Here is the call graph for this function:

unsigned int string::strlen ( void   )  const [inline]

Get string length.

Returns:
Size in characters.

References size.

Referenced by cgi::addschema(), md5checksum::append(), termbuffer::backspace(), binputstr(), binputvstr(), scriptparser::build(), cgi::cgi(), daemon::checkpid(), filesystem::chgrp(), filesystem::chown(), termbuffer::clearleft(), file::close(), tcpsocket::connect(), httpsocket::connectToHost(), copyafter(), filesystem::cp(), termbuffer::crhome(), termbuffer::crleft(), cropafter(), cropafterlast(), termbuffer::crsrpos(), termbuffer::crup(), timestamp::ctime(), cutafter(), cutafterlast(), cutat(), cutatlast(), value::decode(), decode64(), termbuffer::del(), encode64(), strutil::encodecsv(), termbuffer::eraseword(), value::fromcsv(), value::fromcxml(), value::fromshox(), value::fromxml(), cli< ctlclass >::fullexpand(), httpsocket::get(), filesystem::getinfo(), termbuffer::getkey(), termbuffer::getline(), stringrefdb::getref(), filesystem::getresource(), file::gets(), httpdlogger::handle(), httpd::handle(), systemclass::netFunctions::hostname(), strutil::htmlize(), strutil::httpurldecode(), value::iniparse(), termbuffer::insert(), insert(), filesystem::isdir(), timestamp::iso(), termbuffer::length(), value::loadcsv(), value::loadini(), value::loadinitree(), value::loadxml(), filesystem::mkdir(), filesystem::mv(), xmlschema::nstransattr(), file::openappend(), file::openread(), file::openwrite(), statstring::operator bool(), value::parsecompressed(), strutil::parsenv(), httpsocket::post(), value::print(), file::printf(), printf_va(), value::printshox(), value::printstr(), value::printxml(), file::puts(), file::read(), filesystem::rm(), cli< ctlclass >::run(), smtpworker::run(), httpdfileshare::run(), httpdvhost::run(), httpdbasicauth::run(), httpdworker::run(), cmdtoken_if::run(), filesystem::save(), tcpsocket::sendfile(), cgi::sendpage(), udpsocket::sendto(), termbuffer::set(), termbuffer::setcrsr(), termbuffer::setprompt(), strutil::split(), strutil::splitcsv(), strutil::splitescaped(), strutil::splitquoted(), strutil::splitspace(), cliutil::splitwords(), smtpd::start(), strcasecmp(), strcat(), strclone(), strcmp(), strcpy(), string(), value::strlen(), statstring::strlen(), strncasecmp(), strncmp(), strstr(), cli< ctlclass >::tabhandler(), termbuffer::tohistory(), termbuffer::tprintf(), termbuffer::tputs(), file::tryputs(), strutil::unescape(), stringrefdb::unref(), strutil::urldecode(), strutil::urlencode(), utf8pad(), termbuffer::wordleft(), strutil::wrap(), file::writeln(), daemon::writepid(), and strutil::xmlreadtag().

int string::strstr ( const string substr,
int  offset = 0 
) const

Find a string sequence.

Returns:
Sequence position or -1.

References str(), strlen(), and strstr().

Here is the call graph for this function:

int string::strstr ( const char *  substr,
int  offset = 0 
) const

Find a string sequence.

Returns:
Sequence position or -1.

References strlen(), and strstr().

Here is the call graph for this function:

int string::strstr ( const char *  dat,
size_t  sz,
int  offset = 0 
) const

Find a sequence.

Parameters:
dat The search data.
sz Size of the sequence.
offset Index to start the search at.
Returns:
Sequence position or -1.

References data, offs, size, and refblock::v.

Referenced by application::application(), cgi::cgi(), copyafter(), copyafterlast(), copyuntil(), copyuntillast(), strutil::crlfornot(), cropafter(), cropafterlast(), cropat(), cropatlast(), cutafter(), cutafterlast(), cutat(), cutatlast(), timestamp::format(), filesystem::ls(), httpdfileshare::run(), cmdtoken_data::run(), strutil::split(), strstr(), and strutil::xmlreadtag().

int string::toint ( int  base = 10  )  const

Cast to integer.

Parameters:
base Optional math base to use.

References data, and str().

Referenced by smtpsocket::dosmtp(), timestamp::iso(), terminal< cli< ctlclass > >::readline(), cmdtoken_set::run(), and strutil::splitcsv().

Here is the call graph for this function:

string * string::trim ( const string set = " "  )  const

Trims charcters from the left and right of the current string until it finds a character not in the set.

Parameters:
set Set of special characters
Returns:
New trimmed string

References data, left(), mid(), offs, right(), size, strchr(), and refblock::v.

Referenced by chomp().

Here is the call graph for this function:

void string::unescape ( void   ) 

Unescape data in the buffer.

Uses the reverse rules of escape().

References alloc, data, offs, refblock::refcount, size, strcat(), and refblock::v.

Here is the call graph for this function:

unsigned int string::utf8len ( void   )  const

Naive calculation of the effective length in characters if the string contains UTF-8 data.

Double wide characters are not currently included in this calculation.

References data, offs, size, and refblock::v.

Referenced by utf8pad().

void string::utf8pad ( int  i,
char  with = ' ' 
)

Pad the string to a specific count of UTF-8 characters.

References crop(), pad(), strlen(), utf8len(), and utf8pos().

Here is the call graph for this function:

unsigned int string::utf8pos ( int  i  )  const

Find the byte-position of a specific character position inside a string possibly represented as UTF-8.

Double wide characters are not taken into account.

References data, offs, size, and refblock::v.

Referenced by utf8pad().

bool string::validate ( const string set  )  const

Validate string against a set of 'legal' characters.

Parameters:
set The collection of permitted chars.
Returns:
Status, true if validated ok.

References data, offs, size, strchr(), and refblock::v.

Here is the call graph for this function:

char * string::visitchild ( int  pos  )  const

Implementation of the iterator protocol, makes string foreachable.

References data, offs, and refblock::v.


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

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