ZNC  trunk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
CString Class Reference

String class that is used inside ZNC. More...

#include <ZNCString.h>

+ Inheritance diagram for CString:
+ Collaboration diagram for CString:

Public Types

enum  EEscape {
  EASCII, EURL, EHTML, ESQL,
  ENAMEDFMT, EDEBUG, EMSGTAG, EHEXCOLON
}
 

Public Member Functions

 CString (bool b)
 
 CString (char c)
 
 CString (unsigned char c)
 
 CString (short i)
 
 CString (unsigned short i)
 
 CString (int i)
 
 CString (unsigned int i)
 
 CString (long i)
 
 CString (unsigned long i)
 
 CString (long long i)
 
 CString (unsigned long long i)
 
 CString (double i, int precision=2)
 
 CString (float i, int precision=2)
 
 CString ()
 
 CString (const char *c)
 
 CString (const char *c, size_t l)
 
 CString (const std::string &s)
 
 CString (size_t n, char c)
 
 CString (std::initializer_list< char > list)
 
 ~CString ()
 
template<typename T >
bool Convert (T *target) const
 Casts a CString to another type. More...
 
template<typename Iterator >
CString Join (Iterator i_start, const Iterator &i_end) const
 Joins a collection of objects together, using 'this' as a delimiter. More...
 
int CaseCmp (const CString &s, CString::size_type uLen=CString::npos) const
 Compare this string caselessly to some other string. More...
 
int StrCmp (const CString &s, CString::size_type uLen=CString::npos) const
 Compare this string case sensitively to some other string. More...
 
bool Equals (const CString &s, CaseSensitivity cs=CaseInsensitive) const
 Check if this string is equal to some other string. More...
 
bool Equals (const CString &s, bool bCaseSensitive, CString::size_type uLen=CString::npos) const
 
bool WildCmp (const CString &sWild, CaseSensitivity cs=CaseSensitive) const
 Do a wild compare on this string. More...
 
CStringMakeUpper ()
 Turn all characters in this string into their upper-case equivalent. More...
 
CStringMakeLower ()
 Turn all characters in this string into their lower-case equivalent. More...
 
CString AsUpper () const
 Return a copy of this string with all characters turned into upper-case. More...
 
CString AsLower () const
 Return a copy of this string with all characters turned into lower-case. More...
 
CString Escape_n (EEscape eFrom, EEscape eTo) const
 
CString Escape_n (EEscape eTo) const
 
CStringEscape (EEscape eFrom, EEscape eTo)
 
CStringEscape (EEscape eTo)
 
CString Replace_n (const CString &sReplace, const CString &sWith, const CString &sLeft="", const CString &sRight="", bool bRemoveDelims=false) const
 Replace all occurrences in the current string. More...
 
unsigned int Replace (const CString &sReplace, const CString &sWith, const CString &sLeft="", const CString &sRight="", bool bRemoveDelims=false)
 Replace all occurrences in the current string. More...
 
CString Ellipsize (unsigned int uLen) const
 Ellipsize the current string. More...
 
CString Left (size_type uCount) const
 Return the left part of the string. More...
 
CString Right (size_type uCount) const
 Return the right part of the string. More...
 
CString FirstLine () const
 Get the first line of this string. More...
 
CString Token (size_t uPos, bool bRest=false, const CString &sSep=" ", bool bAllowEmpty=false) const
 Get a token out of this string. More...
 
CString Token (size_t uPos, bool bRest, const CString &sSep, bool bAllowEmpty, const CString &sLeft, const CString &sRight, bool bTrimQuotes=true) const
 Get a token out of this string. More...
 
size_type URLSplit (MCString &msRet) const
 
size_type OptionSplit (MCString &msRet, bool bUpperKeys=false) const
 
size_type QuoteSplit (VCString &vsRet) const
 
size_type Split (const CString &sDelim, VCString &vsRet, bool bAllowEmpty=true, const CString &sLeft="", const CString &sRight="", bool bTrimQuotes=true, bool bTrimWhiteSpace=false) const
 Split up this string into tokens. More...
 
