1414#include " overloaded.hpp"
1515#include " pgsql.hpp"
1616
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+
1726param_value_t params_t::get (std::string const &key) const
1827{
1928 return m_map.at (key);
@@ -49,7 +58,7 @@ double params_t::get_double(std::string const &key, double default_value) const
4958 return static_cast <double >(std::get<int64_t >(it->second ));
5059 }
5160
52- throw fmt_error (" Invalid value '{}' for {}." , it->second , key);
61+ throw fmt_error (" Invalid value '{}' for {}." , to_string ( it->second ) , key);
5362}
5463
5564std::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
5867 if (it == m_map.end ()) {
5968 throw fmt_error (" Missing parameter '{}' on generalizer." , key);
6069 }
61- return fmt::format ( " {} " , it->second );
70+ return to_string ( it->second );
6271}
6372
6473std::string params_t::get_string (std::string const &key,
@@ -73,7 +82,7 @@ std::string params_t::get_identifier(std::string const &key) const
7382 if (it == m_map.end ()) {
7483 return {};
7584 }
76- std::string result = fmt::format ( " {} " , it->second );
85+ std::string result = to_string ( it->second );
7786 check_identifier (result, key.c_str ());
7887 return result;
7988}
@@ -85,7 +94,7 @@ void params_t::check_identifier_with_default(std::string const &key,
8594 if (it == m_map.end ()) {
8695 m_map.emplace (key, std::move (default_value));
8796 } else {
88- check_identifier (fmt::format ( " {} " , it->second ), key.c_str ());
97+ check_identifier (to_string ( it->second ), key.c_str ());
8998 }
9099}
91100
@@ -111,6 +120,6 @@ void write_to_debug_log(params_t const ¶ms, char const *message)
111120 }
112121 log_debug (" {}" , message);
113122 for (auto const &[key, value] : params) {
114- log_debug (" {}={}" , key, value);
123+ log_debug (" {}={}" , key, to_string ( value) );
115124 }
116125}
0 commit comments