Util: Add easy way to remove keys
Jeffrey Pfau jeffrey@endrift.com
Sun, 18 Jan 2015 01:19:28 -0800
2 files changed,
13 insertions(+),
0 deletions(-)
M
src/util/configuration.c
→
src/util/configuration.c
@@ -83,6 +83,17 @@ sprintf(charValue, "%.*g", FLT_DIG, value);
ConfigurationSetValue(configuration, section, key, charValue); } +void ConfigurationClearValue(struct Configuration* configuration, const char* section, const char* key) { + struct Table* currentSection = &configuration->root; + if (section) { + currentSection = HashTableLookup(&configuration->sections, section); + if (!currentSection) { + return; + } + } + HashTableRemove(currentSection, key); +} + const char* ConfigurationGetValue(const struct Configuration* configuration, const char* section, const char* key) { const struct Table* currentSection = &configuration->root; if (section) {
M
src/util/configuration.h
→
src/util/configuration.h
@@ -25,6 +25,8 @@ void ConfigurationSetFloatValue(struct Configuration*, const char* section, const char* key, float value);
const char* ConfigurationGetValue(const struct Configuration*, const char* section, const char* key); +void ConfigurationClearValue(struct Configuration*, const char* section, const char* key); + bool ConfigurationRead(struct Configuration*, const char* path); bool ConfigurationWrite(const struct Configuration*, const char* path); bool ConfigurationWriteSection(const struct Configuration*, const char* path, const char* section);