size_type Split (const CString &sDelim, SCString &ssRet, bool bAllowEmpty=true, const CString &sLeft="", const CString &sRight="", bool bTrimQuotes=true, bool bTrimWhiteSpace=false) const
 Split up this string into tokens. More...
 
CString MD5 () const
 
CString SHA256 () const
 
unsigned long Base64Decode (CString &sRet) const
 Treat this string as base64-encoded data and decode it. More...
 
unsigned long Base64Decode ()
 Treat this string as base64-encoded data and decode it. More...
 
CString Base64Decode_n () const
 Treat this string as base64-encoded data and decode it. More...
 
bool Base64Encode (CString &sRet, unsigned int uWrap=0) const
 Base64-encode the current string. More...
 
bool Base64Encode (unsigned int uWrap=0)
 Base64-encode the current string. More...
 
CString Base64Encode_n (unsigned int uWrap=0) const
 Base64-encode the current string. More...
 
CString Encrypt_n (const CString &sPass, const CString &sIvec="") const
 
CString Decrypt_n (const CString &sPass, const CString &sIvec="") const
 
void Encrypt (const CString &sPass, const CString &sIvec="")
 
void Decrypt (const CString &sPass, const CString &sIvec="")
 
void Crypt (const CString &sPass, bool bEncrypt, const CString &sIvec="")
 
bool ToBool () const
 
short ToShort () const
 
unsigned short ToUShort () const
 
int ToInt () const
 
long ToLong () const
 
unsigned int ToUInt () const
 
unsigned long ToULong () const
 
unsigned long long ToULongLong () const
 
long long ToLongLong () const
 
double ToDouble () const
 
bool Trim (const CString &s=" \t\r\n")
 Trim this string. More...
 
bool TrimLeft (const CString &s=" \t\r\n")
 Trim this string. More...
 
bool TrimRight (const CString &s=" \t\r\n")
 Trim this string. More...
 
CString Trim_n (const CString &s=" \t\r\n") const
 Trim this string. More...
 
CString TrimLeft_n (const CString &s=" \t\r\n") const
 Trim this string. More...
 
CString TrimRight_n (const CString &s=" \t\r\n") const
 Trim this string. More...
 
bool TrimPrefix (const CString &sPrefix=":")
 Trim a given prefix. More...
 
bool TrimSuffix (const CString &sSuffix)
 Trim a given suffix. More...
 
CString TrimPrefix_n (const CString &sPrefix=":") const
 Trim a given prefix. More...
 
CString TrimSuffix_n (const CString &sSuffix) const
 Trim a given suffix. More...
 
size_t Find (const CString &s, CaseSensitivity cs=CaseInsensitive) const
 Find the position of the given substring. More...
 
bool StartsWith (const CString &sPrefix, CaseSensitivity cs=CaseInsensitive) const
 Check whether the string starts with a given prefix. More...
 
bool EndsWith (const CString &sSuffix, CaseSensitivity cs=CaseInsensitive) const
 Check whether the string ends with a given suffix. More...
 
bool Contains (const CString &s, CaseSensitivity cs=CaseInsensitive) const
 Check whether the string contains a given string. More...
 
bool LeftChomp (size_type uLen=1)
 Remove characters from the beginning of this string. More...
 
bool RightChomp (size_type uLen=1)
 Remove characters from the end of this string. More...
 
CString LeftChomp_n (size_type uLen=1) const
 Remove characters from the beginning of this string. More...
 
CString RightChomp_n (size_type uLen=1) const
 Remove characters from the end of this string. More...
 
CStringStripControls ()
 Remove controls characters from this string. More...
 
CString StripControls_n () const
 Remove controls characters from this string. More...
 

Static Public Member Functions

static bool WildCmp (const CString &sWild, const CString &sString, CaseSensitivity cs=CaseSensitive)
 Do a wildcard comparison between two strings. More...
 
static EEscape ToEscape (const CString &sEsc)
 
static unsigned int Replace (CString &sStr, const CString &sReplace, const CString &sWith, const CString &sLeft="", const CString &sRight="", bool bRemoveDelims=false)
 Replace all occurrences in a string. More...
 
