ccgl::utils_string Namespace Reference

String related functions. More...

Functions

string GetUpper (const string &str)
 Get Uppercase of given string. More...
 
void TrimSpaces (string &str)
 Trim Both leading and trailing spaces. More...
 
vector< string > SplitString (const string &item, char delimiter)
 Splits the given string based on the given delimiter. More...
 
vector< string > SplitString (const string &item)
 Splits the given string by spaces. More...
 
bool StringMatch (const char *a, const char *b)
 Match char ignore cases. More...
 
bool StringMatch (const string &text1, const string &text2)
 Match Strings in UPPERCASE manner. More...
 
string & Trim (string &s)
 Trim given string's heading and tailing by "<space>,\n,\t,\r". More...
 
void CopyStringMap (const STRING_MAP &in_opts, STRING_MAP &out_opts)
 Copy string map.
 
void UpdateStringMap (STRING_MAP &opts, const string &key, const string &value)
 Add or modify element in a string map.
 
string itoa (vint number)
 Convert a signed integer to a string. More...
 
wstring itow (vint number)
 Convert a signed integer to an unicode string. More...
 
string i64toa (vint64_t number)
 Convert a 64-bits signed integer to a string. More...
 
wstring i64tow (vint64_t number)
 Convert a 64-bits signed integer to an unicode string. More...
 
string utoa (vuint number)
 Convert an unsigned integer to a string. More...
 
wstring utow (vuint number)
 Convert an unsigned integer to an unicode string. More...
 
string u64toa (vuint64_t number)
 Convert a 64-bits unsigned integer to a string. More...
 
wstring u64tow (vuint64_t number)
 Convert a 64-bits unsigned integer to an unicode string. More...
 
string ftoa (double number)
 Convert a 64-bits floating pointer number to a string. More...
 
wstring ftow (double number)
 Convert a 64-bits floating pointer number to an unicode string. More...
 
vint _wtoa (const wchar_t *w, char *a, vint chars)
 
string wtoa (const wstring &wstr)
 Convert an unicode string to an Ansi string. More...
 
vint _atow (const char *a, wchar_t *w, vint chars)
 
wstring atow (const string &astr)
 Convert an Ansi string to an unicode string. More...
 
vint IsInt (const string &num_str, bool &success)
 Check if a string is an signed integer, if ture, return the converted integer. More...
 
vint IsInt (const wstring &num_str, bool &success)
 Check if an unicode string is an signed integer. More...
 
vint64_t IsInt64 (const string &num_str, bool &success)
 Convert a string to an signed 64-bits integer. More...
 
vint64_t IsInt64 (const wstring &num_str, bool &success)
 Convert an unicode string to an signed 64-bits integer. More...
 
vuint IsUInt (const string &num_str, bool &success)
 Convert an Ansi string to an unsigned integer. More...
 
vuint IsUInt (const wstring &num_str, bool &success)
 Convert an Unicode string to an unsigned integer. More...
 
vuint64_t IsUInt64 (const string &num_str, bool &success)
 Convert an Ansi string to a 64-bits unsigned integer. More...
 
vuint64_t IsUInt64 (const wstring &num_str, bool &success)
 Convert an Unicode string to a 64-bits unsigned integer. More...
 
double IsDouble (const string &num_str, bool &success)
 Convert an Ansi string to 64-bits floating point number. More...
 
double IsDouble (const wstring &num_str, bool &success)
 Convert an Ansi string to 64-bits floating point number. More...
 
template<typename T >
string ValueToString (const T &val)
 Convert value to string. More...
 
template<typename T >
bool SplitStringForValues (const string &items, const char delimiter, vector< T > &values)
 Get numeric values by splitting the given string based on the given delimiter.
 
template<typename STRING_T >
bool IsNumber (const STRING_T &num_str)
 Check if a string is a number (integer or float)
 
template<typename STRING_T >
vint ToInt (const STRING_T &num_str)
 Convert an Ansi or Unicode string to an integer.
 
template<typename STRING_T >
vint64_t ToInt64 (const STRING_T &num_str)
 Convert an Ansi or Unicode string to an signed 64-bits integer.
 
template<typename STRING_T >
vuint ToUInt (const STRING_T &num_str)
 Convert an Ansi or Unicode string to an unsigned integer.
 
template<typename STRING_T >
vuint64_t ToUInt64 (const STRING_T &num_str)
 Convert an Ansi or Unicode string to a 64-bits unsigned integer.
 
template<typename STRING_T >
double ToDouble (const STRING_T &num_str)
 Convert an Ansi or Unicode string to a 64-bits floating point number.
 

Detailed Description

String related functions.

Function Documentation

◆ atow()

wstring ccgl::utils_string::atow ( const string &  astr)

Convert an Ansi string to an unicode string.

Parameters
[in]astrThe Ansi string to convert
Returns
The converted unicode string

◆ ftoa()

string ccgl::utils_string::ftoa ( double  number)

Convert a 64-bits floating pointer number to a string.

Parameters
[in]numberThe number to convert
Returns
The converted string

◆ ftow()

wstring ccgl::utils_string::ftow ( double  number)

Convert a 64-bits floating pointer number to an unicode string.

Parameters
[in]numberThe number to convert
Returns
The converted unicode string

◆ GetUpper()

string ccgl::utils_string::GetUpper ( const string &  str)

