14 string_formatter::string_formatter(std::unordered_map<
std::string, std::vector<kvp>>
enums)
26 map<string, string> exp_replace_map;
27 map<string, int> enum_replace_map;
29 if (params ==
nullptr && num_of_params > 0)
return false;
31 for (
size_t i = 0;
i < num_of_params;
i++)
33 string regular_exp[4];
34 string replacement[4];
35 stringstream st_regular_exp[4];
36 stringstream st_replacement[4];
38 st_regular_exp[0] <<
"\\{\\b(" <<
i <<
")\\}";
39 regular_exp[0] = st_regular_exp[0].str();
41 st_replacement[0] << params[
i];
42 replacement[0] = st_replacement[0].str();
44 exp_replace_map[regular_exp[0]] = replacement[0];
47 st_regular_exp[1] <<
"\\{\\b(" << i <<
"):x\\}";
48 regular_exp[1] = st_regular_exp[1].str();
50 st_replacement[1] << hex << setw(2) << setfill(
'0') << params[
i];
51 replacement[1] = st_replacement[1].str();
53 exp_replace_map[regular_exp[1]] = replacement[1];
55 st_regular_exp[2] <<
"\\{\\b(" << i <<
"):f\\}";
56 regular_exp[2] = st_regular_exp[2].str();
57 st_replacement[2] << params[
i];
58 replacement[2] = st_replacement[2].str();
59 exp_replace_map[regular_exp[2]] = replacement[2];
62 st_regular_exp[3] <<
"\\{\\b(" << i <<
"),[a-zA-Z]+\\}";
63 regular_exp[3] = st_regular_exp[3].str();
65 enum_replace_map[regular_exp[3]] = params[
i];
68 return replace_params(source, exp_replace_map, enum_replace_map, dest);
73 string source_temp(source);
75 for (
auto exp_replace_it = exp_replace_map.begin(); exp_replace_it != exp_replace_map.end(); exp_replace_it++)
78 regex e(exp_replace_it->first);
79 auto res = regex_replace(back_inserter(destTemp), source_temp.begin(), source_temp.end(),
e, exp_replace_it->second);
80 source_temp = destTemp;
83 for (
auto exp_replace_it = enum_replace_map.begin(); exp_replace_it != enum_replace_map.end(); exp_replace_it++)
86 regex e(exp_replace_it->first);
88 std::regex_search(source_temp, m,
std::regex(e));
92 string st_regular_exp =
"[a-zA-Z]+";
93 regex e1(st_regular_exp);
95 for(
size_t exp = 0; exp<m.size(); exp++)
104 for (
size_t exp = 0; exp < m1.size(); exp++)
109 auto vec =
_enums[enum_name];
112 int val = exp_replace_it->second;
116 regex_replace(back_inserter(destTemp), source_temp.begin(), source_temp.end(), e3,
it->second);
121 s <<
"Protocol Error recognized!\nImproper log message received: " << source_temp
122 <<
", invalid parameter: " << exp_replace_it->second <<
".\n The range of supported values is \n";
123 for_each(vec.begin(), vec.end(), [&
s](
kvp&
entry) { s <<
entry.first <<
":" <<
entry.second <<
" ,"; });
124 std::cout << s.str().c_str() << std::endl;;
126 source_temp = destTemp;
GLsizei const GLchar *const * string
GLenum const GLfloat * params
GLsizei GLsizei GLchar * source