16 fw_string_formatter::fw_string_formatter(std::unordered_map<
std::string, std::vector<kvp>>
enums)
28 map<string, string> exp_replace_map;
29 map<string, int> enum_replace_map;
31 if (params ==
nullptr && num_of_params > 0)
return false;
33 for (
size_t i = 0;
i < num_of_params;
i++)
35 string regular_exp[4];
36 string replacement[4];
37 stringstream st_regular_exp[4];
38 stringstream st_replacement[4];
40 st_regular_exp[0] <<
"\\{\\b(" <<
i <<
")\\}";
41 regular_exp[0] = st_regular_exp[0].str();
43 st_replacement[0] << params[
i];
44 replacement[0] = st_replacement[0].str();
46 exp_replace_map[regular_exp[0]] = replacement[0];
49 st_regular_exp[1] <<
"\\{\\b(" << i <<
"):x\\}";
50 regular_exp[1] = st_regular_exp[1].str();
52 st_replacement[1] << hex << setw(2) << setfill(
'0') << params[
i];
53 replacement[1] = st_replacement[1].str();
55 exp_replace_map[regular_exp[1]] = replacement[1];
57 st_regular_exp[2] <<
"\\{\\b(" << i <<
"):f\\}";
58 regular_exp[2] = st_regular_exp[2].str();
59 st_replacement[2] << params[
i];
60 replacement[2] = st_replacement[2].str();
61 exp_replace_map[regular_exp[2]] = replacement[2];
64 st_regular_exp[3] <<
"\\{\\b(" << i <<
"),[a-zA-Z]+\\}";
65 regular_exp[3] = st_regular_exp[3].str();
67 enum_replace_map[regular_exp[3]] = params[
i];
70 return replace_params(source, exp_replace_map, enum_replace_map, dest);
75 string source_temp(source);
77 for (
auto exp_replace_it = exp_replace_map.begin(); exp_replace_it != exp_replace_map.end(); exp_replace_it++)
80 regex e(exp_replace_it->first);
81 auto res = regex_replace(back_inserter(destTemp), source_temp.begin(), source_temp.end(),
e, exp_replace_it->second);
82 source_temp = destTemp;
85 for (
auto exp_replace_it = enum_replace_map.begin(); exp_replace_it != enum_replace_map.end(); exp_replace_it++)
88 regex e(exp_replace_it->first);
90 std::regex_search(source_temp, m,
std::regex(e));
94 string st_regular_exp =
"[a-zA-Z]+";
95 regex e1(st_regular_exp);
97 for (
size_t exp = 0; exp < m.size(); exp++)
106 for (
size_t exp = 0; exp < m1.size(); exp++)
111 auto vec =
_enums[enum_name];
114 int val = exp_replace_it->second;
118 regex_replace(back_inserter(destTemp), source_temp.begin(), source_temp.end(), e3,
it->second);
123 s <<
"Protocol Error recognized!\nImproper log message received: " << source_temp
124 <<
", invalid parameter: " << exp_replace_it->second <<
".\n The range of supported values is \n";
125 for_each(vec.begin(), vec.end(), [&
s](
kvp&
entry) { s <<
entry.first <<
":" <<
entry.second <<
" ,"; });
126 std::cout << s.str().c_str() << std::endl;;
128 source_temp = destTemp;
GLsizei const GLchar *const * string
GLenum const GLfloat * params
GLsizei GLsizei GLchar * source