From f5a394a5051384a930d635da22ccafc6beb1cb84 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Jan 2010 17:19:24 +0200 Subject: Change code style --- src/configuration.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/configuration.cpp') 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::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; } -- cgit v1.2.3-70-g09d2