Lines Matching refs:config
39 static bool config_parse(FILE* fp, config_t* config);
44 static auto section_find(T& config, const std::string& section) { in section_find() argument
46 config.sections.begin(), config.sections.end(), in section_find()
50 static const entry_t* entry_find(const config_t& config, in entry_find() argument
53 auto sec = section_find(config, section); in entry_find()
54 if (sec == config.sections.end()) return nullptr; in entry_find()
70 std::unique_ptr<config_t> config = config_new_empty(); in config_new() local
79 if (!config_parse(fp, config.get())) { in config_new()
80 config.reset(); in config_new()
84 return config; in config_new()
99 bool config_has_section(const config_t& config, const std::string& section) { in config_has_section() argument
100 return (section_find(config, section) != config.sections.end()); in config_has_section()
103 bool config_has_key(const config_t& config, const std::string& section, in config_has_key() argument
105 return (entry_find(config, section, key) != nullptr); in config_has_key()
108 int config_get_int(const config_t& config, const std::string& section, in config_get_int() argument
110 const entry_t* entry = entry_find(config, section, key); in config_get_int()
118 uint64_t config_get_uint64(const config_t& config, const std::string& section, in config_get_uint64() argument
120 const entry_t* entry = entry_find(config, section, key); in config_get_uint64()
128 bool config_get_bool(const config_t& config, const std::string& section, in config_get_bool() argument
130 const entry_t* entry = entry_find(config, section, key); in config_get_bool()
139 const std::string* config_get_string(const config_t& config, in config_get_string() argument
143 const entry_t* entry = entry_find(config, section, key); in config_get_string()
149 void config_set_int(config_t* config, const std::string& section, in config_set_int() argument
151 config_set_string(config, section, key, std::to_string(value)); in config_set_int()
154 void config_set_uint64(config_t* config, const std::string& section, in config_set_uint64() argument
156 config_set_string(config, section, key, std::to_string(value)); in config_set_uint64()
159 void config_set_bool(config_t* config, const std::string& section, in config_set_bool() argument
161 config_set_string(config, section, key, value ? "true" : "false"); in config_set_bool()
164 void config_set_string(config_t* config, const std::string& section, in config_set_string() argument
166 CHECK(config); in config_set_string()
168 auto sec = section_find(*config, section); in config_set_string()
169 if (sec == config->sections.end()) { in config_set_string()
170 config->sections.emplace_back(section_t{.name = section}); in config_set_string()
171 sec = std::prev(config->sections.end()); in config_set_string()
193 bool config_remove_section(config_t* config, const std::string& section) { in config_remove_section() argument
194 CHECK(config); in config_remove_section()
196 auto sec = section_find(*config, section); in config_remove_section()
197 if (sec == config->sections.end()) return false; in config_remove_section()
199 config->sections.erase(sec); in config_remove_section()
203 bool config_remove_key(config_t* config, const std::string& section, in config_remove_key() argument
205 CHECK(config); in config_remove_key()
206 auto sec = section_find(*config, section); in config_remove_key()
207 if (sec == config->sections.end()) return false; in config_remove_key()
220 bool config_save(const config_t& config, const std::string& filename) { in config_save() argument
260 for (const section_t& section : config.sections) { in config_save()
339 static bool config_parse(FILE* fp, config_t* config) { in config_parse() argument
341 CHECK(config != nullptr); in config_parse()
373 config_set_string(config, section, trim(line_ptr), trim(split + 1)); in config_parse()