Yate: String Class Reference

Yate

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
String Class Reference

A C-style string handling class. More...

`#include <yateclass.h>`

Inheritance diagram for String:

## Public Types
enum | Align { Left = 0 , Center , Right }

## Public Member Functions
| String ()
| String (const char *value, int len=-1)
| String (char value, unsigned int repeat=1)
| String (int32_t value)
| String (uint32_t value)
| String (int64_t value)
| String (uint64_t value)
| String (bool value)
| String (double value)
| String (const String &value)
| String (const String *value)
virtual | ~String ()
virtual void * | getObject (const String &name) const
const char * | c_str () const
const char * | safe () const
const char * | safe (const char *defStr) const
unsigned int | length () const
bool | null () const
int | lenUtf8 (uint32_t maxChar=0x10ffff, bool overlong=false) const
int | fixUtf8 (const char *replace=0, uint32_t maxChar=0x10ffff, bool overlong=false)
unsigned int | encodeFlags (const TokenDict *tokens) const
uint64_t | encodeFlags (const TokenDict64 *tokens) const
String & | decodeFlags (unsigned int flags, const TokenDict *tokens, bool unknownflag=true)
String & | decodeFlags (uint64_t flags, const TokenDict64 *tokens, bool unknownflag=true)
bool | checkBOM () const
bool | stripBOM ()
unsigned int | hash () const
void | clear ()
char | at (int index) const
String | substr (int offs, int len=-1) const
String & | trimBlanks ()
String & | trimSpaces ()
virtual const String & | toString () const
int | toInteger (int defvalue=0, int base=0, int minvalue=INT_MIN, int maxvalue=INT_MAX, bool clamp=true) const
int | toInteger (const TokenDict *tokens, int defvalue=0, int base=0) const
int | toInteger (const TokenDictStr *tokens, int defvalue=0, int base=0) const
long int | toLong (long int defvalue=0, int base=0, long int minvalue=LONG_MIN, long int maxvalue=LONG_MAX, bool clamp=true) const
int64_t | toInt64 (int64_t defvalue=0, int base=0, int64_t minvalue=LLONG_MIN, int64_t maxvalue=LLONG_MAX, bool clamp=true) const
int64_t | toInt64Dict (const TokenDict64 *tokens, int64_t defvalue=0, int base=0) const
int64_t | toInt64Dict (const TokenDictStr64 *tokens, int64_t defvalue=0, int base=0) const
uint64_t | toUInt64 (uint64_t defvalue=0, int base=0, uint64_t minvalue=0, uint64_t maxvalue=ULLONG_MAX, bool clamp=true) const
double | toDouble (double defvalue=0.0) const
bool | toBoolean (bool defvalue=false) const
bool | isBoolean () const
String & | toUpper ()
String & | toLower ()
char | operator[] (signed int index) const
char | operator[] (unsigned int index) const
| operator const char * () const
String & | assign (const char *value, int len=-1)
String & | assign (char value, unsigned int repeat=1)
String & | hexify (const void *data, unsigned int len, char sep=0, bool upCase=false)
String & | operator= (const String &value)
String & | operator= (const String *value)
String & | operator= (const char *value)
String & | operator= (char value)
String & | operator= (int32_t value)
String & | operator= (uint32_t value)
String & | operator= (int64_t value)
String & | operator= (uint64_t value)
String & | operator= (bool value)
String & | operator= (double value)
String & | operator+= (const char *value)
String & | operator+= (char value)
String & | operator+= (int32_t value)
String & | operator+= (uint32_t value)
String & | operator+= (int64_t value)
String & | operator+= (uint64_t value)
String & | operator+= (bool value)
String & | operator+= (double value)
bool | operator== (const char *value) const
bool | operator!= (const char *value) const
bool | operator== (const String &value) const
bool | operator!= (const String &value) const
bool | operator&= (const char *value) const
bool | operator|= (const char *value) const
String & | operator<< (const char *value)
String & | operator<< (char value)
String & | operator<< (int32_t value)
String & | operator<< (uint32_t value)
String & | operator<< (int64_t value)
String & | operator<< (uint64_t value)
String & | operator<< (bool value)
String & | operator<< (double value)
String & | operator>> (const char *skip)
String & | operator>> (char &store)
String & | operator>> (UChar &store)
String & | operator>> (int &store)
String & | operator>> (unsigned int &store)
String & | operator>> (bool &store)
String & | append (const char *value, int len)
String & | append (const char *value, const char *separator=0, bool force=false)
String & | append (const ObjList *list, const char *separator=0, bool force=false)
String & | append (const ObjList &list, const char *separator=0, bool force=false)
String & | append (char value, unsigned int len=1)
String & | append (double value, unsigned int decimals=3)
String & | insert (unsigned int pos, const char *value, int len=-1)
String & | insert (unsigned int pos, char value, unsigned int len=1)
String & | printf (const char *format,...)
String & | printf (unsigned int length, const char *format,...)
String & | printfAppend (const char *format,...)
String & | printfAppend (unsigned int length, const char *format,...)
String & | appendFixed (unsigned int fixedLength, const char *str, unsigned int len=-1, char fill=' ', int align=Left)
String & | appendFixed (unsigned int fixedLength, const String &str, char fill=' ', int align=Left)
int | find (char what, unsigned int offs=0) const
int | find (const char *what, unsigned int offs=0) const
int | rfind (char what) const
int | rfind (const char *what) const
bool | startsWith (const char *what, bool wordBreak=false, bool caseInsensitive=false) const
bool | endsWith (const char *what, bool wordBreak=false, bool caseInsensitive=false) const
bool | startSkip (const char *what, bool wordBreak=true, bool caseInsensitive=false)
String & | replaceChars (const char *what, const char *repl, bool inPlace=false, int wLen=-1, int rLen=-1, bool *chg=0)
String & | removeChars (const char *what, int wLen=-1, bool *chg=0)
String & | extractTo (const char *sep, String &store)
String & | extractTo (const char *sep, bool &store)
String & | extractTo (const char *sep, int &store, int base=0)
String & | extractTo (const char *sep, int &store, const TokenDict *tokens, int base=0)
String & | extractTo (const char *sep, double &store)
virtual bool | matches (const String &value) const
bool | matches (const Regexp &rexp)
int | matchOffset (int index=0) const
int | matchLength (int index=0) const
String | matchString (int index=0) const
String | replaceMatches (const String &templ) const
int | matchCount () const
ObjList * | split (ObjList &list, char separator, bool emptyOK=true) const
ObjList * | split (ObjList &list, const Regexp &reg, bool emptyOK=true) const
ObjList * | split (char separator, bool emptyOK=true) const
ObjList * | split (const Regexp &reg, bool emptyOK=true) const
String | msgEscape (char extraEsc=0) const
String | msgUnescape (int *errptr=0, char extraEsc=0) const
String | sqlEscape (char extraEsc=0) const
String & | uriEscapeTo (String &buf, char extraEsc=0, const char *noEsc=0) const
String | uriEscape (char extraEsc=0, const char *noEsc=0) const
String & | uriUnescapeTo (String &buf, bool setPartial=false, int *errptr=0) const
String & | uriUnescapeStr (bool setPartial=false, int *errptr=0)
String | uriUnescape (int *errptr=0, bool setPartial=true) const
Public Member Functions inherited from GenObject
| GenObject ()
virtual | ~GenObject ()
virtual bool | alive () const
virtual void | destruct ()
virtual const String & | traceId () const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (NamedCounter *counter)

