17 char endliteralDelimiter =
'\0';
19 while (str[iChar] ==
' ' || str[iChar] ==
'\t')
25 while (iChar < str.size()) {
28 bool quotedText =
false;
29 if (str[iChar] ==
'\"') {
31 endliteralDelimiter =
'\"';
33 iLast = str.find_first_of(
'\"', iChar);
35 else if (str[iChar] ==
'{') {
37 endliteralDelimiter =
'}';
39 iLast = str.find_first_of(
'}', iChar);
42 iLast = str.find_first_of(delimiter, iChar + 1);
44 if (iLast != std::string::npos) {
46 token = str.substr(iChar, iLast - iChar);
47 if (str[iLast] == endliteralDelimiter) {
56 throw std::runtime_error(std::string(
"[GGSStringUtils::Tokenize] Missing closing ") + endliteralDelimiter);
60 token = str.substr(iChar);
63 tokens.push_back(token);
65 iChar = str.find_first_not_of(delimiter, iLast);
72 std::string retStr = str;
73 retStr.erase(retStr.begin(), std::find_if(retStr.begin(), retStr.end(), [](
int ch) {
74 return !(std::isblank(static_cast<unsigned int>(ch)));
76 retStr.erase(std::find_if(retStr.rbegin(), retStr.rend(), [](
int ch) {
77 return !(std::isblank(static_cast<unsigned int>(ch)));
78 }).base(), retStr.end());
83 std::string trimmedStr =
Trim(str);
84 if (trimmedStr.empty() || ((!isdigit(trimmedStr[0])) && (trimmedStr[0] !=
'-') && (trimmedStr[0] !=
'+')))
86 for (
unsigned int iChar = 1; iChar < trimmedStr.size(); iChar++) {
87 if (!isdigit(trimmedStr[iChar])) {
95 std::string trimmedStr =
Trim(str);
96 if (trimmedStr.empty() || ((!isdigit(trimmedStr[0])) && (trimmedStr[0] !=
'-') && (trimmedStr[0] !=
'+')))
98 bool hasPoint =
false;
100 for (
unsigned int iChar = 1; iChar < trimmedStr.size(); iChar++) {
101 if (!isdigit(trimmedStr[iChar])) {
102 if (trimmedStr[iChar] ==
'.') {
108 else if (trimmedStr[iChar] ==
'e') {
115 if (iChar >= trimmedStr.size()
116 || (!isdigit(trimmedStr[iChar]) && (trimmedStr[iChar] !=
'-') && (trimmedStr[iChar] !=
'+'))) {
129 if (str.find(
'*') != std::string::npos || str.find(
'?') != std::string::npos) {
138 static std::string regexStr;
140 std::string::size_type n = 0;
141 while ((n = regexStr.find(
".", n)) != std::string::npos) {
142 regexStr.replace(n, 1,
"\\.");
146 while ((n = regexStr.find(
"*", n)) != std::string::npos) {
147 regexStr.replace(n, 1,
".*");
150 std::replace(regexStr.begin(), regexStr.end(),
'?',
'.');
std::string RegexFromGlob(const std::string &str)
Build a regex starting from a glob expression.
Tokens Tokenize(const std::string &str, char delimiter= ' ')
Extracts words from a string.
bool IsGlobExpression(const std::string &str)
Check if the given string is a glob expression.
bool IsInteger(const std::string &str)
Checks if a string is an a integer.
bool IsReal(const std::string &str)
Checks if a string is a real number.
std::string Trim(const std::string &str)
Trims a string.