Namespaces | |
namespace | bitpit::utils::string |
Namespace for string utility functions. | |
Functions | |
template<class T , size_t n> | |
void | bitpit::utils::string::convertString (std::string input, std::array< T, n > &output) |
template<class T > | |
void | bitpit::utils::string::convertString (std::string input, std::vector< T > &output) |
template<class T > | |
void | bitpit::utils::string::convertString (std::string input, T &output) |
bool | bitpit::utils::string::getAfterKeyword (const std::string &line, const std::string &key, char del, std::string &result) |
bool | bitpit::utils::string::keywordInString (const std::string &line, const std::string &key) |
std::string | bitpit::utils::string::lfill (int nchars, const std::string &s, char c) |
std::string & | bitpit::utils::string::ltrim (std::string &s) |
std::string | bitpit::utils::string::rfill (int nchars, const std::string &s, char c) |
std::string & | bitpit::utils::string::rtrim (std::string &s) |
std::string & | bitpit::utils::string::trim (std::string &s) |
std::string | bitpit::utils::string::zeroPadNumber (int nchars, int num) |
void bitpit::utils::string::convertString | ( | std::string | input, |
std::array< T, n > & | output ) |
Convertes a string into a arrayof fundamental data type.
If no data of type T can be extracted from the input string a void array with null elements is returned. If the number of elements which can be extracted from the input string is larger than the array size, only the first n elements are saved in the array.
[in] | input | is the input string |
[out] | output | on output contains the values extracted from the input string |
Definition at line 274 of file stringUtils.tpp.
void bitpit::utils::string::convertString | ( | std::string | input, |
std::vector< T > & | output ) |
Convertes a string into a vector of fundamental data type.
If no data of type T can be extracted from the input string a void vector is returned. Values extracted from string are pushed at the end of the vector.
[in] | input | is the input string |
[out] | output | on output contains the values extracted from the input string |
Definition at line 237 of file stringUtils.tpp.
void bitpit::utils::string::convertString | ( | std::string | input, |
T & | output ) |
Convertes a string into fundamental data type.
If no data of type T can be extracted from the input string a 0 value, will be stored in output. If multiple values can be extracted from the input string, only the first value will be saved in output.
[in] | input | is the input string |
[out] | output | on output contains the value extracted from the input string |
Definition at line 195 of file stringUtils.tpp.
bool bitpit::utils::string::getAfterKeyword | ( | const std::string & | line, |
const std::string & | key, | ||
char | del, | ||
std::string & | result ) |
Given an input string containing several fields separated by a delimiter, returns the field after the specified search key. For instance, if the input string is str = "field_1 ; field_2 ; field_3" getAfterKeyword(str, "field_1, ';', output) returns output = "field_2"
[in] | line | input string |
[in] | key | search key |
[in] | del | delimiter char |
[in,out] | result | on output stores the field after the search key |
Definition at line 51 of file stringUtils.cpp.
|
inline |
Check whether a string contains the kwyword or not.
[in] | line | is the input string |
[in] | key | is the search key |
Definition at line 175 of file stringUtils.tpp.
|
inline |
String left-filler. Create a string composed of the input string left-filled with a specified character. E.g. given the input string s = "test", lfill(10, s, '_') will return "______test".
[in] | nchars | is the final length of the string |
[in] | s | is the input string |
[in] | c | is the char used as filler |
Definition at line 115 of file stringUtils.tpp.
|
inline |
Left-trim operator for std::string.
Remove left trailing spaces from string. For instance, if the input string is " test_string ", on output this function returns "test_string "
[in,out] | s | on input contains the input string, on output contains the trimmed string |
Definition at line 46 of file stringUtils.tpp.
|
inline |
String right-filler. Create a string composed of the input string right-filled with a specified character. E.g. given the input string s = "test", rfill(10, s, '_') will return "test______".
[in] | nchars | is the final length of the string |
[in] | s | is the input string |
[in] | c | is the char used as filler |
Definition at line 135 of file stringUtils.tpp.
|
inline |
Right-trim operator for std::string. Remove right blank spaces from string. For instance, if the input string is " test_string ", on output this function returns " test_string"
[in,out] | s | on input contains the input string, on output contains the trimmed string |
Definition at line 72 of file stringUtils.tpp.
|
inline |
Trim operator for std::string. Remove left/right blank spaces from string. For instance, if the input string is " test_string ", on output this function returns "test_string"
[in,out] | s | on input contains the input string, on output contains the trimmed string |
Definition at line 98 of file stringUtils.tpp.
|
inline |
Given an integer, returns a string of length nchars, composed of the input number and nchars - ndigits '0' characters (where ndigits is the number of digits of the input integer) in the following format "000xxx". If ndigits > nchars, the output string will contaiens ndigits characters storing the digits of the input number. For instance, if nchars = 4 and num = 3, this function returns the string "0003". If nchars = 4, and num = 12345, this function returns "12345".
[in] | nchars | is the final length of the string |
[in] | num | is the input integer |
Definition at line 158 of file stringUtils.tpp.