11 #include "regexConfParser.hpp"
24 const bool isVerbosityDebug)
26 map<string, string> regexMap;
27 for (
string line; getline(stream, line); )
37 const bool isVerbosityDebug)
39 map<string, string> regexMap;
40 for (
string line; getline(stream, line); )
54 const std::string& regexDesc,
55 const bool isVerbosityDebug)
57 if (regexDesc[0] ==
'#')
60 istringstream is_line(regexDesc);
62 if (getline(is_line, key,
'='))
64 if(getline(is_line, value))
69 cout <<
"loaded or updated regex definition: " << key <<
" -> \"" << value <<
"\"" << endl;
73 cout <<
"empty regex definition in conf: \"" << regexDesc <<
"\"" << endl;
78 cout <<
"bad regex definition in conf: \"" << regexDesc <<
"\"" << endl;
90 const string& constInput)
92 #define RGX_SEPARATOR_LEFT "__"
93 #define RGX_SEPARATOR_RIGHT RGX_SEPARATOR_LEFT
94 #define RGX_SEPARATOR_LEN 2
96 string input(constInput);
101 while ((pos = input.find(RGX_SEPARATOR_LEFT)) != string::npos)
103 output << input.substr(0, pos);
104 input.erase(0, pos + RGX_SEPARATOR_LEN);
106 if ((pos = input.find(RGX_SEPARATOR_RIGHT)) != string::npos)
108 output << regexMap[input.substr(0, pos)];
109 input.erase(0, pos + RGX_SEPARATOR_LEN);
114 cout <<
"uneven number of delimiters: " << constInput << endl;
void addRegexToMap(RegexMap ®exMap, const std::string ®exDesc, const bool isVerbosityDebug)
Given a single line as 'key=value' pair, create a RegexMap.
RegexMap readConfStreamToMap(std::istringstream &stream, const bool isVerbosityDebug)
Read a string stream and crate a RegexMap.
string replaceTokens(RegexMap ®exMap, const string &constInput)
Removes tokens separated by RGX_SEPARATOR_LEFT in constInput using regexMap.