14
14
#include " overloaded.hpp"
15
15
#include " pgsql.hpp"
16
16
17
+ std::string to_string (param_value_t const &value)
18
+ {
19
+ return std::visit (
20
+ overloaded{[](null_param_t ) { return std::string{}; },
21
+ [](std::string val) { return val; },
22
+ [](auto const &val) { return fmt::to_string (val); }},
23
+ value);
24
+ }
25
+
17
26
param_value_t params_t::get (std::string const &key) const
18
27
{
19
28
return m_map.at (key);
@@ -49,7 +58,7 @@ double params_t::get_double(std::string const &key, double default_value) const
49
58
return static_cast <double >(std::get<int64_t >(it->second ));
50
59
}
51
60
52
- throw fmt_error (" Invalid value '{}' for {}." , it->second , key);
61
+ throw fmt_error (" Invalid value '{}' for {}." , to_string ( it->second ) , key);
53
62
}
54
63
55
64
std::string params_t::get_string (std::string const &key) const
@@ -58,7 +67,7 @@ std::string params_t::get_string(std::string const &key) const
58
67
if (it == m_map.end ()) {
59
68
throw fmt_error (" Missing parameter '{}' on generalizer." , key);
60
69
}
61
- return fmt::format ( " {} " , it->second );
70
+ return to_string ( it->second );
62
71
}
63
72
64
73
std::string params_t::get_string (std::string const &key,
@@ -73,7 +82,7 @@ std::string params_t::get_identifier(std::string const &key) const
73
82
if (it == m_map.end ()) {
74
83
return {};
75
84
}
76
- std::string result = fmt::format ( " {} " , it->second );
85
+ std::string result = to_string ( it->second );
77
86
check_identifier (result, key.c_str ());
78
87
return result;
79
88
}
@@ -85,7 +94,7 @@ void params_t::check_identifier_with_default(std::string const &key,
85
94
if (it == m_map.end ()) {
86
95
m_map.emplace (key, std::move (default_value));
87
96
} else {
88
- check_identifier (fmt::format ( " {} " , it->second ), key.c_str ());
97
+ check_identifier (to_string ( it->second ), key.c_str ());
89
98
}
90
99
}
91
100
@@ -111,6 +120,6 @@ void write_to_debug_log(params_t const ¶ms, char const *message)
111
120
}
112
121
log_debug (" {}" , message);
113
122
for (auto const &[key, value] : params) {
114
- log_debug (" {}={}" , key, value);
123
+ log_debug (" {}={}" , key, to_string ( value) );
115
124
}
116
125
}
0 commit comments