Namespace for formatting functions. More...
Functions | |
| bool | is_digit (char c) | 
| Check if is digit.  More... | |
| bool | wild_card_match (const char *str, const char *pattern) | 
| Match string with wildcard. Match string with wildcard pattern, '*' and '?' supported.  More... | |
| std::string | ltrim (std::string str) | 
| Left trim whitespace.  More... | |
| std::string | rtrim (std::string str) | 
| Right trim whitespace.  More... | |
| std::string | trim (std::string str) | 
| Left and right trim whitespace.  More... | |
| std::string | lstrip (std::string str, std::string what) | 
| Strip specified sub-string from left. The strip will do strict check from left, even whitespace.  More... | |
| std::string | rstrip (std::string str, std::string what) | 
| Strip specified sub-string from right. The strip will do strict check from right, even whitespace.  More... | |
| std::string | lskip (std::string str, std::string delim) | 
| Skip from left until delimiter string found.  More... | |
| std::string | rskip (std::string str, std::string delim) | 
| Skip from right until delimiter string found.  More... | |
| std::string | rskip_all (std::string str, std::string delim) | 
| Skip from right, remove all stuff right to left-most delim.  More... | |
| std::vector< std::string > | split (const std::string s, char delim= ' ') | 
| Split string into parts with specified single char delimiter.  More... | |
| std::vector< std::string > | split (const std::string s, std::string delim) | 
| Split string into parts with specified string delimiter. The entire delimiter must be matched exactly.  More... | |
| std::vector< std::string > | split_multi_delims (const std::string s, std::string delims) | 
| Split string into parts with multiple single char delimiter.  More... | |
| std::vector< std::string > | split_whitespace (const std::string s) | 
| Special case to split_multi_delims(), split all whitespace.  More... | |
| std::pair< std::string, std::string > | split_first_occurance (const std::string s, char delim) | 
| Split string in two parts with specified delim.  More... | |
| std::vector< std::string > & | erase_empty (std::vector< std::string > &vec) | 
| Go through vector and erase empty ones. Erase in-place in vector.  More... | |
| std::string | join (std::vector< std::string > elems, char delim) | 
| Concatenates a std::vector of strings into a string with delimiters.  More... | |
| bool | starts_with (const std::string &str, const std::string &start) | 
| Check if string starts with specified sub-string.  More... | |
| bool | ends_with (const std::string &str, const std::string &end) | 
| Check if string ends with specified sub-string.  More... | |
| std::string & | replace_all (std::string &str, char replaceWhat, char replaceWith) | 
| Replace all from one to another sub-string, char version.  More... | |
| std::string & | replace_all (std::string &str, const std::string &replaceWhat, const std::string &replaceWith) | 
| Replace all from one to another sub-string.  More... | |
| void | replace_first_with_escape (std::string &str, const std::string &replaceWhat, const std::string &replaceWith) | 
| Replace first occurance of one string with specified another string. Replace in-place.  More... | |
| void | replace_all_with_escape (std::string &str, const std::string &replaceWhat, const std::string &replaceWith) | 
| Replace every occurance of one string with specified another string. Replace in-place.  More... | |
| void | replace_sequential_with_escape (std::string &str, const std::string &replaceWhat, const std::vector< std::string > &replaceWith) | 
| Replace every occurance of one string with specified list of strings sequentially. Replace in-place.  More... | |
| bool | str_equals (const char *s1, const char *s2) | 
| Compare c style raw string Will take care of string not ends with '\0'(ignore it), which is unsafe using strcmp().  More... | |
| std::string | to_lower_ascii (std::string mixed) | 
| Convert string to lower case. Support ASCII characters only. Unicode string will trigger undefined behavior.  More... | |
| std::string | to_upper_ascii (std::string mixed) | 
| Convert string to upper case. Support ASCII characters only. Unicode string will trigger undefined behavior.  More... | |
| std::u16string | utf8_to_utf16 (std::string u8str) | 
| C++ 11 UTF-8 string to UTF-16 string.  More... | |
| std::string | utf16_to_utf8 (std::u16string u16str) | 
| C++ 11 UTF-16 string to UTF-8 string.  More... | |
| std::u32string | utf8_to_utf32 (std::string u8str) | 
| C++ 11 UTF-8 string to UTF-32 string.  More... | |
| std::string | utf32_to_utf8 (std::u32string u32str) | 
| C++ 11 UTF-32 string to UTF-8 string.  More... | |
| std::string | int_to_zero_pad_str (int num, int length) | 
| Convert int to left zero padded string.  More... | |
| template<typename Arg > | |
| void | format_string (std::string &fmt, const Arg &last) | 
| Format function to replace each {} with templated type variable.  More... | |
| template<typename Arg , typename... Args> | |
| void | format_string (std::string &fmt, const Arg ¤t, const Args &...more) | 
| Vairadic variable version of format function to replace each {} with templated type variable.  More... | |
Detailed Description
Namespace for formatting functions.
Function Documentation
| bool zz::fmt::ends_with | ( | const std::string & | str, | 
| const std::string & | end | ||
| ) | 
Check if string ends with specified sub-string.
- Parameters
 - 
  
