GGS(GenericGEANT4Simulation)Software
2.7.0
|
A namespace with some utility methods for strings. More...
Functions | |
Tokens | Tokenize (const std::string &str, char delimiter= ' ') |
Extracts words from a string. More... | |
std::string | Trim (const std::string &str) |
Trims a string. More... | |
bool | IsInteger (const std::string &str) |
Checks if a string is an a integer. More... | |
bool | IsReal (const std::string &str) |
Checks if a string is a real number. More... | |
bool | IsGlobExpression (const std::string &str) |
Check if the given string is a glob expression. More... | |
std::string | RegexFromGlob (const std::string &str) |
Build a regex starting from a glob expression. More... | |
A namespace with some utility methods for strings.
bool GGSStringUtils::IsGlobExpression | ( | const std::string & | str | ) |
Check if the given string is a glob expression.
A glob expression is recognized by looking at '*' or '?' characters in the string. Other glob wildcards are ignored.
str | The string to be checked. |
Definition at line 122 of file GGSStringUtils.cpp.
bool GGSStringUtils::IsInteger | ( | const std::string & | str | ) |
Checks if a string is an a integer.
Checks if the trimmed input string represents an integer value, possibly with sign.
str | The input string. |
Definition at line 78 of file GGSStringUtils.cpp.
bool GGSStringUtils::IsReal | ( | const std::string & | str | ) |
Checks if a string is a real number.
Checks if the trimmed input string represents a real value, possibly with sign, in the standard notation (e.g. 10.2, not 1.02e1). Note that integer numbers e.g. 10 are real numbers so they are recognized as real by this function.
str | The input string. |
Definition at line 90 of file GGSStringUtils.cpp.
std::string GGSStringUtils::RegexFromGlob | ( | const std::string & | str | ) |
Build a regex starting from a glob expression.
This function manages only the '*' and '?' glob wildcards.
str | The glob expression. |
Definition at line 130 of file GGSStringUtils.cpp.
Tokens GGSStringUtils::Tokenize | ( | const std::string & | str, |
char | delimiter = ' ' |
||
) |
Extracts words from a string.
The string must be a sequence of words separated by a given delimiter. A string portion enclosed within double quotation marks will be treated as a single word (the quotation marks will be removed). If the closing double quotation is missing then a std::runtime_error is thrown.
str | The string to tokenize. |
delimiter | A vector used to return the words in the string. |
std::runtime_error | if a non-terminated double-quotation-enclosed sequence is found. |
Definition at line 13 of file GGSStringUtils.cpp.
std::string GGSStringUtils::Trim | ( | const std::string & | str | ) |
Trims a string.
Removes all leading and trailing invisible characters (spaces, tabs etc.).
str | The input string. |
Definition at line 67 of file GGSStringUtils.cpp.