static CString NamedFormat (const CString &sFormat, const MCString &msValues)
 Build a string from a format string, replacing values from a map. More...
 
static CString RandomString (unsigned int uLength)
 Produces a random string. More...
 
static CString ToPercent (double d)
 Pretty-print a percent value. More...
 
static CString ToByteStr (unsigned long long d)
 Pretty-print a number of bytes. More...
 
static CString ToTimeStr (unsigned long s)
 Pretty-print a time span. More...
 

Static Public Attributes

static const CaseSensitivity CaseSensitive = CaseSensitivity::CaseSensitive
 
static const CaseSensitivity CaseInsensitive
 

Protected Member Functions

unsigned char * strnchr (const unsigned char *src, unsigned char c, unsigned int iMaxBytes, unsigned char *pFill=nullptr, unsigned int *piCount=nullptr) const
 

Detailed Description

String class that is used inside ZNC.

All strings that are used in ZNC and its modules should use instances of this class. It provides helpful functions for parsing input like Token() and Split().

Member Enumeration Documentation

Enumerator
EASCII 
EURL 
EHTML 
ESQL 
ENAMEDFMT 
EDEBUG 
EMSGTAG 
EHEXCOLON 

Constructor & Destructor Documentation

CString::CString ( bool  b)
inlineexplicit
CString::CString ( char  c)
explicit
CString::CString ( unsigned char  c)
explicit
CString::CString ( short  i)
explicit
CString::CString ( unsigned short  i)
explicit
CString::CString ( int  i)
explicit
CString::CString ( unsigned int  i)
explicit
CString::CString ( long  i)
explicit
CString::CString ( unsigned long  i)
explicit
CString::CString ( long long  i)
explicit
CString::CString ( unsigned long long  i)
explicit
CString::CString ( double  i,
int  precision = 2 
)
explicit
CString::CString ( float  i,
int  precision = 2 
)
explicit
CString::CString ( )
inline

Referenced by Join().

CString::CString ( const char *  c)
inline
CString::CString ( const char *  c,
size_t  l 
)
inline
CString::CString ( const std::string &  s)
inline
CString::CString ( size_t  n,
char  c 
)
inline
CString::CString ( std::initializer_list< char >  list)
inline
CString::~CString ( )
inline

Member Function Documentation

CString CString::AsLower ( ) const

Return a copy of this string with all characters turned into lower-case.

Returns
The new string.
CString CString::AsUpper ( ) const

Return a copy of this string with all characters turned into upper-case.

Returns
The new string.
unsigned long CString::Base64Decode ( CString sRet) const

Treat this string as base64-encoded data and decode it.

Parameters
sRetString to which the result of the decode is safed.
Returns
The length of the resulting string.
unsigned long CString::Base64Decode ( )

Treat this string as base64-encoded data and decode it.

The result is saved in this CString instance.

Returns
The length of the resulting string.
CString CString::Base64Decode_n ( ) const

Treat this string as base64-encoded data and decode it.

Returns
The decoded string.
bool CString::Base64Encode ( CString sRet,
unsigned int  uWrap = 0 
) const

Base64-encode the current string.

Parameters
sRetString where the result is saved.
uWrapA boolean(!?!) that decides if the result should be wrapped after everywhere 57 characters.
Returns
true unless this code is buggy.
Todo:

WTF @ uWrap.

This only returns false if some formula we use was wrong?!

bool CString::Base64Encode ( unsigned int  uWrap = 0)

Base64-encode the current string.

This string is overwritten with the result of the encode.

Todo:
return value and param are as with Base64Encode() from above.
CString CString::Base64Encode_n ( unsigned int  uWrap = 0) const

Base64-encode the current string.

Todo:
uWrap is as broken as Base64Encode()'s uWrap.
Returns
The encoded string.
int CString::CaseCmp ( const CString s,
CString::size_type  uLen = CString::npos 
) const

Compare this string caselessly to some other string.

Parameters
sThe string to compare to.
uLenThe number of characters to compare.
Returns
An integer less than, equal to, or greater than zero if this string smaller, equal.... to the given string.
bool CString::Contains ( const CString s,
CaseSensitivity  cs = CaseInsensitive 
) const