str end  
- Returns
 - True if success
 
| std::vector< std::string > & zz::fmt::erase_empty | ( | std::vector< std::string > & | vec | ) | 
Go through vector and erase empty ones. Erase in-place in vector.
- Parameters
 - 
  
vec  
- Returns
 - Clean vector with no empty elements.
 
      
  | 
  inline | 
Format function to replace each {} with templated type variable.
- Parameters
 - 
  
fmt Original string with place-holder {} last The last variable in variadic template function  
      
  | 
  inline | 
Vairadic variable version of format function to replace each {} with templated type variable.
- Parameters
 - 
  
fmt Original string with place-holder {} current The current variable to be converted ... more Variadic variables to be templated.  
      
  | 
  inline | 
Convert int to left zero padded string.
- Parameters
 - 
  
num Integer number length String length  
- Returns
 - Zero-padded string
 
| bool zz::fmt::is_digit | ( | char | c | ) | 
Check if is digit.
- Parameters
 - 
  
c  
- Returns
 
| std::string zz::fmt::join | ( | std::vector< std::string > | elems, | 
| char | delim | ||
| ) | 
Concatenates a std::vector of strings into a string with delimiters.
- Parameters
 - 
  
elems delim  
- Returns
 - Concatenated string
 
| std::string zz::fmt::lskip | ( | std::string | str, | 
| std::string | delim | ||
| ) | 
Skip from left until delimiter string found.
- Parameters
 - 
  
str delim  
- Returns
 - Skipped string
 
| std::string zz::fmt::lstrip | ( | std::string | str, | 
| std::string | what | ||
| ) | 
Strip specified sub-string from left. The strip will do strict check from left, even whitespace.
- Parameters
 - 
  
str Original string what What to be stripped  
- Returns
 - Stripped string
 
| std::string zz::fmt::ltrim | ( | std::string | str | ) | 
Left trim whitespace.
- Parameters
 - 
  
str  
- Returns
 - Trimed string
 
| std::string & zz::fmt::replace_all | ( | std::string & | str, | 
| char | replaceWhat, | ||
| char | replaceWith | ||
| ) | 
Replace all from one to another sub-string, char version.
- Parameters
 - 
  
str replaceWhat replaceWith  
- Returns
 - Reference to modified string
 
| std::string & zz::fmt::replace_all | ( | std::string & | str, | 
| const std::string & | replaceWhat, | ||
| const std::string & | replaceWith | ||
| ) | 
Replace all from one to another sub-string.
- Parameters
 - 
  
str replaceWhat replaceWith  
- Returns
 - Reference to modified string
 
| void zz::fmt::replace_all_with_escape | ( | std::string & | str, | 
| const std::string & | replaceWhat, | ||
| const std::string & | replaceWith | ||
| ) | 
Replace every occurance of one string with specified another string. Replace in-place.
- Parameters
 - 
  
str replaceWhat What substring to be replaced. replaceWith What string to replace.  
| void zz::fmt::replace_first_with_escape | ( | std::string & | str, | 
| const std::string & | replaceWhat, | ||
| const std::string & | replaceWith | ||
| ) | 
Replace first occurance of one string with specified another string. Replace in-place.
- Parameters
 - 
  
str replaceWhat What substring to be replaced. replaceWith What string to replace.  
| void zz::fmt::replace_sequential_with_escape | ( | std::string & | str, | 
| const std::string & | replaceWhat, | ||
| const std::vector< std::string > & | replaceWith | ||
| ) | 
Replace every occurance of one string with specified list of strings sequentially. Replace in-place.
- Parameters
 - 
  
str replaceWhat What substring to be replaced. replaceWith Vector of what strings to replace one by one.  
| std::string zz::fmt::rskip | ( | std::string | str, | 
| std::string | delim | ||
| ) | 
Skip from right until delimiter string found.
- Parameters
 - 
  
str delim  
- Returns
 - Skipped string
 
| std::string zz::fmt::rskip_all | ( | std::string | str, | 
| std::string | delim | ||
| ) | 
Skip from right, remove all stuff right to left-most delim.
- Parameters
 - 
  
