ZNC
trunk
|
#include <pstring.h>
Public Types | |
enum | EType { STRING, INT, UINT, NUM, BOOL } |
enum | EEscape { EASCII, EURL, EHTML, ESQL, ENAMEDFMT, EDEBUG } |
Public Member Functions | |
PString () | |
PString (const char *c) | |
PString (const CString &s) | |
PString (int i) | |
PString (u_int i) | |
PString (long i) | |
PString (u_long i) | |
PString (long long i) | |
PString (unsigned long long i) | |
PString (double i) | |
PString (bool b) | |
PString (SV *sv) | |
virtual | ~PString () |
EType | GetType () const |
void | SetType (EType e) |
SV * | GetSV (bool bMakeMortal=true) const |
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, bool bCaseSensitive=false, CString::size_type uLen=CString::npos) const |
Check if this string is equal to some other string. More... | |
bool | WildCmp (const CString &sWild) const |
Do a wild compare on this string. More... | |
CString & | MakeUpper () |
Turn all characters in this string into their upper-case equivalent. More... | |
CString & | MakeLower () |
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 |
CString & | Escape (EEscape eFrom, EEscape eTo) |
CString & | Escape (EEscape eTo) |
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 | 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... | |
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... | |
bool | StartsWith (const CString &sPrefix) const |
Check whether the string starts with a given prefix. More... | |
bool | EndsWith (const CString &sSuffix) const |
Check whether the string ends with a given suffix. 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... | |
CString & | StripControls () |
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) |
Do a wildcard comparision 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... | |
Protected Member Functions | |
unsigned char * | strnchr (const unsigned char *src, unsigned char c, unsigned int iMaxBytes, unsigned char *pFill=NULL, unsigned int *piCount=NULL) const |
|
inherited |
enum PString::EType |
|
inline |
References STRING.
|
inline |
References STRING.
|
inline |
References INT.
|
inline |
References UINT.
|
inline |
References INT.
|
inline |
References UINT.
|
inline |
References INT.
|
inline |
References UINT.
|
inline |
References NUM.
|
inline |
References BOOL.
|
inline |
|
inlinevirtual |
|
inherited |
Return a copy of this string with all characters turned into lower-case.
|
inherited |
Return a copy of this string with all characters turned into upper-case.
|
inherited |
Treat this string as base64-encoded data and decode it.
sRet | String to which the result of the decode is safed. |
|
inherited |
Treat this string as base64-encoded data and decode it.
The result is saved in this CString instance.
|
inherited |
Treat this string as base64-encoded data and decode it.
|
inherited |
|
inherited |
Base64-encode the current string.
This string is overwritten with the result of the encode.
|
inherited |
Base64-encode the current string.
|
inherited |
Compare this string caselessly to some other string.
s | The string to compare to. |
uLen | The number of characters to compare. |
|
inlineinherited |
Casts a CString to another type.
Implemented via std::stringstream, you use this for any class that has an operator<<(std::ostream, YourClass).
target | The object to cast into. If the cast fails, its state is unspecified. |
|
inherited |
Ellipsize the current string.
For example, ellipsizing "Hello, I'm Bob" to the length 9 would result in "Hello,...".
uLen | The length to ellipsize to. |
|
inherited |
Check whether the string ends with a given suffix.
sSuffix | The suffix. |
|
inherited |
Check if this string is equal to some other string.
s | The string to compare to. |
bCaseSensitive | True if you want the comparision to be case sensitive. |
uLen | Number of characters to consider. |
|
inlineinherited |
|
inline |
References BOOL, GetType(), INT, NUM, STRING, CString::ToDouble(), CString::ToLongLong(), CString::ToULongLong(), and UINT.
|
inlineinherited |
Joins a collection of objects together, using 'this' as a delimiter.
You can pass either pointers to arrays, or iterators to collections.
i_begin | An iterator pointing to the beginning of a group of objects. |
i_end | An iterator pointing past the end of a group of objects. |
References CString::CString().
|
inherited |
Return the left part of the string.
uCount | The number of characters to keep. |
|
inherited |
Remove characters from the beginning of this string.
uLen | The number of characters to remove. |
|
inherited |
Remove characters from the beginning of this string.
This string object isn't modified.
uLen | The number of characters to remove. |
|
inherited |
Turn all characters in this string into their lower-case equivalent.
|
inherited |
Turn all characters in this string into their upper-case equivalent.
|
inherited |
|
staticinherited |
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}".
sFormat | The format specification. |
msValues | A map of named parameters to their values. |
|
inherited |
|
inherited |
|
staticinherited |
Produces a random string.
uLength | The length of the resulting string. |
|
staticinherited |
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.
sStr | The string to do the replacing on. This will also contain the result when this function returns. |
sReplace | The string that should be replaced. |
sWith | The replacement to use. |
sLeft | The string that marks the begin of the "safe zone". |
sRight | The string that marks the end of the "safe zone". |
bRemoveDelims | If this is true, all matches for sLeft and sRight are removed. |
|
inherited |
Replace all occurrences in the current string.
sReplace | The string to look for. |
sWith | The replacement to use. |
sLeft | The delimiter at the beginning of a safe zone. |
sRight | The delimiter at the end of a safe zone. |
bRemoveDelims | If true, all matching delimiters are removed. |
|
inherited |
Replace all occurrences in the current string.
sReplace | The string to look for. |
sWith | The replacement to use. |
sLeft | The delimiter at the beginning of a safe zone. |
sRight | The delimiter at the end of a safe zone. |
bRemoveDelims | If true, all matching delimiters are removed. |
|
inherited |
Return the right part of the string.
uCount | The number of characters to keep. |
|
inherited |
Remove characters from the end of this string.
uLen | The number of characters to remove. |
|
inherited |
Remove characters from the end of this string.
This string object isn't modified.
uLen | The number of characters to remove. |
|
inline |
|
inherited |
|
inherited |
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 occurences of sDelim in such a block are ignored.
sDelim | Delimiter between tokens. |
vsRet | Vector for returning the result. |
bAllowEmpty | Do empty tokens count as a valid token? |
sLeft | Left delimiter like with Replace(). |
sRight | Right delimiter like with Replace(). |
bTrimQuotes | Should sLeft and sRight be removed from the token they mark? |
bTrimWhiteSpace | If this is true, CString::Trim() is called on each token. |
|
inherited |
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.
|
inherited |
Check whether the string starts with a given prefix.
sPrefix | The prefix. |
|
inherited |
Compare this string case sensitively to some other string.
s | The string to compare to. |
uLen | The number of characters to compare. |
|
inherited |
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
|
inherited |
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.
|
protectedinherited |
|
inherited |
Referenced by CConfig::FindBoolEntry().
|
staticinherited |
Pretty-print a number of bytes.
d | The number of bytes. |
|
inherited |
Referenced by CConfig::FindDoubleEntry(), and GetSV().
|
inherited |
|
inherited |
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.
uPos | The number of the token you are interested. The first token has a position of 0. |
bRest | If false, only the token you asked for is returned. Else you get the substring starting from the beginning of your token. |
sSep | Seperator between tokens. |
bAllowEmpty | If this is true, empty tokens are allowed. In the example from above this means that there is a token "" before the "e" token. |
Referenced by CString::FirstLine().
|
inherited |
|
inherited |
Referenced by GetSV().
|
staticinherited |
Pretty-print a percent value.
d | The percent value. This should be in range 0-100. |
|
inherited |
|
staticinherited |
Pretty-print a time span.
s | Number of seconds to print. |
|
inherited |
Referenced by CConfig::FindUIntEntry().
|
inherited |
|
inherited |
Referenced by GetSV().
|
inherited |
Referenced by CConfig::FindUShortEntry().
|
inherited |
Trim this string.
All leading/trailing occurences of characters from s are removed.
s | A list of characters that should be trimmed. |
Trim this string.
All leading/trailing occurences of characters from s are removed. This CString instance is not modified.
s | A list of characters that should be trimmed. |
|
inherited |
Trim this string.
All leading occurences of characters from s are removed.
s | A list of characters that should be trimmed. |
Trim this string.
All leading occurences of characters from s are removed. This CString instance is not modified.
s | A list of characters that should be trimmed. |
|
inherited |
Trim a given prefix.
sPrefix | The prefix that should be removed. |
Trim a given prefix.
sPrefix | The prefix that should be removed. |
|
inherited |
Trim this string.
All trailing occurences of characters from s are removed.
s | A list of characters that should be trimmed. |
Trim this string.
All trailing occurences of characters from s are removed. This CString instance is not modified.
s | A list of characters that should be trimmed. |
|
inherited |
Trim a given suffix.
sSuffix | The suffix that should be removed. |
Trim a given suffix.
sSuffix | The suffix that should be removed. |
Referenced by CDir::FillByWildcard().
|
inherited |
Do a wildcard comparision between two strings.
For example, the following returns true: WildCmp("*!?bar@foo", "I_am!~bar@foo");
sWild | The wildcards used for the comparison. |
sString | The string that is used for comparing. |
Referenced by CDir::FillByWildcard().
|
inherited |
Do a wild compare on this string.
sWild | The wildcards used to for the comparison. |
this->WildCmp(sWild, *this);
.