Check whether the string contains a given string.

Parameters
sThe string to search.
bCaseSensitiveWhether the search is case sensitive.
Returns
True if this string contains the other string, falser otherwise.
template<typename T >
bool CString::Convert ( T *  target) const
inline

Casts a CString to another type.

Implemented via std::stringstream, you use this for any class that has an operator<<(std::ostream, YourClass).

Parameters
targetThe object to cast into. If the cast fails, its state is unspecified.
Returns
True if the cast succeeds, and false if it fails.
void CString::Crypt ( const CString sPass,
bool  bEncrypt,
const CString sIvec = "" 
)
void CString::Decrypt ( const CString sPass,
const CString sIvec = "" 
)
CString CString::Decrypt_n ( const CString sPass,
const CString sIvec = "" 
) const
CString CString::Ellipsize ( unsigned int  uLen) const

Ellipsize the current string.

For example, ellipsizing "Hello, I'm Bob" to the length 9 would result in "Hello,...".

Parameters
uLenThe length to ellipsize to.
Returns
The ellipsized string.
void CString::Encrypt ( const CString sPass,
const CString sIvec = "" 
)
CString CString::Encrypt_n ( const CString sPass,
const CString sIvec = "" 
) const
bool CString::EndsWith ( const CString sSuffix,
CaseSensitivity  cs = CaseInsensitive 
) const

Check whether the string ends with a given suffix.

Parameters
sSuffixThe suffix.
csCaseSensitive if you want the comparison to be case sensitive, CaseInsensitive (default) otherwise.
Returns
True if the string ends with suffix, false otherwise.
bool CString::Equals ( const CString s,
CaseSensitivity  cs = CaseInsensitive 
) const

Check if this string is equal to some other string.

Parameters
sThe string to compare to.
csCaseSensitive if you want the comparison to be case sensitive, CaseInsensitive (default) otherwise.
Returns
True if the strings are equal.

Referenced by CCTCPMessage::IsReply().

bool CString::Equals ( const CString s,
bool  bCaseSensitive,
CString::size_type  uLen = CString::npos 
) const
CString& CString::Escape ( EEscape  eFrom,
EEscape  eTo 
)
CString& CString::Escape ( EEscape  eTo)
CString CString::Escape_n ( EEscape  eFrom,
EEscape  eTo 
) const
CString CString::Escape_n ( EEscape  eTo) const
size_t CString::Find ( const CString s,
CaseSensitivity  cs = CaseInsensitive 
) const

Find the position of the given substring.

Parameters
sThe substring to search for.
csCaseSensitive if you want the comparison to be case sensitive, CaseInsensitive (default) otherwise.
Returns
The position of the substring if found, CString::npos otherwise.
CString CString::FirstLine ( ) const
inline

Get the first line of this string.

Returns
The first line of text.

References Token().

template<typename Iterator >
CString CString::Join ( Iterator  i_start,
const Iterator &  i_end 
) const
inline

Joins a collection of objects together, using 'this' as a delimiter.

You can pass either pointers to arrays, or iterators to collections.

Parameters
i_beginAn iterator pointing to the beginning of a group of objects.
i_endAn iterator pointing past the end of a group of objects.
Returns
The joined string

References CString().

CString CString::Left ( size_type  uCount) const

Return the left part of the string.

Parameters
uCountThe number of characters to keep.
Returns
The resulting string.
bool CString::LeftChomp ( size_type  uLen = 1)

Remove characters from the beginning of this string.

Parameters
uLenThe number of characters to remove.
Returns
true if this string was modified.
CString CString::LeftChomp_n ( size_type  uLen = 1) const

Remove characters from the beginning of this string.

This string object isn't modified.

Parameters
uLenThe number of characters to remove.
Returns
The result of the conversion.
CString& CString::MakeLower ( )

Turn all characters in this string into their lower-case equivalent.

Returns
A reference to *this.
CString& CString::MakeUpper ( )

Turn all characters in this string into their upper-case equivalent.

Returns
A reference to *this.
CString CString::MD5 ( ) const
Returns
The MD5 hash of this string.
static CString CString::NamedFormat ( const CString sFormat,
const MCString msValues 
)
static

