all repos — mgba @ 61467cacd9569e0f56f3c01663edc40d9712d1b9

mGBA Game Boy Advance Emulator

Util: Add easy way to remove keys
Jeffrey Pfau jeffrey@endrift.com
Sun, 18 Jan 2015 01:19:28 -0800
commit

61467cacd9569e0f56f3c01663edc40d9712d1b9

parent

0ba9d1e247209c37a04321d30867c7bbac3ba4bf

2 files changed, 13 insertions(+), 0 deletions(-)

jump to
M src/util/configuration.csrc/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.hsrc/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);