22 #include "regexConfParser.hpp" 35 const bool isVerbosityDebug)
37 map<string, string> regexMap;
38 for (
string line; getline(stream, line); )
48 const bool isVerbosityDebug)
50 map<string, string> regexMap;
51 for (
string line; getline(stream, line); )
65 const std::string& regexDesc,
66 const bool isVerbosityDebug)
68 if (regexDesc[0] ==
'#')
71 istringstream is_line(regexDesc);
73 if (getline(is_line, key,
'='))
75 if(getline(is_line, value))
80 cout <<
"loaded or updated regex definition: " << key <<
" -> \"" << value <<
"\"" << endl;
84 cout <<
"empty regex definition in conf: \"" << regexDesc <<
"\"" << endl;
89 cout <<
"bad regex definition in conf: \"" << regexDesc <<
"\"" << endl;
101 const string& constInput)
103 #define RGX_SEPARATOR_LEFT "__" 104 #define RGX_SEPARATOR_RIGHT RGX_SEPARATOR_LEFT 105 #define RGX_SEPARATOR_LEN 2 107 string input(constInput);
112 while ((pos = input.find(RGX_SEPARATOR_LEFT)) != string::npos)
114 output << input.substr(0, pos);
115 input.erase(0, pos + RGX_SEPARATOR_LEN);
117 if ((pos = input.find(RGX_SEPARATOR_RIGHT)) != string::npos)
119 output << regexMap[input.substr(0, pos)];
120 input.erase(0, pos + RGX_SEPARATOR_LEN);
125 cout <<
"uneven number of delimiters: " << constInput << endl;
RegexMap readConfStreamToMap(std::istringstream &stream, const bool isVerbosityDebug)
Read a string stream and crate a RegexMap.
void addRegexToMap(RegexMap ®exMap, const std::string ®exDesc, const bool isVerbosityDebug)
Given a single line as 'key=value' pair, create a RegexMap.
string replaceTokens(RegexMap ®exMap, const string &constInput)
Removes tokens separated by RGX_SEPARATOR_LEFT in constInput using regexMap.