Build a string from a format string, replacing values from a map.

The format specification can contain simple named parameters that match keys in the given map. For example in the string "a {b} c", the key "b" is looked up in the map, and inserted for "{b}".

Parameters
sFormatThe format specification.
msValuesA map of named parameters to their values.
Returns
The string with named parameters replaced.

Referenced by CInlineFormatMessage::operator()().

size_type CString::OptionSplit ( MCString msRet,
bool  bUpperKeys = false 
) const
size_type CString::QuoteSplit ( VCString vsRet) const
static CString CString::RandomString ( unsigned int  uLength)
static

Produces a random string.

Parameters
uLengthThe length of the resulting string.
Returns
A random string.
static unsigned int CString::Replace ( CString sStr,
const CString sReplace,
const CString sWith,
const CString sLeft = "",
const CString sRight = "",
bool  bRemoveDelims = false 
)
static

Replace all occurrences in a string.

You can specify a "safe zone" via sLeft and sRight. Anything inside of such a zone will not be replaced. This does not do recursion, so e.g. with Replace("(a()a)", "a", "b", "(", ")", true) you would get "a(b)" as result. The second opening brace and the second closing brace would not be seen as a delimitered and thus wouldn't be removed. The first a is inside a "safe zone" and thus is left alone, too.

Parameters
sStrThe string to do the replacing on. This will also contain the result when this function returns.
sReplaceThe string that should be replaced.
sWithThe replacement to use.
sLeftThe string that marks the begin of the "safe zone".
sRightThe string that marks the end of the "safe zone".
bRemoveDelimsIf this is true, all matches for sLeft and sRight are removed.
Returns
The number of replacements done.
unsigned int CString::Replace ( const CString sReplace,
const CString sWith,
const CString sLeft = "",
const CString sRight = "",
bool  bRemoveDelims = false 
)

Replace all occurrences in the current string.

See Also
CString::Replace
Parameters
sReplaceThe string to look for.
sWithThe replacement to use.
sLeftThe delimiter at the beginning of a safe zone.
sRightThe delimiter at the end of a safe zone.
bRemoveDelimsIf true, all matching delimiters are removed.
Returns
The number of replacements done.
CString CString::Replace_n ( const CString sReplace,
const CString sWith,
const CString sLeft = "",
const CString sRight = "",
bool  bRemoveDelims = false 
) const

Replace all occurrences in the current string.

See Also
CString::Replace
Parameters
sReplaceThe string to look for.
sWithThe replacement to use.
sLeftThe delimiter at the beginning of a safe zone.
sRightThe delimiter at the end of a safe zone.
bRemoveDelimsIf true, all matching delimiters are removed.
Returns
The result of the replacing. The current string is left unchanged.
CString CString::Right ( size_type  uCount) const

Return the right part of the string.

Parameters
uCountThe number of characters to keep.
Returns
The resulting string.
bool CString::RightChomp ( size_type  uLen = 1)

Remove characters from the end of this string.

Parameters
uLenThe number of characters to remove.
Returns
true if this string was modified.
CString CString::RightChomp_n ( size_type  uLen = 1) const

Remove characters from the end of this string.

This string object isn't modified.

Parameters
uLenThe number of characters to remove.
Returns
The result of the conversion.
CString CString::SHA256 ( ) const
Returns
The SHA256 hash of this string.
size_type CString::Split ( const CString sDelim,
VCString vsRet,
bool  bAllowEmpty = true,
const CString sLeft = "",
const CString sRight = "",
bool  bTrimQuotes = true,
bool  bTrimWhiteSpace = false 
) const

Split up this string into tokens.

Via sLeft and sRight you can define "markers" like with Replace(). Anything in such a marked section is treated as a single token. All occurrences of sDelim in such a block are ignored.

