diff --git a/config/config.cpp b/config/config.cpp index 50f62ef1ffcc2b15fd57dbd3839e3151b2997519..ac75ed64f0420036704f3dfa3c964bf7a4caf6f0 100644 --- a/config/config.cpp +++ b/config/config.cpp @@ -378,3 +378,30 @@ void config::update_used_nfs() { } } } + +std::string oai::config::get_value_formatter(int level) { + { + // TODO use this function everywhere, it is much simpler + int indent_width = level * INDENT_WIDTH; + std::string base_indent = fmt::format("{:<{}}", "", indent_width); + std::string indent_char = + (level + 1) % 2 == 0 ? INNER_LIST_ELEM : OUTER_LIST_ELEM; + + unsigned int inner_width = COLUMN_WIDTH; + if (base_indent.length() < COLUMN_WIDTH) { + inner_width = COLUMN_WIDTH - base_indent.length(); + } + return base_indent + indent_char + " {:.<" + std::to_string(inner_width) + + "}: {}\n"; + } +} + +std::string oai::config::get_title_formatter(int level) { + { + int indent_width = level * INDENT_WIDTH; + std::string base_indent = fmt::format("{:<{}}", "", indent_width); + std::string indent_char = + (level + 1) % 2 == 0 ? INNER_LIST_ELEM : OUTER_LIST_ELEM; + return base_indent + indent_char + " {}\n"; + } +} diff --git a/config/config.hpp b/config/config.hpp index ec0f7eaca6d3e6e097fe1d1a61b371e0cf90fddf..41da31be438d055f97331343d0d7d907af473144 100644 --- a/config/config.hpp +++ b/config/config.hpp @@ -105,6 +105,7 @@ const std::string DNNS_CONFIG_NAME = "dnns"; constexpr auto NF_CONFIG_HTTP_NAME = "http_version"; constexpr auto NF_CONFIG_HTTP_LABEL = "HTTP Version"; + // HTTP Version constexpr auto NF_CONFIG_CURL_TIMEOUT = "curl_timeout"; constexpr auto NF_CONFIG_CURL_TIMEOUT_LABEL = "Curl Timeout"; @@ -113,28 +114,8 @@ constexpr uint32_t NF_CONFIG_CURL_TIMEOUT_DEFAULT_VALUE = constexpr uint32_t NF_CONFIG_CURL_TIMEOUT_MIN_VALUE = 10; // in milliseconds constexpr uint32_t NF_CONFIG_CURL_TIMEOUT_MAX_VALUE = 20000; // in milliseconds -static std::string get_value_formatter(int level) { - // TODO use this function everywhere, it is much simpler - int indent_width = level * INDENT_WIDTH; - std::string base_indent = fmt::format("{:<{}}", "", indent_width); - std::string indent_char = - (level) % 2 == 0 ? INNER_LIST_ELEM : OUTER_LIST_ELEM; - - unsigned int inner_width = COLUMN_WIDTH; - if (base_indent.length() < COLUMN_WIDTH) { - inner_width = COLUMN_WIDTH - base_indent.length(); - } - return base_indent + indent_char + " {:.<" + std::to_string(inner_width) + - "}: {}\n"; -} - -static std::string get_title_formatter(int level) { - int indent_width = level * INDENT_WIDTH; - std::string base_indent = fmt::format("{:<{}}", "", indent_width); - std::string indent_char = - (level) % 2 == 0 ? INNER_LIST_ELEM : OUTER_LIST_ELEM; - return base_indent + indent_char + " {}\n"; -} +std::string get_value_formatter(int level); +std::string get_title_formatter(int level); class config_iface { public: diff --git a/config/config_types.cpp b/config/config_types.cpp index f159e330f71798528f3301c772b57225c926108f..f6ba4163802738364819b36c1ee9204c0e10100f 100644 --- a/config/config_types.cpp +++ b/config/config_types.cpp @@ -123,6 +123,14 @@ std::string config_type::add_indent(const std::string& indent) { return base_indent + indent; } +nlohmann::json config_type::to_json() { + return {}; +} + +bool config_type::from_json(const nlohmann::json&) { + return false; +} + string_config_value::string_config_value( const std::string& name, const std::string& value) { m_config_name = name; @@ -653,7 +661,7 @@ nlohmann::json nf_features_config::to_json() { return json_data; } -bool nf_features_config::from_json(const nlohmann::json& json_data) { +bool nf_features_config::from_json(const nlohmann::json&) { try { // TODO: /* if (json_data.find(m_config_name) != json_data.end()) { diff --git a/config/config_types.hpp b/config/config_types.hpp index fa4c4c27299ff11bc66b5fe7395dd2e502a6a04a..3c9d9385a6b942a68a11ac6594629a37e39138b2 100644 --- a/config/config_types.hpp +++ b/config/config_types.hpp @@ -71,18 +71,12 @@ class config_type { * Convert to JSON format * @return void */ - virtual nlohmann::json to_json() { - nlohmann::json json_data = {}; - return json_data; - }; // TODO: pure virtual - + virtual nlohmann::json to_json(); /** * Get value from JSON * @return void */ - virtual bool from_json(const nlohmann::json& json_data) { - return true; - }; // TODO: pure virtual + virtual bool from_json(const nlohmann::json& json_data); /** * Checks if the configuration is set. Configuration is not set if it has not