config/config_file: Add exports and definitions of config_type_for<>

Required for implementors. Other than config.cc.
This commit is contained in:
Calle Wilund
2025-01-08 10:37:39 +00:00
parent e51b2075da
commit 7ed89266b3
2 changed files with 20 additions and 0 deletions

View File

@@ -144,6 +144,9 @@ const config_type config_type_for<std::string> = config_type("string", value_to_
template <>
const config_type config_type_for<std::vector<sstring>> = config_type("string list", value_to_json<std::vector<sstring>>);
template <>
const config_type config_type_for<std::unordered_map<sstring, std::unordered_map<sstring, sstring>>> = config_type("string map map", value_to_json<std::unordered_map<sstring, std::unordered_map<sstring, sstring>>>);
template <>
const config_type config_type_for<std::unordered_map<sstring, sstring>> = config_type("string map", value_to_json<std::unordered_map<sstring, sstring>>);

View File

@@ -53,6 +53,21 @@ public:
template <typename T>
extern const config_type config_type_for;
template<>
extern const config_type config_type_for<uint32_t>;
template<>
extern const config_type config_type_for<sstring>;
template<>
extern const config_type config_type_for<bool>;
template<>
extern const config_type config_type_for<std::unordered_map<sstring, sstring>>;
template<>
extern const config_type config_type_for<std::unordered_map<sstring, std::unordered_map<sstring, sstring>>>;
class config_file {
static thread_local unsigned s_shard_id;
struct any_value {
@@ -271,6 +286,8 @@ public:
config_file(std::initializer_list<cfg_ref> = {});
config_file(const config_file&) = delete;
virtual ~config_file() = default;
void add(cfg_ref, std::unique_ptr<any_value> value);
void add(std::initializer_list<cfg_ref>);
void add(const std::vector<cfg_ref> &);