libcamgm
|
Classes | |
struct | SafeBuf |
Functions | |
std::string | toString (bool b) |
template<class _T > | |
std::string | asString (const _T &t) |
template<> | |
std::string | asString (const std::string &t) |
std::string | form (const char *format,...) |
std::string | strerror (int errno_r) |
std::string | gsub (const std::string &sData, const std::string &sFrom, const std::string &sTo) |
Looks for text in a string and replaces it. More... | |
std::string & | replaceAll (std::string &str, const std::string &from, const std::string &to) |
Looks for text in string and replaces it in place. More... | |
std::string | stripFirstWord (std::string &line, const bool ltrim_first) |
std::string | stripLastWord (std::string &line, const bool rtrim_first) |
std::string | getline (std::istream &str, bool trim=false) |
std::string | getline (std::istream &str, const Trim trim_r) |
std::string representation of number. | |
std::string | numstring (char n, int w=0) |
std::string | numstring (unsigned char n, int w=0) |
std::string | numstring (short n, int w=0) |
std::string | numstring (unsigned short n, int w=0) |
std::string | numstring (int n, int w=0) |
std::string | numstring (unsigned n, int w=0) |
std::string | numstring (long n, int w=0) |
std::string | numstring (unsigned long n, int w=0) |
std::string | numstring (long long n, int w=0) |
std::string | numstring (unsigned long long n, int w=0) |
std::string representation of number as hex value with leading '0x'. | |
Optional second argument sets the minimal string width (0 padded). Negative values will cause the number to be left adjusted within the string. Default width is 10 (4 for char). hexstring(42) -> "0x0000002a" hexstring(42, 4) -> "0x2a" hexstring(42,-4) -> "0x2a" | |
std::string | hexstring (char n, int w=4) |
std::string | hexstring (unsigned char n, int w=4) |
std::string | hexstring (short n, int w=10) |
std::string | hexstring (unsigned short n, int w=10) |
std::string | hexstring (int n, int w=10) |
std::string | hexstring (unsigned n, int w=10) |
std::string | hexstring (long n, int w=10) |
std::string | hexstring (unsigned long n, int w=10) |
std::string | hexstring (long long n, int w=0) |
std::string | hexstring (unsigned long long n, int w=0) |
std::string representation of number as octal value with leading '0'. | |
Optional second argument sets the minimal string width (0 padded). Negative values will cause the number to be left adjusted within the string. Default width is 5 (4 for char). octstring(42) -> "00052" octstring(42, 4) -> "0052" octstring(42,-4) -> "052 " | |
std::string | octstring (char n, int w=4) |
std::string | octstring (unsigned char n, int w=4) |
std::string | octstring (short n, int w=5) |
std::string | octstring (unsigned short n, int w=5) |
std::string | octstring (int n, int w=5) |
std::string | octstring (unsigned n, int w=5) |
std::string | octstring (long n, int w=5) |
std::string | octstring (unsigned long n, int w=5) |
std::string | octstring (long long n, int w=0) |
std::string | octstring (unsigned long long n, int w=0) |
template<typename _It > | |
_It | strtonum (const C_Str &str) |
template<> | |
short | strtonum (const C_Str &str) |
template<> | |
int | strtonum (const C_Str &str) |
template<> | |
long | strtonum (const C_Str &str) |
template<> | |
long long | strtonum (const C_Str &str) |
template<> | |
unsigned short | strtonum (const C_Str &str) |
template<> | |
unsigned | strtonum (const C_Str &str) |
template<> | |
unsigned long | strtonum (const C_Str &str) |
template<> | |
unsigned long long | strtonum (const C_Str &str) |
template<typename _It > | |
_It | strtonum (const C_Str &str, _It &i) |
bool | strToTrue (const C_Str &str) |
bool | strToFalse (const C_Str &str) |
bool | strToBool (const C_Str &str, bool default_r) |
bool | strToBoolNodefault (const C_Str &str, bool &return_r) |
Split. | |
template<class _OutputIterator > | |
unsigned | split (const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t") |
template<class _OutputIterator > | |
unsigned | splitEscaped (const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false) |
template<class _OutputIterator > | |
unsigned | splitFields (const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=":") |
template<class _OutputIterator > | |
unsigned | splitFieldsEscaped (const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=":") |
Join. | |
template<class _Iterator > | |
std::string | join (_Iterator begin, _Iterator end, const C_Str &sep_r=" ") |
template<class _Container > | |
std::string | join (const _Container &cont_r, const C_Str &sep_r=" ") |
template<class _Iterator > | |
std::string | joinEscaped (_Iterator begin, _Iterator end, const char sep_r= ' ') |
std::string | escape (const std::string &str_r, const char c= ' ') |
Hexencode. | |
Encode all characters other than [a-zA-Z0-9] as XX. This includes the % character itself, which becomes %25. | |
std::string | hexencode (const C_Str &str_r) |
std::string | hexdecode (const C_Str &str_r) |
Case conversion. | |
std::string | toLower (const std::string &s) |
std::string | toLower (const char *s) |
std::string | toUpper (const std::string &s) |
std::string | toUpper (const char *s) |
Case insensitive comparison. | |
int | compareCI (const C_Str &lhs, const C_Str &rhs) |
Locate substring. | |
bool | contains (const C_Str &str_r, const C_Str &val_r) |
bool | containsCI (const C_Str &str_r, const C_Str &val_r) |
std::string prefix/suffix handling. | |
bool | hasPrefix (const C_Str &str_r, const C_Str &prefix_r) |
bool | hasPrefixCI (const C_Str &str_r, const C_Str &prefix_r) |
std::string | stripPrefix (const C_Str &str_r, const C_Str &prefix_r) |
bool | hasSuffix (const C_Str &str_r, const C_Str &suffix_r) |
bool | hasSuffixCI (const C_Str &str_r, const C_Str &suffix_r) |
std::string | stripSuffix (const C_Str &str_r, const C_Str &suffix_r) |
bool | startsWith (const C_Str &str_r, const C_Str &prefix_r) |
bool | startsWithCI (const C_Str &str_r, const C_Str &prefix_r) |
bool | endsWith (const C_Str &str_r, const C_Str &prefix_r) |
bool | endsWithCI (const C_Str &str_r, const C_Str &prefix_r) |
Trimming whitepace. | |
| |
enum | Trim { NO_TRIM = 0x00, L_TRIM = 0x01, R_TRIM = 0x02, TRIM = (L_TRIM|R_TRIM) } |
std::string | trim (const std::string &s, const Trim trim_r=TRIM) |
std::string | ltrim (const std::string &s) |
std::string | rtrim (const std::string &s) |
std::string related utilities and ZYPP_STR_REGEX.
enum ca_mgm::str::Trim |
|
inline |
|
inline |
References form(), and strerror().
Referenced by join(), and joinEscaped().
Locate substring case sensitive.
Locate substring case insensitive.
alias for hasSuffix
References hasSuffix().
Return whether str_r has prefix prefix_r.
References hasSuffixCI().
std::string ca_mgm::str::escape | ( | const std::string & | str_r, |
const char | c = ' ' |
||
) |
Escape desired character c using a backslash.
For use when printing c separated values, and where joinEscaped() is too heavy.
Referenced by joinEscaped().
std::string ca_mgm::str::form | ( | const char * | format, |
... | |||
) |
Printf style construction of std::string.
Referenced by asString(), ca_mgm::LogControl::ShortLineFormater::format(), ca_mgm::ExceptionDetail::Errno< exType >::format(), hexstring(), numstring(), and octstring().
std::string ca_mgm::str::getline | ( | std::istream & | str, |
bool | trim = false |
||
) |
std::string ca_mgm::str::gsub | ( | const std::string & | sData, |
const std::string & | sFrom, | ||
const std::string & | sTo | ||
) |
Looks for text in a string and replaces it.
Referenced by strToBoolNodefault().
Return whether str_r has prefix prefix_r.
References ca_mgm::C_Str::size().
Referenced by startsWith(), and stripPrefix().
Return whether str_r has prefix prefix_r.
References ca_mgm::C_Str::size().
Referenced by startsWithCI().
Return whether str_r has suffix suffix_r.
References ca_mgm::C_Str::size().
Referenced by endsWith(), and stripSuffix().
Return whether str_r has prefix prefix_r.
References ca_mgm::C_Str::size().
Referenced by endsWithCI().
std::string ca_mgm::str::hexdecode | ( | const C_Str & | str_r | ) |
Decode hexencoded XX sequences.
Referenced by joinEscaped().
std::string ca_mgm::str::hexencode | ( | const C_Str & | str_r | ) |
Encode all characters other than [a-zA-Z0-9] as XX. This includes the % character itself, which becomes %25.
Referenced by joinEscaped().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
std::string ca_mgm::str::join | ( | _Iterator | begin, |
_Iterator | end, | ||
const C_Str & | sep_r = " " |
||
) |
Join strings using separator sep_r (defaults to BLANK).
References asString().
std::string ca_mgm::str::join | ( | const _Container & | cont_r, |
const C_Str & | sep_r = " " |
||
) |
Join strings using separator sep_r (defaults to BLANK).
std::string ca_mgm::str::joinEscaped | ( | _Iterator | begin, |
_Iterator | end, | ||
const char | sep_r = ' ' |
||
) |
Join strings using separator sep_r, quoting or escaping the values. Separator defaults to BLANK. Use splitEscaped to restore the values.
References asString(), escape(), for_, hexdecode(), hexencode(), and toLower().
|
inline |
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form().
|
inline |
References form(), and strtonum().
std::string& ca_mgm::str::replaceAll | ( | std::string & | str, |
const std::string & | from, | ||
const std::string & | to | ||
) |
Looks for text in string and replaces it in place.
Referenced by splitEscaped(), and strToBoolNodefault().
|
inline |
To define how to trim.
References getline(), R_TRIM, stripFirstWord(), stripLastWord(), and trim().
unsigned ca_mgm::str::split | ( | const C_Str & | line_r, |
_OutputIterator | result_r, | ||
const C_Str & | sepchars_r = " \t" |
||
) |
Split line_r into words. Any sequence of characters in sepchars_r is treated as delimiter. The words are passed to OutputIterator result_r.
unsigned ca_mgm::str::splitEscaped | ( | const C_Str & | line_r, |
_OutputIterator | result_r, | ||
const C_Str & | sepchars_r = " \t" , |
||
bool | withEmpty = false |
||
) |
Split line_r into words with respect to escape delimeters. Any sequence of characters in sepchars_r is treated as delimiter if not inside "" or "" or escaped by \, but not \. The words are passed to OutputIterator result_r.
References replaceAll().
Referenced by splitFieldsEscaped().
unsigned ca_mgm::str::splitFields | ( | const C_Str & | line_r, |
_OutputIterator | result_r, | ||
const C_Str & | sepchars_r = ":" |
||
) |
Split line_r into fields. Any single character in sepchars_r is treated as a field separator. The words are passed to OutputIterator result_r.
unsigned ca_mgm::str::splitFieldsEscaped | ( | const C_Str & | line_r, |
_OutputIterator | result_r, | ||
const C_Str & | sepchars_r = ":" |
||
) |
Split line_r into fields handling also escaped separators.
References splitEscaped().
alias for hasPrefix
References hasPrefix().
alias for hasPrefixCI
References hasPrefixCI().
std::string ca_mgm::str::strerror | ( | int | errno_r | ) |
Return string describing the error_r code. Like strerror, but the numerical value is included in the string as well.
Referenced by asString(), ca_mgm::ExceptionDetail::Errno< exType >::format(), and ca_mgm::ExceptionDetail::Errno< exType >::simple().
std::string ca_mgm::str::stripFirstWord | ( | std::string & | line, |
const bool | ltrim_first | ||
) |
Referenced by rtrim().
std::string ca_mgm::str::stripLastWord | ( | std::string & | line, |
const bool | rtrim_first | ||
) |
Referenced by rtrim().
Strip a prefix_r from str_r and return the resulting string.
References ca_mgm::C_Str::c_str(), hasPrefix(), and ca_mgm::C_Str::size().
Strip a suffix_r from str_r and return the resulting string.
References ca_mgm::C_Str::c_str(), hasSuffix(), and ca_mgm::C_Str::size().
|
inline |
Parse str
into a bool depending on the default value. If the default
is true, look for a legal false
string. If the default
is false, look for a legal true
string.
References strToFalse(), and strToTrue().
|
inline |
Parse str
into a bool if it's a legal true
or false
string. If str
is not a recognized true
or false
string, return_r is left unchanged.
References gsub(), replaceAll(), strToFalse(), and strToTrue().
bool ca_mgm::str::strToFalse | ( | const C_Str & | str | ) |
Return false
if str is 0, false, no, off
.
Referenced by strToBool(), strToBoolNodefault(), and strtonum().
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
Parsing numbers from string. std::string to integer type determined by template arg.
|
inline |
std::string to integer type detemined 2nd function arg i.
References strToFalse(), and strToTrue().
Referenced by octstring().
bool ca_mgm::str::strToTrue | ( | const C_Str & | str | ) |
Parsing boolean from string.Return true
if str is 1, true, yes, on
(or a nonzero number).
Referenced by strToBool(), strToBoolNodefault(), and strtonum().
std::string ca_mgm::str::toLower | ( | const std::string & | s | ) |
Return lowercase version of s
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References toUpper().
Referenced by joinEscaped().
|
inline |
Global asString() that works with std::string too
Referenced by ca_mgm::path::PathName::asString().
std::string ca_mgm::str::toUpper | ( | const std::string & | s | ) |
Return uppercase version of s
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Referenced by toLower().