str delim  
- Returns
 - Skipped string
 
| std::string zz::fmt::rstrip | ( | std::string | str, | 
| std::string | what | ||
| ) | 
Strip specified sub-string from right. The strip will do strict check from right, even whitespace.
- Parameters
 - 
  
str Original string what What to be stripped  
- Returns
 - Stripped string
 
| std::string zz::fmt::rtrim | ( | std::string | str | ) | 
Right trim whitespace.
- Parameters
 - 
  
str  
- Returns
 - Trimed string
 
| std::vector< std::string > zz::fmt::split | ( | const std::string | s, | 
| char | delim = ' '  | 
        ||
| ) | 
Split string into parts with specified single char delimiter.
- Parameters
 - 
  
s delim  
- Returns
 - A std::vector of parts in std::string
 
| std::vector< std::string > zz::fmt::split | ( | const std::string | s, | 
| std::string | delim | ||
| ) | 
Split string into parts with specified string delimiter. The entire delimiter must be matched exactly.
- Parameters
 - 
  
s delim  
- Returns
 - A std::vector of parts in std::string
 
| std::pair< std::string, std::string > zz::fmt::split_first_occurance | ( | const std::string | s, | 
| char | delim | ||
| ) | 
Split string in two parts with specified delim.
- Parameters
 - 
  
s delim  
- Returns
 - A std::pair of std::string, ret.first = first part, ret.second = second part
 
| std::vector< std::string > zz::fmt::split_multi_delims | ( | const std::string | s, | 
| std::string | delims | ||
| ) | 
Split string into parts with multiple single char delimiter.
- Parameters
 - 
  
s delim A std::string contains multiple single char delimiter, e.g.(' 
') 
- Returns
 - A std::vector of parts in std::string
 
| std::vector< std::string > zz::fmt::split_whitespace | ( | const std::string | s | ) | 
Special case to split_multi_delims(), split all whitespace.
- Parameters
 - 
  
s  
- Returns
 - A std::vector of parts in std::string
 
| bool zz::fmt::starts_with | ( | const std::string & | str, | 
| const std::string & | start | ||
| ) | 
Check if string starts with specified sub-string.
- Parameters
 - 
  
str start  
- Returns
 - True if success
 
| bool zz::fmt::str_equals | ( | const char * | s1, | 
| const char * | s2 | ||
| ) | 
Compare c style raw string Will take care of string not ends with '\0'(ignore it), which is unsafe using strcmp().
- Parameters
 - 
  
s1 s2  
- Returns
 - True if same
 
| std::string zz::fmt::to_lower_ascii | ( | std::string | mixed | ) | 
Convert string to lower case. Support ASCII characters only. Unicode string will trigger undefined behavior.
- Parameters
 - 
  
mixed Mixed case string  
- Returns
 - Lower case string.
 
| std::string zz::fmt::to_upper_ascii | ( | std::string | mixed | ) | 
Convert string to upper case. Support ASCII characters only. Unicode string will trigger undefined behavior.
- Parameters
 - 
  
mixed Mixed case string  
- Returns
 - Upper case string.
 
| std::string zz::fmt::trim | ( | std::string | str | ) | 
Left and right trim whitespace.
- Parameters
 - 
  
str  
- Returns
 - Trimed string
 
| std::string zz::fmt::utf16_to_utf8 | ( | std::u16string | u16str | ) | 
C++ 11 UTF-16 string to UTF-8 string.
- Parameters
 - 
  
u16str UTF-16 string  
- Returns
 - UTF-8 string
 
| std::string zz::fmt::utf32_to_utf8 | ( | std::u32string | u32str | ) | 
C++ 11 UTF-32 string to UTF-8 string.
- Parameters
 - 
  
u32str UTF-32 string  
- Returns
 - UTF-8 string
 
| std::u16string zz::fmt::utf8_to_utf16 | ( | std::string | u8str | ) | 
C++ 11 UTF-8 string to UTF-16 string.
- Parameters
 - 
  
u8str UTF-8 string  
- Returns
 - UTF-16 string
 
| std::u32string zz::fmt::utf8_to_utf32 | ( | std::string | u8str | ) | 
C++ 11 UTF-8 string to UTF-32 string.
- Parameters
 - 
  
u8str UTF-8 string  
- Returns
 - UTF-32 string
 
| bool zz::fmt::wild_card_match | ( | const char * | str, | 
| const char * | pattern | ||
| ) | 
Match string with wildcard. Match string with wildcard pattern, '*' and '?' supported.
- Parameters
 - 
  
str pattern  
- Returns
 - True for success match
 
 1.8.9.1