VMime
stringUtils Class Reference

Static Public Member Functions

static const string makeStringFromBytes (const byte_t *data, const size_t count)
 
static const byte_tbytesFromString (const string &str)
 
static const byte_tbytesFromString (const char *str)
 
static stringappendBytesToString (string &str, const byte_t *data, const size_t count)
 
static bool isStringEqualNoCase (const string &s1, const char *s2, const size_t n)
 
static bool isStringEqualNoCase (const string &s1, const string &s2)
 
static bool isStringEqualNoCase (const string::const_iterator begin, const string::const_iterator end, const char *s, const size_t n)
 
static const string toLower (const string &str)
 
static const string toUpper (const string &str)
 
static const string trim (const string &str)
 
static size_t countASCIIchars (const string::const_iterator begin, const string::const_iterator end)
 
static bool is7bit (const string &str)
 
static size_t findFirstNonASCIIchar (const string::const_iterator begin, const string::const_iterator end)
 
template<class TYPE >
static const string toString (const TYPE &value)
 
template<class TYPE >
static const TYPE fromString (const string &value)
 
static const string unquote (const string &str)
 
static bool needQuoting (const string &str, const string &specialChars=" \t\"(),:;<>@[\\]")
 
static string quote (const string &str, const string &escapeSpecialChars, const string &escapeChar)
 

Detailed Description

Miscellaneous functions related to strings.

Member Function Documentation

static string& appendBytesToString ( string str,
const byte_t data,
const size_t  count 
)
static

Appends bytes to a string.

Parameters
strstring to which append data
datapointer to buffer containing data
countnumber of bytes to use from buffer
Returns
a reference to modified string

Referenced by maildirMessage::fetchPartHeader(), and outputStreamStringAdapter::writeImpl().

static const byte_t* bytesFromString ( const string str)
static

Casts a string to bytes.

Parameters
strstring
Returns
pointer to the first byte of the string

Referenced by IMAPFolder::addMessage().

static const byte_t* bytesFromString ( const char *  str)
static

Casts a NULL-terminated string to bytes.

Parameters
strstring
Returns
pointer to the first byte of the string
size_t countASCIIchars ( const string::const_iterator  begin,
const string::const_iterator  end 
)
static

Return the number of 7-bit US-ASCII characters in a string.

Parameters
beginstart position
endend position
Returns
number of ASCII characters

References vmime::count(), vmime::end(), and parserHelpers::isAscii().

Referenced by text::createFromString(), wordEncoder::guessBestEncoding(), and stringUtils::is7bit().

size_t findFirstNonASCIIchar ( const string::const_iterator  begin,
const string::const_iterator  end 
)
static

Returns the position of the first non 7-bit US-ASCII character in a string.

Parameters
beginstart position
endend position
Returns
position since begin, or string::npos

References vmime::begin(), vmime::end(), parserHelpers::isAscii(), and vmime::npos.

Referenced by wordEncoder::isEncodingNeeded().

static const TYPE fromString ( const string value)
static

Convert the specified string value to a value of the specified type.

Parameters
valuevalue to convert
Returns
value converted into type 'TYPE'
bool is7bit ( const string str)
static

Returns whether the specified string is composed exclusively of 7-bit ASCII characters.

Parameters
strstring to test
Returns
true if the string is ASCII-only, false otherwise

References stringUtils::countASCIIchars().

Referenced by charsetConverter_idna::convert(), and emailAddress::generateImpl().

bool isStringEqualNoCase ( const string s1,
const char *  s2,
const size_t  n 
)
static

Test two strings for equality (case insensitive).

Warning
Use this with ASCII-only strings.
Parameters
s1first string
s2second string (must be in lower-case!)
nlength of the second string
Returns
true if the two strings compare equally, false otherwise

Referenced by charset::charset(), charset::operator==(), relay::parseImpl(), charset::parseImpl(), and transport::processHeaderField().

bool isStringEqualNoCase ( const string s1,
const string s2 
)
static

Test two strings for equality (case insensitive).

Warning
Use this with ASCII-only strings.
Parameters
s1first string
s2second string
Returns
true if the two strings compare equally, false otherwise

References vmime::end().

bool isStringEqualNoCase ( const string::const_iterator  begin,
const string::const_iterator  end,
const char *  s,
const size_t  n 
)
static

Test two strings for equality (case insensitive).

Warning
Use this with ASCII-only strings.
Parameters
beginstart position of the first string
endend position of the first string
ssecond string (must be in lower-case!)
nlength of the second string
Returns
true if the two strings compare equally, false otherwise
static const string makeStringFromBytes ( const byte_t data,
const size_t  count 
)
static

Makes a string from bytes.

Parameters
datapointer to buffer containing data
countnumber of bytes to use from buffer
Returns
a string object containing a copy of the specified data

Referenced by SASLSocket::receive().

bool needQuoting ( const string str,
const string specialChars = " \t\"(),:;<>@[\\]" 
)
static

Determines whether the specified string needs to be quoted.

Parameters
strstring to test
specialCharslist of characters that will cause the string to be quoted
Returns
true if the string needs to be quoted, false otherwise

References vmime::npos.

string quote ( const string str,
const string escapeSpecialChars,
const string escapeChar 
)
static

Quotes the specified string.

Parameters
strstring to quote
escapeSpecialCharslist of characters that will be escaped
escapeCharcharacter that will be used for escaping (eg. '\')
Returns
quoted string

References vmime::npos.

static const string toString ( const TYPE &  value)
static

Convert the specified value to a string value.

Parameters
valueto convert
Returns
value converted from type 'TYPE'

Referenced by messageSet::byUID().

const string toUpper ( const string str)
static

Transform all the characters in a string to upper-case.

Warning
Use this with ASCII-only strings.
Parameters
strthe string to transform
Returns
a new string in upper-case

Referenced by SASLMechanismFactory::create().

const string trim ( const string str)
static

Strip the space characters (SPC, TAB, CR, LF) at the beginning and at the end of the specified string.

Parameters
strstring in which to strip spaces
Returns
a new string with space characters removed

References parserHelpers::isSpace().

Referenced by disposition::generateImpl(), importanceHelper::getImportanceHeader(), maildirStore::isValidFolderName(), contentDisposition::parseImpl(), mediaType::parseImpl(), charset::parseImpl(), encoding::parseImpl(), mailboxGroup::parseImpl(), and POP3Response::readMultilineResponse().

const string unquote ( const string str)
static

Unquote the specified string and transform escaped characters.

Parameters
strstring from which to remove quotes
Returns
unquoted string

References vmime::end().

Referenced by encoding::parseImpl().


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