diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-05 02:20:34 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-08-05 02:20:34 +0000 |
commit | d25e1c9b0dac7fcfe803083af1189489d5a9ad88 (patch) | |
tree | 330e30558d62c4de99976305390a976fd5f8d958 /src/configuration.cpp | |
parent | 97f1e5345cc8a88fed9c65035f2b01fc2eaf9cbd (diff) | |
download | mana-d25e1c9b0dac7fcfe803083af1189489d5a9ad88.tar.gz mana-d25e1c9b0dac7fcfe803083af1189489d5a9ad88.tar.bz2 mana-d25e1c9b0dac7fcfe803083af1189489d5a9ad88.tar.xz mana-d25e1c9b0dac7fcfe803083af1189489d5a9ad88.zip |
Some cleanups, mostly lowering indentation levels.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 4085b20b..53f6785e 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -57,18 +57,18 @@ void Configuration::init(const std::string &filename) for (node = node->xmlChildrenNode; node != NULL; node = node->next) { - if (xmlStrEqual(node->name, BAD_CAST "option")) - { - xmlChar *name = xmlGetProp(node, BAD_CAST "name"); - xmlChar *value = xmlGetProp(node, BAD_CAST "value"); + if (!xmlStrEqual(node->name, BAD_CAST "option")) + continue; - if (name && value) { - mOptions[(const char*)name] = (const char*)value; - } + xmlChar *name = xmlGetProp(node, BAD_CAST "name"); + xmlChar *value = xmlGetProp(node, BAD_CAST "value"); - if (name) xmlFree(name); - if (value) xmlFree(value); + if (name && value) { + mOptions[(const char*)name] = (const char*)value; } + + if (name) xmlFree(name); + if (value) xmlFree(value); } xmlFreeDoc(doc); @@ -87,28 +87,28 @@ void Configuration::write() xmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0); - if (writer) - { - xmlTextWriterSetIndent(writer, 1); - xmlTextWriterStartDocument(writer, NULL, NULL, NULL); - xmlTextWriterStartElement(writer, BAD_CAST "configuration"); + if (!writer) + return; - for (OptionIterator i = mOptions.begin(); i != mOptions.end(); i++) - { - logger->log("Configuration::write(%s, \"%s\")", - i->first.c_str(), i->second.c_str()); - - xmlTextWriterStartElement(writer, BAD_CAST "option"); - xmlTextWriterWriteAttribute(writer, - BAD_CAST "name", BAD_CAST i->first.c_str()); - xmlTextWriterWriteAttribute(writer, - BAD_CAST "value", BAD_CAST i->second.c_str()); - xmlTextWriterEndElement(writer); - } + xmlTextWriterSetIndent(writer, 1); + xmlTextWriterStartDocument(writer, NULL, NULL, NULL); + xmlTextWriterStartElement(writer, BAD_CAST "configuration"); - xmlTextWriterEndDocument(writer); - xmlFreeTextWriter(writer); + for (OptionIterator i = mOptions.begin(); i != mOptions.end(); i++) + { + logger->log("Configuration::write(%s, \"%s\")", + i->first.c_str(), i->second.c_str()); + + xmlTextWriterStartElement(writer, BAD_CAST "option"); + xmlTextWriterWriteAttribute(writer, + BAD_CAST "name", BAD_CAST i->first.c_str()); + xmlTextWriterWriteAttribute(writer, + BAD_CAST "value", BAD_CAST i->second.c_str()); + xmlTextWriterEndElement(writer); } + + xmlTextWriterEndDocument(writer); + xmlFreeTextWriter(writer); } void Configuration::setValue(const std::string &key, std::string value) |