## Static Public Member Functions
static const String & | empty ()
static const char * | boolText (bool value)
static int | lenUtf8 (const char *value, uint32_t maxChar=0x10ffff, bool overlong=false)
static bool | checkBOM (const char *str)
static bool | stripBOM (const char *&str)
static bool | stripBOM (char *&str)
static unsigned int | hash (const char *value, unsigned int h=0)
static String | msgEscape (const char *str, char extraEsc=0)
static String | msgUnescape (const char *str, int *errptr=0, char extraEsc=0)
static String | sqlEscape (const char *str, char extraEsc=0)
static String & | uriEscapeTo (String &buf, const char *str, char extraEsc=0, const char *noEsc=0)
static String & | uriEscapeTo (String &buf, const char *str, const char *extraEsc, const char *noEsc=0)
static String | uriEscape (const char *str, char extraEsc=0, const char *noEsc=0)
static String | uriEscape (const char *str, const char *extraEsc, const char *noEsc=0)
static String & | uriUnescapeTo (String &buf, const char *str, bool setPartial=false, int *errptr=0)
static String | uriUnescape (const char *str, int *errptr=0, bool setPartial=true)
static const String * | atom (const String *&str, const char *val)
static unsigned int | c_starts_with (const char *str, const char *what, int lenStr=-1, int lenWhat=-1, bool caseInsensitive=false)
static unsigned int | c_ends_with (const char *str, const char *what, int lenStr=-1, int lenWhat=-1, bool caseInsensitive=false)
static unsigned int | c_skip (const char *&str, const char *what, int lenStr=-1, int lenWhat=-1, bool caseInsensitive=false)
static unsigned int | c_skip_chars (const char *&str, const char *what, int len=-1, bool skipFound=true)
static char * | c_replace_chars (const char *str, const char *what, const char *repl=0, bool inPlace=false, int wLen=-1, int rLen=-1, bool *chg=0)
Static Public Member Functions inherited from GenObject
static void * | getObject (const String &name, const GenObject *obj)
static bool | getObjCounting ()
static void | setObjCounting (bool enable)
static NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()

## Protected Member Functions
virtual void | changed ()

## Detailed Description

A C-style string handling class.

A simple string handling class for C style (one byte) strings. For simplicity and read speed no copy-on-write is performed. Strings have hash capabilities and comparations are using the hash for fast inequality check.

## Constructor & Destructor Documentation

## ◆ String() [1/11]

String | ( |  | ) |

Creates a new, empty string.

