summaryrefslogtreecommitdiff
path: root/src/configuration.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-01-10 17:19:24 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-01-10 17:20:33 +0100
commitf5a394a5051384a930d635da22ccafc6beb1cb84 (patch)
treed28fc14408a6bb91170e05880b4d2af6a17fcc14 /src/configuration.cpp
parent5757066312cab082378dbc5d8df97dea3fe40af0 (diff)
downloadmana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.gz
mana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.bz2
mana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.xz
mana-f5a394a5051384a930d635da22ccafc6beb1cb84.zip
Change code style
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r--src/configuration.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 0f73e2fb..cb5d9002 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -38,7 +38,8 @@ void Configuration::setValue(const std::string &key, const std::string &value)
// Notify listeners
ListenerMapIterator list = mListenerMap.find(key);
- if (list != mListenerMap.end()) {
+ if (list != mListenerMap.end())
+ {
Listeners listeners = list->second;
for (ListenerIterator i = listeners.begin(); i != listeners.end(); i++)
{
@@ -102,7 +103,8 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
for_each_xml_child_node(node, parent_node)
{
- if (xmlStrEqual(node->name, BAD_CAST "list")) {
+ if (xmlStrEqual(node->name, BAD_CAST "list"))
+ {
// list option handling
std::string name = XML::getProperty(node, "name", std::string());
@@ -110,7 +112,8 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
for_each_xml_child_node(subnode, node)
{
if (xmlStrEqual(subnode->name, BAD_CAST name.c_str())
- && subnode->type == XML_ELEMENT_NODE) {
+ && subnode->type == XML_ELEMENT_NODE)
+ {
ConfigurationObject *cobj = new ConfigurationObject;
cobj->initFromXML(subnode); // recurse
@@ -119,7 +122,9 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
}
}
- } else if (xmlStrEqual(node->name, BAD_CAST "option")) {
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "option"))
+ {
// single option handling
std::string name = XML::getProperty(node, "name", std::string());
@@ -137,12 +142,10 @@ void Configuration::init(const std::string &filename)
// Do not attempt to read config from non-existant file
FILE *testFile = fopen(filename.c_str(), "r");
- if (!testFile) {
+ if (!testFile)
return;
- }
- else {
+ else
fclose(testFile);
- }
xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
@@ -150,7 +153,8 @@ void Configuration::init(const std::string &filename)
xmlNodePtr rootNode = xmlDocGetRootElement(doc);
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) {
+ if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration"))
+ {
logger->log("Warning: No configuration file (%s)", filename.c_str());
xmlFreeDoc(doc);
return;
@@ -175,7 +179,8 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
}
for (std::map<std::string, ConfigurationList>::const_iterator
- it = mContainerOptions.begin(); it != mContainerOptions.end(); it++) {
+ it = mContainerOptions.begin(); it != mContainerOptions.end(); it++)
+ {
const char *name = it->first.c_str();
xmlTextWriterStartElement(writer, BAD_CAST "list");
@@ -183,8 +188,8 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
// recurse on all elements
for (ConfigurationList::const_iterator
- elt_it = it->second.begin(); elt_it != it->second.end(); elt_it++) {
-
+ elt_it = it->second.begin(); elt_it != it->second.end(); elt_it++)
+ {
xmlTextWriterStartElement(writer, BAD_CAST name);
(*elt_it)->writeToXML(writer);
xmlTextWriterEndElement(writer);
@@ -198,18 +203,21 @@ void Configuration::write()
{
// Do not attempt to write to file that cannot be opened for writing
FILE *testFile = fopen(mConfigPath.c_str(), "w");
- if (!testFile) {
+ if (!testFile)
+ {
logger->log("Configuration::write() couldn't open %s for writing",
mConfigPath.c_str());
return;
}
- else {
+ else
+ {
fclose(testFile);
}
xmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0);
- if (!writer) {
+ if (!writer)
+ {
logger->log("Configuration::write() error while creating writer");
return;
}