Parameters
sDelimDelimiter between tokens.
vsRetVector for returning the result.
bAllowEmptyDo empty tokens count as a valid token?
sLeftLeft delimiter like with Replace().
sRightRight delimiter like with Replace().
bTrimQuotesShould sLeft and sRight be removed from the token they mark?
bTrimWhiteSpaceIf this is true, CString::Trim() is called on each token.
Returns
The number of tokens found.
size_type CString::Split ( const CString sDelim,
SCString ssRet,
bool  bAllowEmpty = true,
const CString sLeft = "",
const CString sRight = "",
bool  bTrimQuotes = true,
bool  bTrimWhiteSpace = false 
) const

Split up this string into tokens.

This function is identical to the other CString::Split(), except that the result is returned as a SCString instead of a VCString.

bool CString::StartsWith ( const CString sPrefix,
CaseSensitivity  cs = CaseInsensitive 
) const

Check whether the string starts with a given prefix.

Parameters
sPrefixThe prefix.
csCaseSensitive if you want the comparison to be case sensitive, CaseInsensitive (default) otherwise.
Returns
True if the string starts with prefix, false otherwise.
int CString::StrCmp ( const CString s,
CString::size_type  uLen = CString::npos 
) const

Compare this string case sensitively to some other string.

Parameters
sThe string to compare to.
uLenThe number of characters to compare.
Returns
An integer less than, equal to, or greater than zero if this string smaller, equal.... to the given string.
CString& CString::StripControls ( )

Remove controls characters from this string.

Controls characters are color codes, and those in C0 set See https://en.wikipedia.org/wiki/C0_and_C1_control_codes

Returns
The result of the conversion.
CString CString::StripControls_n ( ) const

Remove controls characters from this string.

Controls characters are color codes, and those in C0 set See https://en.wikipedia.org/wiki/C0_and_C1_control_codes This string object isn't modified.

Returns
The result of the conversion.
unsigned char* CString::strnchr ( const unsigned char *  src,
unsigned char  c,
unsigned int  iMaxBytes,
unsigned char *  pFill = nullptr,
unsigned int *  piCount = nullptr 
) const
protected
bool CString::ToBool ( ) const
Returns
True if this string is not "false".

Referenced by CConfig::FindBoolEntry().

static CString CString::ToByteStr ( unsigned long long  d)
static

Pretty-print a number of bytes.

Parameters
dThe number of bytes.
Returns
A string describing the number of bytes.
double CString::ToDouble ( ) const
Returns
The numerical value of this string similar to atoi().

Referenced by CConfig::FindDoubleEntry().

static EEscape CString::ToEscape ( const CString sEsc)
static
int CString::ToInt ( ) const
Returns
The numerical value of this string similar to atoi().
CString CString::Token ( size_t  uPos,
bool  bRest = false,
const CString sSep = " ",
bool  bAllowEmpty = false 
) const

Get a token out of this string.

For example in the string "a bc d e", each of "a", "bc", "d" and "e" are tokens.

Parameters
uPosThe number of the token you are interested. The first token has a position of 0.
bRestIf false, only the token you asked for is returned. Else you get the substring starting from the beginning of your token.
sSepSeperator between tokens.
bAllowEmptyIf this is true, empty tokens are allowed. In the example from above this means that there is a token "" before the "e" token.
Returns
The token you asked for and, if bRest is true, everything after it.
See Also
Split() if you need a string split into all of its tokens.

Referenced by FirstLine().

CString CString::Token ( size_t  uPos,
bool  bRest,
const CString sSep,
bool  bAllowEmpty,
const CString sLeft,
const CString sRight,
bool  bTrimQuotes = true 
) const

Get a token out of this string.

This function behaves much like the other Token() function in this class. The extra arguments are handled similarly to Split().

long CString::ToLong ( ) const
Returns
The numerical value of this string similar to atoi().
long long CString::ToLongLong ( ) const
Returns
The numerical value of this string similar to atoi().
static CString CString::ToPercent ( double  d)
static

Pretty-print a percent value.

Parameters
dThe percent value. This should be in range 0-100.
Returns
The "pretty" string.
short CString::ToShort ( ) const
Returns
The numerical value of this string similar to atoi().
static CString CString::ToTimeStr ( unsigned long  s)
static

Pretty-print a time span.

Parameters
sNumber of seconds to print.
Returns
A string like "4w 6d 4h 3m 58s".
unsigned int CString::ToUInt ( ) const
Returns
The numerical value of this string similar to atoi().

