utils_string.h File Reference

Handling string related issues in CCGL. More...

#include <sstream>
#include <vector>
#include "basic.h"

Go to the source code of this file.

Namespaces

namespace  ccgl
 Common Cross-platform Geographic Library (CCGL)
 
namespace  ccgl::utils_string
 String related functions.
 

Functions

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

Detailed Description

Handling string related issues in CCGL.

Remarks
  • 1. 2018-05-02 - lj - Make part of CCGL.
  • 2. 2018-11-12 - lj - Add check and conversion between string and number (int, float, double)
Author
Liangjun Zhu, zlj(at)lreis.ac.cn
Version
1.1