EventAnalysis  1.0.0
StringUtils.h
Go to the documentation of this file.
1 /*
2  * StringUtils.h
3  *
4  * Created on: 17 Aug 2017
5  * Author: Nicola Mori
6  */
7 
10 #ifndef STRINGUTILS_H_
11 #define STRINGUTILS_H_
12 
13 #include <regex>
14 #include <string>
15 #include <vector>
16 
17 namespace EA {
18 
20 namespace StringUtils {
21 
22 using Tokens = std::vector<std::string>;
23 
36 Tokens Tokenize(const std::string &str, char delimiter = ' ');
37 
45 std::string Trim(const std::string &str);
46 
54 bool IsInteger(const std::string &str);
55 
65 bool IsReal(const std::string &str);
66 
76 bool ToBoolean(const std::string &str);
77 
86 bool IsGlobExpression(const std::string &str);
87 
95 std::string RegexFromGlob(const std::string &str);
96 } // namespace StringUtils
97 
98 } // namespace EA
99 
100 #endif /* STRINGUTILS_H_ */
bool ToBoolean(const std::string &str)
Converts a string into a boolean value.
Definition: StringUtils.cpp:122
bool IsGlobExpression(const std::string &str)
Check if the given string is a glob expression.
Definition: StringUtils.cpp:142
Tokens Tokenize(const std::string &str, char delimiter=' ')
Extracts words from a string.
Definition: StringUtils.cpp:15
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
std::string Trim(const std::string &str)
Trims a string.
Definition: StringUtils.cpp:67
std::vector< std::string > Tokens
Definition: StringUtils.h:22
std::string RegexFromGlob(const std::string &str)
Build a regex starting from a glob expression.
Definition: StringUtils.cpp:150
bool IsReal(const std::string &str)
Checks if a string is a real number.
Definition: StringUtils.cpp:90
bool IsInteger(const std::string &str)
Checks if a string is an a integer.
Definition: StringUtils.cpp:78