From 7bbf1c7684b5530a887bc46f18ccf5659eae1ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 7 Dec 2011 14:24:22 +0100 Subject: [PATCH] Removed unused code (libxml2-using). --- dune/common/param/ParameterXML.cpp | 100 ----------------------------- 1 file changed, 100 deletions(-) diff --git a/dune/common/param/ParameterXML.cpp b/dune/common/param/ParameterXML.cpp index 04485ec6..4e69a0ac 100644 --- a/dune/common/param/ParameterXML.cpp +++ b/dune/common/param/ParameterXML.cpp @@ -45,7 +45,6 @@ along with OpenRS. If not, see . #include #include -#if 1 // Use tinyxml #include @@ -135,102 +134,3 @@ namespace Dune { } // namespace parameter } // namespace Dune - -#else // Use libxml2 - -#include // libxml2 -#include // libxml2 - - -namespace Dune { - namespace parameter { - - namespace libxml2 { - void read_xml(ParameterGroup& pg, const std::string filename); - void fill_tree(ParameterGroup& pg, xmlNodePtr root, - const std::string& xml_file_path); - } - - void fill_xml(ParameterGroup& pg, const std::string filename) { - libxml2::read_xml(pg, filename); - } - - namespace libxml2 { - std::string getProperty(const std::string& property, - const xmlNodePtr& node_ptr) - { - const char* prop_value_ptr = (const char*) xmlGetProp(node_ptr, (const xmlChar*)property.c_str()); - std::string property_value(prop_value_ptr ? prop_value_ptr : ""); - xmlFree((xmlChar*) prop_value_ptr); - return property_value; - } - - void read_xml(ParameterGroup& pg, const std::string filename) - { - // Macro to check that the libxml version in use is compatible - // with the version the software has been compiled against - LIBXML_TEST_VERSION; // defined by libxml2 - - xmlDocPtr doc = xmlParseFile(filename.c_str()); - if (doc == NULL) { - xmlFreeDoc(doc); - xmlCleanupParser(); - std::cerr << "ERROR: Failed to open XML file '" << filename << "'\n"; - throw std::exception(); - } - xmlNodePtr root = xmlDocGetRootElement(doc); - std::string xml_file_path = boost::filesystem::path(filename).branch_path().string(); - fill_tree(pg, root, xml_file_path); - xmlFreeDoc(doc); - xmlCleanupParser(); - } - - void fill_tree(ParameterGroup& pg, xmlNodePtr root, - const std::string& xml_file_path) - { - //std::cout << "GROUP '" << value << "' BEGIN\n"; - for (xmlNodePtr cur = root->children; cur; cur = cur->next) { - if (cur->type == XML_ELEMENT_NODE) { - const char* tag_ptr = (const char*) cur->name; - std::string tag_name(tag_ptr ? tag_ptr : ""); - if (tag_name == ID_xmltag__file_params) { - std::string relative_filename = getProperty(ID_xmlatt__value, cur); - std::string filename = (boost::filesystem::path(xml_file_path) / relative_filename).string(); - fill_xml(pg, filename); - continue; - } - std::string name = getProperty(ID_xmlatt__name, cur); - std::tr1::shared_ptr data; - if (tag_name == ID_xmltag__param) { - std::string value = getProperty(ID_xmlatt__value, cur); - std::string type = getProperty(ID_xmlatt__type, cur); - if (type == ID_param_type__file) { - value = (boost::filesystem::path(xml_file_path) / value).string(); - type = ID_param_type__string; - } - data.reset(new Parameter(value, type)); - } else if (tag_name == ID_xmltag__param_grp) { - std::string child_path = pg.path() + ID_delimiter_path + name; - data.reset(new ParameterGroup(child_path, &pg)); - fill_tree(dynamic_cast(*data), cur, xml_file_path); - } else if (tag_name == ID_xmltag__file_param_grp) { - std::string child_path = pg.path() + ID_delimiter_path + name; - data.reset(new ParameterGroup(child_path, &pg)); - std::string relative_filename = getProperty(ID_xmlatt__value, cur); - std::string filename = (boost::filesystem::path(xml_file_path) / relative_filename).string(); - fill_xml(dynamic_cast(*data), filename); - } else { - std::cerr << "ERROR: '" << tag_name << "' is an unknown xml tag.\n"; - throw std::exception(); - } - pg.insert(name, data); - } - } - //std::cout << "GROUP '" << id << "' END\n"; - } - } - } // namespace parameter -} // namespace Dune - - -#endif