7#include <userver/formats/json_fwd.hpp>
11namespace dynamic_config {
15namespace dynamic_config::impl {
17std::string DoToJsonString(
bool value);
18std::string DoToJsonString(
double value);
19std::string DoToJsonString(std::uint64_t value);
20std::string DoToJsonString(std::int64_t value);
21std::string DoToJsonString(std::string_view value);
23template <
typename T,
typename >
28template <
typename T,
typename Unused>
29using Id =
typename IdWrapper<T, Unused>::type;
33template <
typename T,
typename Value = formats::
json::Value>
34std::string ToJsonString(
const T& value) {
35 if constexpr (std::is_same_v<T,
bool>) {
36 return impl::DoToJsonString(
static_cast<Id<
bool, T>>(value));
37 }
else if constexpr (std::is_floating_point_v<T>) {
38 return impl::DoToJsonString(
static_cast<Id<
double, T>>(value));
39 }
else if constexpr (std::is_unsigned_v<T>) {
40 return impl::DoToJsonString(
static_cast<Id<std::uint64_t, T>>(value));
41 }
else if constexpr (std::is_integral_v<T>) {
42 return impl::DoToJsonString(
static_cast<Id<std::int64_t, T>>(value));
43 }
else if constexpr (std::is_convertible_v<
const T&, std::string_view>) {
44 return impl::DoToJsonString(
static_cast<Id<std::string_view, T>>(value));
46 return ToString(Serialize(value, formats::
serialize::
To<Value>{}));
50std::string SingleToDocsMapString(std::string_view name,
51 std::string_view value);
53std::string MultipleToDocsMapString(
const ConfigDefault* data,
57std::string ValueToDocsMapString(std::string_view name,
const T& value) {
58 return impl::SingleToDocsMapString(name, impl::ToJsonString(value));