Util: Add easy way to remove keys

This commit is contained in:
Jeffrey Pfau 2015-01-18 01:19:28 -08:00
parent 0ba9d1e247
commit 61467cacd9
2 changed files with 13 additions and 0 deletions

View File

@ -83,6 +83,17 @@ void ConfigurationSetFloatValue(struct Configuration* configuration, const char*
ConfigurationSetValue(configuration, section, key, charValue); 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 char* ConfigurationGetValue(const struct Configuration* configuration, const char* section, const char* key) {
const struct Table* currentSection = &configuration->root; const struct Table* currentSection = &configuration->root;
if (section) { if (section) {

View File

@ -25,6 +25,8 @@ void ConfigurationSetFloatValue(struct Configuration*, const char* section, cons
const char* ConfigurationGetValue(const struct Configuration*, const char* section, const char* key); 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 ConfigurationRead(struct Configuration*, const char* path);
bool ConfigurationWrite(const struct Configuration*, const char* path); bool ConfigurationWrite(const struct Configuration*, const char* path);
bool ConfigurationWriteSection(const struct Configuration*, const char* path, const char* section); bool ConfigurationWriteSection(const struct Configuration*, const char* path, const char* section);