Get Uppercase of given string.

Parameters
[in]str
Returns
Uppercase string

◆ i64toa()

string ccgl::utils_string::i64toa ( vint64_t  number)

Convert a 64-bits signed integer to a string.

Parameters
[in]numberThe number to convert
Returns
The converted string

◆ i64tow()

wstring ccgl::utils_string::i64tow ( vint64_t  number)

Convert a 64-bits signed integer to an unicode string.

Parameters
[in]numberThe number to convert
Returns
The converted unicode string

◆ IsDouble() [1/2]

double ccgl::utils_string::IsDouble ( const string &  num_str,
bool &  success 
)

Convert an Ansi string to 64-bits floating point number.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsDouble() [2/2]

double ccgl::utils_string::IsDouble ( const wstring &  num_str,
bool &  success 
)

Convert an Ansi string to 64-bits floating point number.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsInt() [1/2]

vint ccgl::utils_string::IsInt ( const string &  num_str,
bool &  success 
)

Check if a string is an signed integer, if ture, return the converted integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsInt() [2/2]

vint ccgl::utils_string::IsInt ( const wstring &  num_str,
bool &  success 
)

Check if an unicode string is an signed integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsInt64() [1/2]

vint64_t ccgl::utils_string::IsInt64 ( const string &  num_str,
bool &  success 
)

Convert a string to an signed 64-bits integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsInt64() [2/2]

vint64_t ccgl::utils_string::IsInt64 ( const wstring &  num_str,
bool &  success 
)

Convert an unicode string to an signed 64-bits integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsUInt() [1/2]

vuint ccgl::utils_string::IsUInt ( const string &  num_str,
bool &  success 
)

Convert an Ansi string to an unsigned integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsUInt() [2/2]

vuint ccgl::utils_string::IsUInt ( const wstring &  num_str,
bool &  success 
)

Convert an Unicode string to an unsigned integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsUInt64() [1/2]

vuint64_t ccgl::utils_string::IsUInt64 ( const string &  num_str,
bool &  success 
)

Convert an Ansi string to a 64-bits unsigned integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ IsUInt64() [2/2]

vuint64_t ccgl::utils_string::IsUInt64 ( const wstring &  num_str,
bool &  success 
)

Convert an Unicode string to a 64-bits unsigned integer.

Parameters
[in]num_strThe string to convert
[out]successReturn true if succeed
Returns
The converted number if succeed, otherwise the result is undefined.

◆ itoa()

string ccgl::utils_string::itoa ( vint  number)

Convert a signed integer to a string.

Parameters
[in]numberThe number to convert
Returns
The converted string

◆ itow()

wstring ccgl::utils_string::itow ( vint  number)

Convert a signed integer to an unicode string.

Parameters
[in]numberThe number to convert
Returns
The converted unicode string

◆ SplitString() [1/2]

vector< string > ccgl::utils_string::SplitString ( const string &  item)

Splits the given string by spaces.

Parameters
[in]itemstring information
Returns
The split strings vector

◆ SplitString() [2/2]

vector< string > ccgl::utils_string::SplitString ( const string &  item,
char  delimiter 
)

Splits the given string based on the given delimiter.

Parameters
[in]itemstring information
[in]delimiterchar
Returns
The split strings vector

◆ StringMatch() [1/2]

bool ccgl::utils_string::StringMatch ( const char *  a,
const char *  b 
)

Match char ignore cases.

Parameters
[in]a,bchar*
Returns
true or false
See also
StringMatch()

◆ StringMatch() [2/2]

bool ccgl::utils_string::StringMatch ( const string &  text1,
const string &  text2 
)

Match Strings in UPPERCASE manner.

Parameters
[in]text1,text2
Returns
true or false

◆ Trim()

string & ccgl::utils_string::Trim ( string &  s)

Trim given string's heading and tailing by "<space>,\n,\t,\r".

See also
TrimSpaces
Parameters
[in]sstring information
Returns
Trimmed string

◆ TrimSpaces()

void ccgl::utils_string::TrimSpaces ( string &  str)

Trim Both leading and trailing spaces.

See also
Trim
Parameters
[in]strstring

◆ u64toa()

string ccgl::utils_string::u64toa ( vuint64_t  number)

Convert a 64-bits unsigned integer to a string.

Parameters
[in]numberThe number to convert
Returns
The converted string

◆ u64tow()

wstring ccgl::utils_string::u64tow ( vuint64_t  number)

Convert a 64-bits unsigned integer to an unicode string.

Parameters
[in]numberThe number to convert
Returns
The converted unicode string

◆ utoa()

string ccgl::utils_string::utoa ( vuint  number)

Convert an unsigned integer to a string.

Parameters
[in]numberThe number to convert
Returns
The converted string

◆ utow()

wstring ccgl::utils_string::utow ( vuint  number)

Convert an unsigned integer to an unicode string.

Parameters
[in]numberThe number to convert
Returns
The converted unicode string

◆ ValueToString()

template<typename T >
string ccgl::utils_string::ValueToString ( const T &  val)

Convert value to string.

Parameters
[in]valvalue, e.g., a int, or float
Returns
converted string

◆ wtoa()

string ccgl::utils_string::wtoa ( const wstring &  wstr)

Convert an unicode string to an Ansi string.

Parameters
[in]wstrThe unicode string to convert
Returns
The converted ansi string