Referenced by CConfig::FindUIntEntry(), and CNumericMessage::GetCode().

unsigned long CString::ToULong ( ) const
Returns
The numerical value of this string similar to atoi().
unsigned long long CString::ToULongLong ( ) const
Returns
The numerical value of this string similar to atoi().
unsigned short CString::ToUShort ( ) const
Returns
The numerical value of this string similar to atoi().

Referenced by CConfig::FindUShortEntry().

bool CString::Trim ( const CString s = " \t\r\n")

Trim this string.

All leading/trailing occurrences of characters from s are removed.

Parameters
sA list of characters that should be trimmed.
Returns
true if this string was modified.
CString CString::Trim_n ( const CString s = " \t\r\n") const

Trim this string.

All leading/trailing occurrences of characters from s are removed. This CString instance is not modified.

Parameters
sA list of characters that should be trimmed.
Returns
The trimmed string.
bool CString::TrimLeft ( const CString s = " \t\r\n")

Trim this string.

All leading occurrences of characters from s are removed.

Parameters
sA list of characters that should be trimmed.
Returns
true if this string was modified.
CString CString::TrimLeft_n ( const CString s = " \t\r\n") const

Trim this string.

All leading occurrences of characters from s are removed. This CString instance is not modified.

Parameters
sA list of characters that should be trimmed.
Returns
The trimmed string.
bool CString::TrimPrefix ( const CString sPrefix = ":")

Trim a given prefix.

Parameters
sPrefixThe prefix that should be removed.
Returns
True if this string was modified.
CString CString::TrimPrefix_n ( const CString sPrefix = ":") const

Trim a given prefix.

Parameters
sPrefixThe prefix that should be removed.
Returns
A copy of this string without the prefix.

Referenced by CModeMessage::GetModes(), CActionMessage::GetText(), and CCTCPMessage::GetText().

bool CString::TrimRight ( const CString s = " \t\r\n")

Trim this string.

All trailing occurrences of characters from s are removed.

Parameters
sA list of characters that should be trimmed.
Returns
true if this string was modified.
CString CString::TrimRight_n ( const CString s = " \t\r\n") const

Trim this string.

All trailing occurrences of characters from s are removed. This CString instance is not modified.

Parameters
sA list of characters that should be trimmed.
Returns
The trimmed string.
bool CString::TrimSuffix ( const CString sSuffix)

Trim a given suffix.

Parameters
sSuffixThe suffix that should be removed.
Returns
True if this string was modified.
CString CString::TrimSuffix_n ( const CString sSuffix) const

Trim a given suffix.

Parameters
sSuffixThe suffix that should be removed.
Returns
A copy of this string without the prefix.

Referenced by CDir::FillByWildcard(), CActionMessage::GetText(), and CCTCPMessage::GetText().

size_type CString::URLSplit ( MCString msRet) const
static bool CString::WildCmp ( const CString sWild,
const CString sString,
CaseSensitivity  cs = CaseSensitive 
)
static

Do a wildcard comparison between two strings.

For example, the following returns true: WildCmp("*!?bar@foo", "I_am!~bar@foo");

Parameters
sWildThe wildcards used for the comparison.
sStringThe string that is used for comparing.
csCaseSensitive (default) if you want the comparison to be case sensitive, CaseInsensitive otherwise.
Todo:
Make cs CaseInsensitive by default.
Returns
true if the wildcard matches.

Referenced by CDir::FillByWildcard().

bool CString::WildCmp ( const CString sWild,
CaseSensitivity  cs = CaseSensitive 
) const

Do a wild compare on this string.

Parameters
sWildThe wildcards used to for the comparison.
csCaseSensitive (default) if you want the comparison to be case sensitive, CaseInsensitive otherwise.
Todo:
Make cs CaseInsensitive by default.
Returns
The result of this->WildCmp(sWild, *this);.

Member Data Documentation

const CaseSensitivity CString::CaseInsensitive
static
const CaseSensitivity CString::CaseSensitive = CaseSensitivity::CaseSensitive
static

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