Referenced by NamedList::addParam(), NamedList::addParam(), NamedList::addParam(), NamedList::addParam(), NamedList::addParam(), MimeHeaderLine::addQuotes(), UIWidget::addTableRow(), Configuration::addValue(), XPath::anyValue(), append(), append(), append(), append(), append(), append(), appendFixed(), appendFixed(), assign(), assign(), atom(), AutoGenObject::AutoGenObject(), ClientSound::build(), UIFactory::build(), MimeHeaderLine::buildHeaders(), MimeAuthLine::buildLine(), MimeHeaderLine::buildLine(), UIFactory::canBuild(), CapturedEvent::CapturedEvent(), CapturedEvent::CapturedEvent(), changed(), URI::clearData(), Configuration::clearKey(), NamedList::clearParam(), ClientAccountList::ClientAccountList(), ClientSound::ClientSound(), Compressor::Compressor(), NamedList::copyParam(), NamedList::copyParams(), NamedList::copySubParams(), UIFactory::create(), Configuration::createSection(), DataFormat::DataFormat(), DataFormat::DataFormat(), Message::decode(), decodeFlags(), decodeFlags(), MimeHeaderLine::delQuotes(), UIWidget::delTableRow(), XPath::describeError(), ClientSound::device(), Message::dispatched(), MatchingItemDump::dump(), NamedList::dump(), NamedList::dump(), XPath::dump(), MatchingItemDump::dumpItem(), MatchingItemDump::dumpValue(), empty(), Message::encode(), Message::encode(), XPath::error(), XPath::escape(), extractTo(), extractTo(), extractTo(), extractTo(), extractTo(), ClientSound::file(), ClientSound::find(), ClientAccountList::findAccount(), ClientAccountList::findAnyContact(), ClientAccountList::findContact(), ClientAccountList::findContact(), ClientAccountList::findContactByInstance(), ClientAccountList::findContactByUri(), ClientAccountList::findRoom(), ClientAccountList::findRoomByMember(), ClientAccountList::findSingleRegAccount(), XPath::findText(), Compressor::format(), NamedList::getBoolValue(), Configuration::getBoolValue(), URI::getDescription(), NamedList::getDoubleValue(), Configuration::getDoubleValue(), URI::getExtra(), URI::getHost(), NamedList::getIndex(), NamedList::getInt64Value(), Configuration::getInt64Value(), NamedList::getInt64ValueDict(), NamedList::getInt64ValueDict(), NamedList::getIntValue(), NamedList::getIntValue(), NamedList::getIntValue(), Configuration::getIntValue(), Configuration::getIntValue(), Configuration::getKey(), NamedList::getObject(), NamedString::getObject(), getObject(), Message::getObject(), MimeAuthLine::getObject(), MimeHeaderLine::getObject(), NamedList::getParam(), URI::getProtocol(), Configuration::getSection(), UIWidget::getSelect(), UIWidget::getTableRow(), UIWidget::getText(), NamedList::getUInt64Value(), URI::getUser(), NamedList::getValue(), Configuration::getValue(), hexify(), insert(), insert(), UIWidget::insertTableRow(), ClientAccountList::isLocalContact(), MatchingItemLoad::load(), MatchingItemLoad::loadXml(), MatchingItemLoad::loadXml(), NamedInt::lookup(), NamedInt::lookupName(), matches(), MatchingItemDump::MatchingItemDump(), MatchingItemLoad::MatchingItemLoad(), MatchingParams::MatchingParams(), matchString(), MimeAuthLine::MimeAuthLine(), MimeHeaderLine::MimeHeaderLine(), msgEscape(), msgEscape(), msgUnescape(), msgUnescape(), NamedString::name(), UIWidget::name(), NamedCounter::NamedCounter(), NamedInt::NamedInt(), NamedInt::NamedInt(), NamedList::NamedList(), operator!=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator+=(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), Configuration::operator=(), URI::operator=(), operator==(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), NamedList::operator[](), printf(), printf(), printfAppend(), printfAppend(), MimeHeaderLine::quote(), Compressor::readDecomp(), ClientAccountList::removeAccount(), removeChars(), replaceChars(), replaceMatches(), NamedList::replaceParams(), XPath::reset(), Message::retValue(), Message::retValue(), MessageHandler::safeNowInternal(), ClientSound::setChannel(), UIWidget::setMultipleRows(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParam(), NamedList::setParamHex(), UIWidget::setSelect(), UIWidget::setTableRow(), UIWidget::setText(), Configuration::setValue(), Configuration::setValue(), Configuration::setValue(), sqlEscape(), sqlEscape(), ClientSound::start(), ClientSound::started(), ClientSound::stop(), String(), String(), substr(), toLower(), NamedString::toString(), toString(), toUpper(), MessageHandler::trackName(), MessageHandler::trackName(), MessageHandler::trackNameOnly(), trimBlanks(), trimSpaces(), UIWidget::UIWidget(), MimeHeaderLine::unquote(), URI::URI(), uriEscape(), uriEscape(), uriEscape(), uriEscapeTo(), uriEscapeTo(), uriEscapeTo(), uriUnescape(), uriUnescape(), uriUnescapeStr(), uriUnescapeTo(), uriUnescapeTo(), Message::userObject(), Compressor::writeComp(), and Compressor::writeDecomp().

## ◆ String() [2/11]

String | ( | const char * | value,
|  | int | len = -1 )

Creates a new initialized string.

Parameters

  value | Initial value of the string
  len | Length of the data to copy, -1 for full string

## ◆ String() [3/11]

String | ( | char | value,
|  | unsigned int | repeat = 1 )
| explicit

Creates a new initialized string.

Parameters

  value | Character to fill the string
  repeat | How many copies of the character to use

## ◆ String() [4/11]

String | ( | int32_t | value | ) |
| explicit

Creates a new initialized string from a 32 bit integer.

Parameters

  value | Value to convert to string

## ◆ String() [5/11]

String | ( | uint32_t | value | ) |
| explicit

Creates a new initialized string from a 32 bit unsigned int.

Parameters

  value | Value to convert to string

## ◆ String() [6/11]

String | ( | int64_t | value | ) |
| explicit

Creates a new initialized string from a 64 bit integer.

Parameters

  value | Value to convert to string

## ◆ String() [7/11]

String | ( | uint64_t | value | ) |
| explicit

Creates a new initialized string from a 64 bit unsigned int.

Parameters

  value | Value to convert to string

## ◆ String() [8/11]

String | ( | bool | value | ) |
| explicit

Creates a new initialized string from a boolean.

Parameters

  value | Value to convert to string

## ◆ String() [9/11]

String | ( | double | value | ) |
| explicit

Creates a new initialized string from a double value.

Parameters

  value | Value to convert to string

## ◆ String() [10/11]

String | ( | const String & | value | ) |

Copy constructor.

Parameters

  value | Initial value of the string

References String().

## ◆ String() [11/11]

String | ( | const String * | value | ) |

Constructor from String pointer.

Parameters

  value | Initial value of the string

References String().

## ◆ ~String()

virtual ~String | ( |  | ) |
| virtual

Destroys the string, disposes the memory.

## Member Function Documentation

## ◆ append() [1/6]

String & append | ( | char | value,
|  | unsigned int | len = 1 )
| inline

Append buffer filled with character to current string

Parameters

  value | Character to insert. NUL character will be ignored
  len | Number of characters to append

Returns
  Reference to the String

References insert(), length(), and String().

## ◆ append() [2/6]

String & append | ( | const char * | value,
|  | const char * | separator = 0,
|  | bool | force = false )

Conditional appending with a separator

Parameters

  value | String to append
  separator | Separator to insert before the value
  force | True to allow appending empty strings

References String().

## ◆ append() [3/6]

String & append | ( | const char * | value,
|  | int | len )

Append a string to the current string

Parameters

  value | String from which to append
  len | Length of the data to copy, -1 for full string

Returns
  Reference to the String

References String().

Referenced by append(), Time::appendTo(), SliceVector< Complex >::dump(), SliceVector< Complex >::dump(), and operator+=().

## ◆ append() [4/6]

String & append | ( | const ObjList & | list,
|  | const char * | separator = 0,
|  | bool | force = false )
| inline

List members appending with a separator

Parameters

  list | Reference of ObjList whose toString() of the items will be appended
  separator | Separator to insert before each item in list
  force | True to allow appending empty strings

References append(), and String().

## ◆ append() [5/6]

String & append | ( | const ObjList * | list,
|  | const char * | separator = 0,
|  | bool | force = false )

List members appending with a separator

Parameters

  list | Pointer to ObjList whose toString() of the items will be appended
  separator | Separator to insert before each item in list
  force | True to allow appending empty strings

References String().

## ◆ append() [6/6]

String & append | ( | double | value,
|  | unsigned int | decimals = 3 )

Explicit double append

Parameters

  value | Value to append
  decimals | Number of decimals

References String().

## ◆ appendFixed() [1/2]

String & appendFixed | ( | unsigned int | fixedLength,
|  | const char * | str,
|  | unsigned int | len = -1,
|  | char | fill = ' ',
|  | int | align = Left )

Build a fixed aligned string from str and append it.

Parameters

  fixedLength | The fixed length in which the 'str' will be aligned.
  str | The string to align
  len | The number of characters to use from str.
  fill | Character to fill the empty space.
  align | The alignment mode.

References String().

Referenced by appendFixed().

## ◆ appendFixed() [2/2]

String & appendFixed | ( | unsigned int | fixedLength,
|  | const String & | str,
|  | char | fill = ' ',
|  | int | align = Left )
| inline

Build a fixed aligned string from str and append it.

Parameters

  fixedLength | The fixed length in which the 'str' will be aligned.
  str | The string to align
  fill | Character to fill the empty space.
  align | The alignment mode.

References appendFixed(), c_str(), length(), and String().

## ◆ assign() [1/2]

String & assign | ( | char | value,
|  | unsigned int | repeat = 1 )

Assigns a new value by filling with a repeated character

Parameters

  value | Character to fill the string
  repeat | How many copies of the character to use

Returns
  Reference to the String

References String().

## ◆ assign() [2/2]

String & assign | ( | const char * | value,
|  | int | len = -1 )

Assigns a new value to the string from a character block.

Parameters

  value | New value of the string
  len | Length of the data to copy, -1 for full string

Returns
  Reference to the String

References String().

## ◆ at()

char at | ( | int | index | ) | const

Extract the caracter at a given index

Parameters

  index | Index of character in string

Returns
  Character at given index or 0 if out of range

Referenced by operator[](), and operator[]().

## ◆ atom()

const String * atom | ( | const String *& | str,
|  | const char * | val )
| static

Atom string support helper

Parameters

  str | Reference to variable to hold the atom string
  val | String value to allocate to the atom

Returns
  Pointer to shared atom string

References String().

Referenced by Atom::Atom().

## ◆ boolText()

const char * boolText | ( | bool | value | ) |
| inlinestatic

A standard text representation of boolean values

Parameters

  value | Boolean value to convert

Returns
  Pointer to a text representation of the value

Referenced by NamedList::addParam(), operator+=(), operator=(), ClientContact::setLocal(), NamedList::setParam(), ClientContact::setRemote(), and ClientAccount::startup().

## ◆ c_ends_with()

unsigned int c_ends_with | ( | const char * | str,
|  | const char * | what,
|  | int | lenStr = -1,
|  | int | lenWhat = -1,
|  | bool | caseInsensitive = false )
| static

Checks if a string ends with a substring

Parameters

  str | String to search in
  what | Substring to check
  lenStr | String length, negative to detect
  lenWhat | Substring length, negative to detect
  caseInsensitive | Compare case-insensitive if set

Returns
  The length of substring if string ends with it

## ◆ c_replace_chars()

char * c_replace_chars | ( | const char * | str,
|  | const char * | what,
|  | const char * | repl = 0,
|  | bool | inPlace = false,
|  | int | wLen = -1,
|  | int | rLen = -1,
|  | bool * | chg = 0 )
| static

Replace and/or remove chars in a string Replace and remove may be done in the same function call by giving a shorter 'repl': c_replace_chars("a-(bc)","-()","_") will return 'a_bc'

Parameters

  str | String to replace in
  what | Characters to search for
  repl | Characters to replace with. Found characters are removed if there is no replacement
  inPlace | In place replace. This parameter is ignored if search and replace strings have different length
  wLen | Length of characters to search string, negative to detect. No replace is done if this parameter is 0
  rLen | Length of characters to replace with string, negative to detect. Found characters will be removed if this parameter is 0
  chg | Optional pointer to flag to be set if changes are done (not set if no changes)

Returns
  String with chars replaced/removed. May be different from the given string if changed. The caller is owning the new string May return NULL if string is empty after replace or memory allocation failure

## ◆ c_skip()

unsigned int c_skip | ( | const char *& | str,
|  | const char * | what,
|  | int | lenStr = -1,
|  | int | lenWhat = -1,
|  | bool | caseInsensitive = false )
| inlinestatic

Skip substring in string if matches

Parameters

  str | String to search in. Will be advanced by skipped chars
  what | Substring to match
  lenStr | String length, negative to detect
  lenWhat | Substring length, negative to detect
  caseInsensitive | Compare case-insensitive if set

Returns
  The number of skipped chars (length of substring), 0 if not matched

References c_starts_with().

## ◆ c_skip_chars()

unsigned int c_skip_chars | ( | const char *& | str,
|  | const char * | what,
|  | int | len = -1,
|  | bool | skipFound = true )
| static

Skip chars in string

Parameters

  str | String to skip in. Will be advanced by skipped chars
  what | Characters to match
  len | Optional maximum length to search in string, negative to use the whole string
  skipFound | Set it to false to skip while NOT match (until first match character)

Returns
  Number of skipped chars

## ◆ c_starts_with()

unsigned int c_starts_with | ( | const char * | str,
|  | const char * | what,
|  | int | lenStr = -1,
|  | int | lenWhat = -1,
|  | bool | caseInsensitive = false )
| static

Checks if a string starts with a substring

Parameters

  str | String to search in
  what | Substring to check
  lenStr | String length, negative to detect
  lenWhat | Substring length, negative to detect
  caseInsensitive | Compare case-insensitive if set

Returns
  The length of substring if string starts with it

Referenced by c_skip().

## ◆ c_str()

const char * c_str | ( |  | ) | const
| inline

Get the value of the stored string.

Returns
  The stored C string which may be NULL.

Referenced by DataBlock::append(), appendFixed(), checkBOM(), DataFormat::DataFormat(), XPath::describeError(), Hasher::hmac(), Hasher::hmacStart(), msgEscape(), msgUnescape(), operator!=(), operator=(), operator=(), operator==(), sqlEscape(), stripBOM(), XmlSaxParser::unEscape(), SliceVector< Complex >::unHexify(), Hasher::update(), uriEscape(), uriEscapeTo(), uriUnescape(), uriUnescapeStr(), uriUnescapeTo(), Compressor::writeComp(), Stream::writeData(), and Compressor::writeDecomp().

## ◆ changed()

virtual void changed | ( |  | ) |
| protectedvirtual

Called whenever the value changed (except in constructors).

Reimplemented in NamedPointer, Regexp, DataFormat, XPath, and URI.

References String().

## ◆ checkBOM() [1/2]

bool checkBOM | ( |  | ) | const
| inline

Check if this string starts with UTF-8 Byte Order Mark

Returns
  True if the string starts with UTF-8 BOM

References c_str(), and checkBOM().

## ◆ checkBOM() [2/2]

bool checkBOM | ( | const char * | str | ) |
| inlinestatic

Check if a string starts with UTF-8 Byte Order Mark

Parameters

  str | String to check for BOM

Returns
  True if the string starts with UTF-8 BOM

Referenced by checkBOM(), stripBOM(), stripBOM(), and stripBOM().

## ◆ clear()

void clear | ( |  | ) |

Clear the string and free the memory

## ◆ decodeFlags() [1/2]

String & decodeFlags | ( | uint64_t | flags,
|  | const TokenDict64 * | tokens,
|  | bool | unknownflag = true )

Decode flags from dictionary values

Parameters

  flags | The flags
  tokens | The dictionary containing the flags
  unknownflag | True (default) to add unknown flags

Returns
  Decoded flags

References String().

## ◆ decodeFlags() [2/2]

String & decodeFlags | ( | unsigned int | flags,
|  | const TokenDict * | tokens,
|  | bool | unknownflag = true )

Decodoe flags from dictionary values

Parameters

  flags | The flags
  tokens | The dictionary containing the flags
  unknownflag | True (default) to add unknown flags

Returns
  Decoded flags

References String().

Referenced by NamedList::addParam(), and NamedList::addParam().

## ◆ empty()

const String & empty | ( |  | ) |
| static

A static null String

Returns
  Reference to a static empty String

References String().

Referenced by ClientContact::accountName(), Window::addOption(), SocketAddr::appendAddr(), SocketAddr::appendTo(), SocketAddr::appendTo(), ClientContact::buildContactInstanceId(), ClientContact::buildIdHash(), ClientContact::buildInstanceId(), ClientLogic::callStart(), DefaultLogic::callStart(), ClientLogic::cdrRemoteParty(), CallEndpoint::clearEndpoint(), ClientChannel::ClientChannel(), SharedVars::copy(), Client::createDefaultLogic(), Client::createDialog(), Window::createDialog(), Client::createWindowSafe(), Client::decodeFlags(), MucRoom::destroyChatWindow(), MatchingItemBase::dump(), MatchingItemDump::dump(), MatchingItemDump::dumpItem(), MatchingItemBase::dumpValue(), MatchingItemDump::dumpValue(), Client::emitDigit(), Client::emitDigits(), Client::generateGuid(), ClientContact::getContactSection(), Client::getOptions(), DefaultLogic::joinRoom(), NamedInt::lookupName(), DefaultLogic::notifyGenericError(), Client::removeLastNameInPath(), ClientContact::removeShared(), XmlDocument::saveFile(), Client::select(), ClientLogic::select(), DefaultLogic::select(), ClientContact::sendChat(), ClientDriver::setActive(), XmlElement::setAttributes(), ClientDriver::setAudioTransfer(), ClientContact::setChatInput(), MucRoom::setChatInput(), ClientChannel::setConference(), Client::setMultipleRows(), UIWidget::setMultipleRows(), Window::setMultipleRows(), ClientResource::setStatusText(), ClientChannel::setTransfer(), XmlElement::setXmlns(), XmlCData::toString(), XmlComment::toString(), XmlDoctype::toString(), XmlDocument::toString(), XmlElement::toString(), XmlFragment::toString(), XmlText::toString(), Engine::trackParam(), and XmlDocument::write().

## ◆ encodeFlags() [1/2]

unsigned int encodeFlags | ( | const TokenDict * | tokens | ) | const

Encode flags from dictionary values

Parameters

  tokens | The dictionary containing the flags

Returns
  Encoded flags

## ◆ encodeFlags() [2/2]

uint64_t encodeFlags | ( | const TokenDict64 * | tokens | ) | const

Encode flags from dictionary values

Parameters

  tokens | The dictionary containing the flags

Returns
  Encoded flags

## ◆ endsWith()

bool endsWith | ( | const char * | what,
|  | bool | wordBreak = false,
|  | bool | caseInsensitive = false ) const

Checks if the string ends with a substring

Parameters

  what | Substring to search for
  wordBreak | Check if a word boundary precedes the substring
  caseInsensitive | Compare case-insensitive if set

Returns
  True if the substring occurs at the end of the string

## ◆ extractTo() [1/5]

String & extractTo | ( | const char * | sep,
|  | bool & | store )

Extract a boolean substring up to a separator

Parameters

  sep | Separator string to match after extracted fragment
  store | Reference to boolean variable to store extracted fragment

Returns
  Reference to this string

References String().

## ◆ extractTo() [2/5]

String & extractTo | ( | const char * | sep,
|  | double & | store )

Extract a double value substring up to a separator

Parameters

  sep | Separator string to match after extracted fragment
  store | Reference to double variable to store extracted fragment

Returns
  Reference to this string

References String().

## ◆ extractTo() [3/5]

String & extractTo | ( | const char * | sep,
|  | int & | store,
|  | const TokenDict * | tokens,
|  | int | base = 0 )

Extract an integer or token value substring up to a separator

Parameters

  sep | Separator string to match after extracted fragment
  store | Reference to integer variable to store extracted fragment
  tokens | Pointer to an array of tokens to lookup first
  base | Numeration base, 0 to autodetect

Returns
  Reference to this string

References String().

## ◆ extractTo() [4/5]

String & extractTo | ( | const char * | sep,
|  | int & | store,
|  | int | base = 0 )

Extract an integer value substring up to a separator

Parameters

  sep | Separator string to match after extracted fragment
  store | Reference to integer variable to store extracted fragment
  base | Numeration base, 0 to autodetect

Returns
  Reference to this string

References String().

## ◆ extractTo() [5/5]

String & extractTo | ( | const char * | sep,
|  | String & | store )

Extract a substring up to a separator

Parameters

  sep | Separator string to match after extracted fragment
  store | Reference to String variable to store extracted fragment

Returns
  Reference to this string

References String().

## ◆ find() [1/2]

int find | ( | char | what,
|  | unsigned int | offs = 0 ) const

Locate the first instance of a character in the string

Parameters

  what | Character to search for
  offs | Offset in string to start searching from

Returns
  Offset of character or -1 if not found

Referenced by ClientContact::splitContactId().

## ◆ find() [2/2]

int find | ( | const char * | what,
|  | unsigned int | offs = 0 ) const

Locate the first instance of a substring in the string

Parameters

  what | Substring to search for
  offs | Offset in string to start searching from

Returns
  Offset of substring or -1 if not found

## ◆ fixUtf8()

int fixUtf8 | ( | const char * | replace = 0,
|  | uint32_t | maxChar = 0x10ffff,
|  | bool | overlong = false )

Fix an UTF-8 encoded string by replacing invalid sequences

Parameters

  replace | String to replace invalid sequences, use U+FFFD if null
  maxChar | Maximum accepted Unicode character code
  overlong | Accept overlong UTF-8 sequences (dangerous!)

Returns
  Count of invalid UTF-8 sequences that were replaced

## ◆ getObject()

virtual void * getObject | ( | const String & | name | ) | const
| virtual

Get a pointer to a derived class given that class name

Parameters

  name | Name of the class we are asking for

Returns
  Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

Reimplemented in NamedList, NamedPointer, NamedString, Message, MimeAuthLine, and MimeHeaderLine.

References String().

## ◆ hash() [1/2]

unsigned int hash | ( |  | ) | const
| inline

Get the hash of the contained string.

Returns
  The hash of the string.

References hash().

Referenced by HashList::getHashList(), hash(), operator!=(), and operator==().

## ◆ hash() [2/2]

unsigned int hash | ( | const char * | value,
|  | unsigned int | h = 0 )
| static

Get the hash of an arbitrary string.

Parameters

  value | C string to hash
  h | Old hash value for incremental hashing

Returns
  The hash of the string.

## ◆ hexify()

String & hexify | ( | const void * | data,
|  | unsigned int | len,
|  | char | sep = 0,
|  | bool | upCase = false )

Build a hexadecimal representation of a buffer of data

Parameters

  data | Pointer to data to dump
  len | Length of the data buffer
  sep | Separator character to use between octets
  upCase | Set to true to use upper case characters in hexa

Returns
  Reference to the String

References String().

Referenced by NamedList::addParamHex(), and SliceVector< Complex >::hexify().

## ◆ insert() [1/2]

String & insert | ( | unsigned int | pos,
|  | char | value,
|  | unsigned int | len = 1 )

Insert a character into current string

Parameters

  pos | Position to insert. Negative or greater than curent length: append
  value | Character to insert. NUL character will be ignored
  len | Number of characters to insert

Returns
  Reference to the String

References String().

## ◆ insert() [2/2]

String & insert | ( | unsigned int | pos,
|  | const char * | value,
|  | int | len = -1 )

Insert a string into current string

Parameters

  pos | Position to insert. String will be appended if position is greater than curent length
  value | String to insert
  len | Length of the data to copy, -1 for full string

Returns
  Reference to the String

References String().

Referenced by append().

## ◆ isBoolean()

bool isBoolean | ( |  | ) | const

Check if the string can be converted to a boolean value.

Returns
  True if the string is a valid boolean.

## ◆ length()

unsigned int length | ( |  | ) | const
| inline

Get the length of the stored string.

Returns
  The length of the stored string, zero for NULL.

Referenced by DataBlock::append(), append(), appendFixed(), Socket::bind(), SliceVector< Complex >::dump(), Hasher::hmac(), Hasher::hmacStart(), printf(), printfAppend(), MessageHandler::trackName(), XmlSaxParser::unEscape(), SliceVector< Complex >::unHexify(), Hasher::update(), Compressor::writeComp(), Stream::writeData(), and Compressor::writeDecomp().

## ◆ lenUtf8() [1/2]

int lenUtf8 | ( | const char * | value,
|  | uint32_t | maxChar = 0x10ffff,
|  | bool | overlong = false )
| static

Get the number of characters in a string assuming UTF-8 encoding

Parameters

  value | C string to compute Unicode length
  maxChar | Maximum accepted Unicode character code
  overlong | Accept overlong UTF-8 sequences (dangerous!)

Returns
  Count of Unicode characters, -1 if not valid UTF-8

Referenced by lenUtf8().

## ◆ lenUtf8() [2/2]

int lenUtf8 | ( | uint32_t | maxChar = 0x10ffff,
|  | bool | overlong = false ) const
| inline

Get the number of characters in the string assuming UTF-8 encoding

Parameters

  maxChar | Maximum accepted Unicode character code
  overlong | Accept overlong UTF-8 sequences (dangerous!)

Returns
  Count of Unicode characters, -1 if not valid UTF-8

References lenUtf8().

## ◆ matchCount()

int matchCount | ( |  | ) | const

Get the total number of submatches from the last match, 0 if no match

Returns
  Number of matching subexpressions

## ◆ matches() [1/2]

bool matches | ( | const Regexp & | rexp | ) |

Checks if matches a regular expression and fill the match substrings

Parameters

  rexp | Regular expression to check for match

Returns
  True if matches, false otherwise

## ◆ matches() [2/2]

virtual bool matches | ( | const String & | value | ) | const
| inlinevirtual

Checks if matches another string

Parameters

  value | String to check for match

Returns
  True if matches, false otherwise

Reimplemented in Regexp.

References operator==(), and String().

## ◆ matchLength()

int matchLength | ( | int | index = 0 | ) | const

Get the length of the last match

Parameters

  index | Index of the submatch to return, 0 for full match

Returns
  Length of the last match, 0 if no match or out of range

Referenced by matchString().

## ◆ matchOffset()

int matchOffset | ( | int | index = 0 | ) | const

Get the offset of the last match

Parameters

  index | Index of the submatch to return, 0 for full match

Returns
  Offset of the last match, -1 if no match or not in range

Referenced by matchString().

## ◆ matchString()

String matchString | ( | int | index = 0 | ) | const
| inline

Get a copy of a matched (sub)string

Parameters

  index | Index of the submatch to return, 0 for full match

Returns
  Copy of the matched substring

References matchLength(), matchOffset(), String(), and substr().

## ◆ msgEscape() [1/2]

String msgEscape | ( | char | extraEsc = 0 | ) | const
| inline

Create an escaped string suitable for use in messages

Parameters

  extraEsc | Character to escape other than the default ones

Returns
  The string with special characters escaped

References c_str(), msgEscape(), and String().

## ◆ msgEscape() [2/2]

String msgEscape | ( | const char * | str,
|  | char | extraEsc = 0 )
| static

Create an escaped string suitable for use in messages

Parameters

  str | String to convert to escaped format
  extraEsc | Character to escape other than the default ones

Returns
  The string with special characters escaped

References String().

Referenced by msgEscape().

## ◆ msgUnescape() [1/2]

String msgUnescape | ( | const char * | str,
|  | int * | errptr = 0,
|  | char | extraEsc = 0 )
| static

Decode an escaped string back to its raw form

Parameters

  str | String to convert to unescaped format
  errptr | Pointer to an integer to receive the place of 1st error
  extraEsc | Character to unescape other than the default ones

Returns
  The string with special characters unescaped

References String().

Referenced by msgUnescape().

## ◆ msgUnescape() [2/2]

String msgUnescape | ( | int * | errptr = 0,
|  | char | extraEsc = 0 ) const
| inline

Decode an escaped string back to its raw form

Parameters

  errptr | Pointer to an integer to receive the place of 1st error
  extraEsc | Character to unescape other than the default ones

Returns
  The string with special characters unescaped

References c_str(), msgUnescape(), and String().

## ◆ null()

bool null | ( |  | ) | const
| inline

Checks if the string holds a NULL pointer.

Returns
  True if the string holds NULL, false otherwise.

## ◆ operator const char *()

operator const char * | ( |  | ) | const
| inline

Conversion to "const char *" operator.

Returns
  Pointer to the internally stored string

## ◆ operator!=() [1/2]

bool operator!= | ( | const char * | value | ) | const

Inequality operator.

Referenced by operator!=().

## ◆ operator!=() [2/2]

bool operator!= | ( | const String & | value | ) | const
| inline

Fast inequality operator.

References c_str(), hash(), operator!=(), and String().

## ◆ operator&=()

bool operator&= | ( | const char * | value | ) | const

Case-insensitive equality operator.

## ◆ operator+=() [1/8]

String & operator+= | ( | bool | value | ) |
| inline

Appending operator for booleans.

Parameters

  value | Value to append to the string

References boolText(), operator+=(), and String().

## ◆ operator+=() [2/8]

String & operator+= | ( | char | value | ) |

Appending operator for single characters.

Parameters

  value | Value to append to the string

References String().

## ◆ operator+=() [3/8]

String & operator+= | ( | const char * | value | ) |
| inline

Appending operator for strings.

Parameters

  value | Value to assign to the string

See also
  TelEngine::strcat

References append(), and String().

Referenced by operator+=(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), and operator<<().

## ◆ operator+=() [4/8]

String & operator+= | ( | double | value | ) |

Appending operator for double.

Parameters

  value | Value to append to the string

References String().

## ◆ operator+=() [5/8]

String & operator+= | ( | int32_t | value | ) |

Appending operator for 32 bit integers.

Parameters

  value | Value to append to the string

References String().

## ◆ operator+=() [6/8]

String & operator+= | ( | int64_t | value | ) |

Appending operator for 64 bit integers.

Parameters

  value | Value to append to the string

References String().

## ◆ operator+=() [7/8]

String & operator+= | ( | uint32_t | value | ) |

Appending operator for 32 bit unsigned integers.

Parameters

  value | Value to append to the string

References String().

## ◆ operator+=() [8/8]

String & operator+= | ( | uint64_t | value | ) |

Appending operator for 64 bit unsigned integers.

Parameters

  value | Value to append to the string

References String().

## ◆ operator<<() [1/8]

String & operator<< | ( | bool | value | ) |
| inline

Stream style appending operator for booleans

References operator+=(), and String().

## ◆ operator<<() [2/8]

String & operator<< | ( | char | value | ) |
| inline

Stream style appending operator for single characters

References operator+=(), and String().

## ◆ operator<<() [3/8]

String & operator<< | ( | const char * | value | ) |
| inline

Stream style appending operator for C strings

References operator+=(), and String().

## ◆ operator<<() [4/8]

String & operator<< | ( | double | value | ) |
| inline

Stream style appending operator for double

References operator+=(), and String().

## ◆ operator<<() [5/8]

String & operator<< | ( | int32_t | value | ) |
| inline

Stream style appending operator for 32 bit integers

References operator+=(), and String().

## ◆ operator<<() [6/8]

String & operator<< | ( | int64_t | value | ) |
| inline

Stream style appending operator for 64 bit integers

References operator+=(), and String().

## ◆ operator<<() [7/8]

String & operator<< | ( | uint32_t | value | ) |
| inline

Stream style appending operator for 32 bit unsigned integers

References operator+=(), and String().

## ◆ operator<<() [8/8]

String & operator<< | ( | uint64_t | value | ) |
| inline

Stream style appending operator for 64 bit unsigned integers

References operator+=(), and String().

## ◆ operator=() [1/10]

String & operator= | ( | bool | value | ) |
| inline

Assignment operator for booleans.

Parameters

  value | Value to assign to the string

References boolText(), operator=(), and String().

## ◆ operator=() [2/10]

String & operator= | ( | char | value | ) |

Assignment operator for single characters.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator=() [3/10]

String & operator= | ( | const char * | value | ) |

Assignment from char* operator.

Parameters

  value | Value to assign to the string

See also
  TelEngine::strcpy

References String().

## ◆ operator=() [4/10]

String & operator= | ( | const String & | value | ) |
| inline

Assignment operator.

Parameters

  value | Value to assign to the string

References c_str(), operator=(), and String().

Referenced by NamedString::operator=(), Regexp::operator=(), operator=(), operator=(), operator=(), Configuration::operator=(), Message::operator=(), URI::operator=(), URI::operator=(), and URI::operator=().

## ◆ operator=() [5/10]

String & operator= | ( | const String * | value | ) |
| inline

Assignment from String* operator.

Parameters

  value | Value to assign to the string

See also
  TelEngine::strcpy

References c_str(), operator=(), and String().

## ◆ operator=() [6/10]

String & operator= | ( | double | value | ) |

Assignment operator for double.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator=() [7/10]

String & operator= | ( | int32_t | value | ) |

Assignment operator for 32 bit integers.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator=() [8/10]

String & operator= | ( | int64_t | value | ) |

Assignment operator for 64 bit integers.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator=() [9/10]

String & operator= | ( | uint32_t | value | ) |

Assignment operator for 32 bit unsigned integers.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator=() [10/10]

String & operator= | ( | uint64_t | value | ) |

Assignment operator for 64 bit unsigned integers.

Parameters

  value | Value to assign to the string

References String().

## ◆ operator==() [1/2]

bool operator== | ( | const char * | value | ) | const

Equality operator.

Referenced by matches(), and operator==().

## ◆ operator==() [2/2]

bool operator== | ( | const String & | value | ) | const
| inline

Fast equality operator.

References c_str(), hash(), operator==(), and String().

## ◆ operator>>() [1/6]

String & operator>> | ( | bool & | store | ) |

Stream style extraction operator for booleans

References String().

## ◆ operator>>() [2/6]

String & operator>> | ( | char & | store | ) |

Stream style extraction operator for single characters

References String().

## ◆ operator>>() [3/6]

String & operator>> | ( | const char * | skip | ) |

Stream style substring skipping operator. It eats all characters up to and including the skip string

References String().

## ◆ operator>>() [4/6]

String & operator>> | ( | int & | store | ) |

Stream style extraction operator for integers

References String().

## ◆ operator>>() [5/6]

String & operator>> | ( | UChar & | store | ) |

Stream style extraction operator for single Unicode characters

References String().

## ◆ operator>>() [6/6]

String & operator>> | ( | unsigned int & | store | ) |

Stream style extraction operator for unsigned integers

References String().

## ◆ operator[]() [1/2]

char operator[] | ( | signed int | index | ) | const
| inline

Indexing operator with signed int

Parameters

  index | Index of character in string

Returns
  Character at given index or 0 if out of range

References at().

## ◆ operator[]() [2/2]

char operator[] | ( | unsigned int | index | ) | const
| inline

Indexing operator with unsigned int

Parameters

  index | Index of character in string

Returns
  Character at given index or 0 if out of range

References at().

## ◆ operator|=()

bool operator|= | ( | const char * | value | ) | const

Case-insensitive inequality operator.

## ◆ printf() [1/2]

String & printf | ( | const char * | format,
|  |  | ... )

Build a String in a printf style.

Parameters

  format | The output format. NOTE: The length of the resulting string will be at most 128 + length of format

References String().

## ◆ printf() [2/2]

String & printf | ( | unsigned int | length,
|  | const char * | format,
|  |  | ... )

Build a String in a printf style.

Parameters

  length | maximum length of the resulting string
  format | The output format.

References length(), and String().

## ◆ printfAppend() [1/2]

String & printfAppend | ( | const char * | format,
|  |  | ... )

Append a String in a printf style.

Parameters

  format | The output format. NOTE: The length of added string will be at most 128 + length of format

References String().

## ◆ printfAppend() [2/2]

String & printfAppend | ( | unsigned int | length,
|  | const char * | format,
|  |  | ... )

Append a String in a printf style.

Parameters

  length | maximum length of the resulting string
  format | The output format.

References length(), and String().

## ◆ removeChars()

String & removeChars | ( | const char * | what,
|  | int | wLen = -1,
|  | bool * | chg = 0 )
| inline

Remove chars in string

Parameters

  what | Characters to remove
  wLen | Length of characters to search string, negative to detect. No remove is done if this parameter is 0
  chg | Optional pointer to flag to be set if changes are done (not set if no changes)

Returns
  Reference to this string

References replaceChars(), and String().

## ◆ replaceChars()

String & replaceChars | ( | const char * | what,
|  | const char * | repl,
|  | bool | inPlace = false,
|  | int | wLen = -1,
|  | int | rLen = -1,
|  | bool * | chg = 0 )

Replace and/or remove chars in string Replace and remove may be done in the same function call by giving a shorter 'repl': s="a-(bc)"; s.replaceChars("-()","_") will result in 'a_bc'

Parameters

  what | Characters to search for
  repl | Characters to replace with. Found characters are removed if there is no replacement
  inPlace | In place replace. This parameter is ignored if search and replace strings have different length
  wLen | Length of characters to search string, negative to detect. No replace is done if this parameter is 0
  rLen | Length of characters to replace with string, negative to detect. Found characters will be removed if this parameter is 0
  chg | Optional pointer to flag to be set if changes are done (not set if no changes)

Returns
  Reference to this string

References String().

Referenced by removeChars().

## ◆ replaceMatches()

String replaceMatches | ( | const String & | templ | ) | const

Create a string by replacing matched strings in a template

Parameters

  templ | Template of the string to generate

Returns
  Copy of template with "\0" - "\9" replaced with submatches

References String().

## ◆ rfind() [1/2]

int rfind | ( | char | what | ) | const

Locate the last instance of a character in the string

Parameters

  what | Character to search for

Returns
  Offset of character or -1 if not found

## ◆ rfind() [2/2]

int rfind | ( | const char * | what | ) | const

Locate the last instance of a substring in the string

Parameters

  what | Substring to search for

Returns
  Offset of substring or -1 if not found

## ◆ safe() [1/2]

const char * safe | ( |  | ) | const
| inline

Get a valid non-NULL C string.

Returns
  The stored C string or a static "".

Referenced by Regexp::matches().

## ◆ safe() [2/2]

const char * safe | ( | const char * | defStr | ) | const
| inline

Get a valid non-NULL C string with a provided default.

Parameters

  defStr | Default C string to return if stored is NULL

Returns
  The stored C string, the default or a static "".

## ◆ split() [1/4]

ObjList * split | ( | char | separator,
|  | bool | emptyOK = true ) const
| inline

Splits the string at a delimiter character

Parameters

  separator | Character where to split the string
  emptyOK | True if empty strings should be inserted in list

Returns
  A newly allocated list of strings, must be deleted after use

References split().

## ◆ split() [2/4]

ObjList * split | ( | const Regexp & | reg,
|  | bool | emptyOK = true ) const
| inline

Splits the string at Regexp delimiter

Parameters

  reg | Regexp describing the delimiter
  emptyOK | True if empty strings should be inserted in list

Returns
  A newly allocated list of strings, must be deleted after use

References split().

## ◆ split() [3/4]

ObjList * split | ( | ObjList & | list,
|  | char | separator,
|  | bool | emptyOK = true ) const

Splits the string at a delimiter character

Parameters

  list | Destination list
  separator | Character where to split the string
  emptyOK | True if empty strings should be inserted in list

Returns
  Pointer to last added item, NULL if no item was added

Referenced by split(), and split().

## ◆ split() [4/4]

ObjList * split | ( | ObjList & | list,
|  | const Regexp & | reg,
|  | bool | emptyOK = true ) const

Splits the string at Regexp delimiter

Parameters

  list | Destination list
  reg | Regexp describing the delimiter
  emptyOK | True if empty strings should be inserted in list

Returns
  Pointer to last added item, NULL if no item was added

## ◆ sqlEscape() [1/2]

String sqlEscape | ( | char | extraEsc = 0 | ) | const
| inline

Create an escaped string suitable for use in SQL queries

Parameters

  extraEsc | Character to escape other than the default ones

Returns
  The string with special characters escaped

References c_str(), sqlEscape(), and String().

## ◆ sqlEscape() [2/2]

String sqlEscape | ( | const char * | str,
|  | char | extraEsc = 0 )
| static

Create an escaped string suitable for use in SQL queries

Parameters

  str | String to convert to escaped format
  extraEsc | Character to escape other than the default ones

Returns
  The string with special characters escaped

References String().

Referenced by sqlEscape().

## ◆ startSkip()

bool startSkip | ( | const char * | what,
|  | bool | wordBreak = true,
|  | bool | caseInsensitive = false )

Checks if the string starts with a substring and removes it

Parameters

  what | Substring to search for
  wordBreak | Check if a word boundary follows the substring; this parameter defaults to True because the intended use of this method is to separate commands from their parameters
  caseInsensitive | Compare case-insensitive if set

Returns
  True if the substring occurs at the beginning of the string and also removes the substring; if wordBreak is True any word breaking characters are also removed

Referenced by ClientContact::getContactSection().

## ◆ startsWith()

bool startsWith | ( | const char * | what,
|  | bool | wordBreak = false,
|  | bool | caseInsensitive = false ) const

Checks if the string starts with a substring

Parameters

  what | Substring to search for
  wordBreak | Check if a word boundary follows the substring
  caseInsensitive | Compare case-insensitive if set

Returns
  True if the substring occurs at the beginning of the string

Referenced by XmlElement::isXmlns().

## ◆ stripBOM() [1/3]

bool stripBOM | ( |  | ) |
| inline

Strip an UTF-8 Byte Order Mark from the start of this string

Returns
  True if the string started with UTF-8 BOM

References c_str(), and checkBOM().

## ◆ stripBOM() [2/3]

bool stripBOM | ( | char *& | str | ) |
| inlinestatic

Advance a string past an UTF-8 Byte Order Mark

Parameters

  str | String to check for and strip BOM

Returns
  True if the string started with UTF-8 BOM

References checkBOM().

## ◆ stripBOM() [3/3]

bool stripBOM | ( | const char *& | str | ) |
| inlinestatic

Advance a const string past an UTF-8 Byte Order Mark

Parameters

  str | String to check for and strip BOM

Returns
  True if the string started with UTF-8 BOM

References checkBOM().

## ◆ substr()

String substr | ( | int | offs,
|  | int | len = -1 ) const

Substring extraction

Parameters

  offs | Offset of the substring, negative to count from end
  len | Length of the substring, -1 for everything possible

Returns
  A copy of the requested substring

References String().

Referenced by matchString(), and ClientContact::splitContactId().

## ◆ toBoolean()

bool toBoolean | ( | bool | defvalue = false | ) | const

Convert the string to a boolean value.

Parameters

  defvalue | Default to return if the string is not a bool

Returns
  The boolean interpretation or defvalue.

## ◆ toDouble()

double toDouble | ( | double | defvalue = 0.0 | ) | const

Convert the string to a floating point value.

Parameters

  defvalue | Default to return if the string is not a number

Returns
  The floating-point interpretation or defvalue.

## ◆ toInt64()

int64_t toInt64 | ( | int64_t | defvalue = 0,
|  | int | base = 0,
|  | int64_t | minvalue = LLONG_MIN,
|  | int64_t | maxvalue = LLONG_MAX,
|  | bool | clamp = true ) const

Convert the string to an 64 bit integer value.

Parameters

  defvalue | Default to return if the string is not a number
  base | Numeration base, 0 to autodetect
  minvalue | Minimum value allowed
  maxvalue | Maximum value allowed
  clamp | Control the out of bound values: true to adjust to the nearest bound, false to return the default value

Returns
  The 64 bit integer interpretation or defvalue.

## ◆ toInt64Dict() [1/2]

int64_t toInt64Dict | ( | const TokenDict64 * | tokens,
|  | int64_t | defvalue = 0,
|  | int | base = 0 ) const

Convert the string to an 64bit integer value looking up first a token table.

Parameters

  tokens | Pointer to an array of tokens to lookup first
  defvalue | Default to return if the string is not a token or number
  base | Numeration base, 0 to autodetect

Returns
  The integer interpretation or defvalue.

## ◆ toInt64Dict() [2/2]

int64_t toInt64Dict | ( | const TokenDictStr64 * | tokens,
|  | int64_t | defvalue = 0,
|  | int | base = 0 ) const

Convert the string to an 64bit integer value looking up first a token table.

Parameters

  tokens | Pointer to an array of String tokens to lookup first
  defvalue | Default to return if the string is not a token or number
  base | Numeration base, 0 to autodetect

Returns
  The integer interpretation or defvalue.

## ◆ toInteger() [1/3]

int toInteger | ( | const TokenDict * | tokens,
|  | int | defvalue = 0,
|  | int | base = 0 ) const

Convert the string to an integer value looking up first a token table.

Parameters

  tokens | Pointer to an array of tokens to lookup first
  defvalue | Default to return if the string is not a token or number
  base | Numeration base, 0 to autodetect

Returns
  The integer interpretation or defvalue.

## ◆ toInteger() [2/3]

int toInteger | ( | const TokenDictStr * | tokens,
|  | int | defvalue = 0,
|  | int | base = 0 ) const

Convert the string to an integer value looking up first a token table.

Parameters

  tokens | Pointer to an array of String tokens to lookup first
  defvalue | Default to return if the string is not a token or number
  base | Numeration base, 0 to autodetect

Returns
  The integer interpretation or defvalue.

## ◆ toInteger() [3/3]

int toInteger | ( | int | defvalue = 0,
|  | int | base = 0,
|  | int | minvalue = INT_MIN,
|  | int | maxvalue = INT_MAX,
|  | bool | clamp = true ) const

Convert the string to an integer value.

Parameters

  defvalue | Default to return if the string is not a number
  base | Numeration base, 0 to autodetect
  minvalue | Minimum value allowed
  maxvalue | Maximum value allowed
  clamp | Control the out of bound values: true to adjust to the nearest bound, false to return the default value

Returns
  The integer interpretation or defvalue.

## ◆ toLong()

long int toLong | ( | long int | defvalue = 0,
|  | int | base = 0,
|  | long int | minvalue = LONG_MIN,
|  | long int | maxvalue = LONG_MAX,
|  | bool | clamp = true ) const

Convert the string to an long integer value.

Parameters

  defvalue | Default to return if the string is not a number
  base | Numeration base, 0 to autodetect
  minvalue | Minimum value allowed
  maxvalue | Maximum value allowed
  clamp | Control the out of bound values: true to adjust to the nearest bound, false to return the default value

Returns
  The long integer interpretation or defvalue.

## ◆ toLower()

String & toLower | ( |  | ) |

Turn the string to an all-lowercase string

Returns
  A reference to this String

References String().

Referenced by ClientContact::buildContactId().

## ◆ toString()

virtual const String & toString | ( |  | ) | const
| virtual

Override GenObject's method to return this String

Returns
  A reference to this String

Reimplemented from GenObject.

Reimplemented in NamedString.

References String().

Referenced by ClientContact::accountName(), Module::itemComplete(), and UIWidget::name().

## ◆ toUInt64()

uint64_t toUInt64 | ( | uint64_t | defvalue = 0,
|  | int | base = 0,
|  | uint64_t | minvalue = 0,
|  | uint64_t | maxvalue = ULLONG_MAX,
|  | bool | clamp = true ) const

Convert the string to an unsigned 64 bit integer value.

Parameters

  defvalue | Default to return if the string is not a number
  base | Numeration base, 0 to autodetect
  minvalue | Minimum value allowed
  maxvalue | Maximum value allowed
  clamp | Control the out of bound values: true to adjust to the nearest bound, false to return the default value

Returns
  The unsigned 64 bit integer interpretation or defvalue.

## ◆ toUpper()

String & toUpper | ( |  | ) |

Turn the string to an all-uppercase string

Returns
  A reference to this String

References String().

## ◆ trimBlanks()

String & trimBlanks | ( |  | ) |

Strip off leading and trailing blank characters

References String().

## ◆ trimSpaces()

String & trimSpaces | ( |  | ) |

Strip off leading and trailing whitespace characters (blank, tabs, form-feed, newlines)

References String().

## ◆ uriEscape() [1/3]

String uriEscape | ( | char | extraEsc = 0,
|  | const char * | noEsc = 0 ) const
| inline

Create an escaped string suitable for use in URI

Parameters

  extraEsc | Character to escape other than the default ones
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  The string with special characters escaped

References c_str(), String(), and uriEscape().

## ◆ uriEscape() [2/3]

String uriEscape | ( | const char * | str,
|  | char | extraEsc = 0,
|  | const char * | noEsc = 0 )
| inlinestatic

Create an escaped string suitable for use in URIs

Parameters

  str | String to convert to escaped format
  extraEsc | Character to escape other than the default ones
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  The string with special characters escaped

References String(), and uriEscapeTo().

Referenced by ClientContact::buildContactId(), ClientContact::buildContactInstanceId(), and uriEscape().

## ◆ uriEscape() [3/3]

String uriEscape | ( | const char * | str,
|  | const char * | extraEsc,
|  | const char * | noEsc = 0 )
| inlinestatic

Create an escaped string suitable for use in URIs

Parameters

  str | String to convert to escaped format
  extraEsc | Pointer to string of characters to escape other than the defaults
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  The string with special characters escaped

References String(), and uriEscapeTo().

## ◆ uriEscapeTo() [1/3]

String & uriEscapeTo | ( | String & | buf,
|  | char | extraEsc = 0,
|  | const char * | noEsc = 0 ) const
| inline

Append an escaped string suitable for use in URIs

Parameters

  buf | Destination buffer
  extraEsc | Character to escape other than the default ones
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  Destination buffer reference

References c_str(), String(), and uriEscapeTo().

## ◆ uriEscapeTo() [2/3]

String & uriEscapeTo | ( | String & | buf,
|  | const char * | str,
|  | char | extraEsc = 0,
|  | const char * | noEsc = 0 )
| static

Append an escaped string suitable for use in URIs

Parameters

  buf | Destination buffer
  str | String to convert to escaped format
  extraEsc | Character to escape other than the default ones
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  Destination buffer reference

References String().

Referenced by SocketAddr::escapeIface(), uriEscape(), uriEscape(), and uriEscapeTo().

## ◆ uriEscapeTo() [3/3]

String & uriEscapeTo | ( | String & | buf,
|  | const char * | str,
|  | const char * | extraEsc,
|  | const char * | noEsc = 0 )
| static

Append an escaped string suitable for use in URIs

Parameters

  buf | Destination buffer
  str | String to convert to escaped format
  extraEsc | Pointer to string of characters to escape other than the defaults
  noEsc | Optional pointer to string of characters that shouldn't be escaped

Returns
  Destination buffer reference

References String().

## ◆ uriUnescape() [1/2]

String uriUnescape | ( | const char * | str,
|  | int * | errptr = 0,
|  | bool | setPartial = true )
| inlinestatic

Decode an URI escaped string back to its raw form

Parameters

  str | String to convert to unescaped format
  errptr | Pointer to an integer to receive the place of 1st error
  setPartial | Copy partial (succeeded) string on failure

Returns
  The string with special characters unescaped

References String(), and uriUnescapeTo().

Referenced by ClientContact::getContactSection(), ClientContact::splitContactId(), and uriUnescape().

## ◆ uriUnescape() [2/2]

String uriUnescape | ( | int * | errptr = 0,
|  | bool | setPartial = true ) const
| inline

Decode an URI escaped string back to its raw form

Parameters

  errptr | Pointer to an integer to receive the place of 1st error
  setPartial | Copy partial (succeeded) string on failure

Returns
  The string with special characters unescaped

References c_str(), String(), and uriUnescape().

## ◆ uriUnescapeStr()

String & uriUnescapeStr | ( | bool | setPartial = false,
|  | int * | errptr = 0 )
| inline

In place decode an URI escaped string back to its raw form

Parameters

  setPartial | Copy partial (succeeded) string on failure
  errptr | Pointer to an integer to receive the place of 1st error

Returns
  String reference

References c_str(), String(), and uriUnescapeTo().

## ◆ uriUnescapeTo() [1/2]

String & uriUnescapeTo | ( | String & | buf,
|  | bool | setPartial = false,
|  | int * | errptr = 0 ) const
| inline

Decode an URI escaped string back to its raw form

Parameters

  buf | Destination buffer
  setPartial | Copy partial (succeeded) string on failure
  errptr | Pointer to an integer to receive the place of 1st error

Returns
  Destination buffer reference

References c_str(), String(), and uriUnescapeTo().

## ◆ uriUnescapeTo() [2/2]

String & uriUnescapeTo | ( | String & | buf,
|  | const char * | str,
|  | bool | setPartial = false,
|  | int * | errptr = 0 )
| static

Decode and append an URI escaped string back to its raw form It is safe to call this method with 'str' set to buf.c_str()

Parameters

  buf | Destination buffer
  str | String to convert to unescaped format
  setPartial | Copy partial (succeeded) string on failure
  errptr | Pointer to an integer to receive the place of 1st error

Returns
  Destination buffer reference

References String().

Referenced by uriUnescape(), uriUnescapeStr(), and uriUnescapeTo().

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

- yateclass.h