17 std::vector<std::string>& vec_tokens,
18 const std::string& str_delimiters) {
23 std::string::size_type lastPos =
24 str_string.find_first_not_of(str_delimiters, 0);
27 std::string::size_type pos = str_string.find_first_of(str_delimiters,
30 while(std::string::npos != pos || std::string::npos != lastPos) {
32 vec_tokens.push_back(str_string.substr(lastPos, pos - lastPos));
35 lastPos = str_string.find_first_not_of(str_delimiters, pos);
38 pos = str_string.find_first_of(str_delimiters, lastPos);
46 auto* buf =
new char[str_string.length()];
47 str_string.copy(buf, str_string.length());
49 for(
unsigned int i = 0; i < str_string.length(); ++i)
50 buf[i] = toupper(buf[i]);
52 std::string r(buf, str_string.length());
63 auto* buf =
new char[str_string.length()];
64 str_string.copy(buf, str_string.length());
66 for(
unsigned int i = 0; i < str_string.length(); ++i)
67 buf[i] = tolower(buf[i]);
69 std::string r(buf, str_string.length());
80 const std::string& str_original,
81 const std::string& str_new) {
86 unPos = str_buffer.find(str_original, unPos);
88 if(unPos != std::string::npos) {
91 str_buffer.replace(unPos, str_original.length(), str_new);
93 unPos += str_new.length();
95 if(unPos >= str_buffer.length()) {
96 unPos = std::string::npos;
100 }
while(unPos != std::string::npos);
107 const std::string& str_pattern) {
113 if(::regcomp(&tRegExp, str_pattern.c_str(), REG_EXTENDED | REG_NOSUB) != 0) {
116 nStatus = ::regexec(&tRegExp, str_input.c_str(), 0,
nullptr, 0);
128 size_t unStart = 0, unEnd;
129 std::string strVarName;
134 unStart = str_buffer.find_first_of(
'$');
136 if(unStart != std::string::npos &&
137 unStart+1 < str_buffer.length()) {
140 unEnd = str_buffer.find_first_not_of(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", unStart+1);
142 if(unEnd != std::string::npos) {
144 strVarName = str_buffer.substr(unStart+1, unEnd-unStart-1);
148 strVarName = str_buffer.substr(unStart+1, str_buffer.length()-unStart-1);
151 pchVarValue = ::getenv(strVarName.c_str());
153 if(pchVarValue !=
nullptr) {
156 str_buffer.replace(unStart, strVarName.length()+1, pchVarValue);
160 str_buffer.erase(unStart, strVarName.length()+1);
unsigned int UInt32
32-bit unsigned integer.
The namespace containing all the ARGoS related code.
void Replace(std::string &str_buffer, const std::string &str_original, const std::string &str_new)
Searches into str_buffer for occurrences of str_original and substitutes them with str_new.
std::string & ExpandEnvVariables(std::string &str_buffer)
Searches into str_buffer for occurrences of an environment variable of the form $VAR and substitutes ...
bool MatchPattern(const std::string &str_input, const std::string &str_pattern)
Returns true if str_pattern is matched by str_input.
std::string StringToLowerCase(const std::string &str_string)
Converts a string to lower case.
void Tokenize(const std::string &str_string, std::vector< std::string > &vec_tokens, const std::string &str_delimiters)
Tokenizes the given string according to the wanted delimiters (by default just a " ").
std::string StringToUpperCase(const std::string &str_string)
Converts a string to upper case.