diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index f2d0610f694637fab5553a7e0285c598d7d28bdb..ae7f30920d944341c9377f60dd4b5055ab1805ca 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -11,7 +11,6 @@ */ #include <boost/property_tree/ptree.hpp> -#include <boost/property_tree/xml_parser.hpp> #ifdef USE_MPI #include <mpi.h> @@ -27,6 +26,7 @@ // BaseLib #include "BaseLib/BuildInfo.h" #include "BaseLib/FileTools.h" +#include "BaseLib/ConfigTree.h" #include "Applications/ApplicationsLib/LinearSolverLibrarySetup.h" #include "Applications/ApplicationsLib/LogogSetup.h" @@ -108,13 +108,8 @@ int main(int argc, char *argv[]) argc, argv); // Project's configuration - ConfigTree project_config; - - read_xml(project_arg.getValue(), project_config, - boost::property_tree::xml_parser::no_comments - | boost::property_tree::xml_parser::trim_whitespace); - DBUG("Project configuration from file \'%s\' read.", - project_arg.getValue().c_str()); + ConfigTree project_config = + BaseLib::read_xml_config(project_arg.getValue()); project_config = project_config.get_child("OpenGeoSysProject"); diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82902a4b7bb63d09ae2fa3ca222773b52a6e1520 --- /dev/null +++ b/BaseLib/ConfigTree.cpp @@ -0,0 +1,31 @@ +/** + * \copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "ConfigTree.h" + +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/xml_parser.hpp> + +#include <logog/include/logog.hpp> + +namespace BaseLib +{ +boost::property_tree::ptree read_xml_config(boost::filesystem::path const& path) +{ + boost::property_tree::ptree ptree; + read_xml(path.string(), ptree, + boost::property_tree::xml_parser::no_comments | + boost::property_tree::xml_parser::trim_whitespace); + + DBUG("Project configuration from file \'%s\' read.", + path.string().c_str()); + + return ptree; +} +} diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h new file mode 100644 index 0000000000000000000000000000000000000000..ec8efcf72ad414b7e63a8475501c17e8f2668f95 --- /dev/null +++ b/BaseLib/ConfigTree.h @@ -0,0 +1,23 @@ +/** + * \copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef BASELIB_CONFIGTREE_H_ +#define BASELIB_CONFIGTREE_H_ + +#include <boost/property_tree/ptree_fwd.hpp> +#include <boost/filesystem.hpp> + +namespace BaseLib +{ + +boost::property_tree::ptree read_xml_config( + boost::filesystem::path const& path); +} + +#endif // BASELIB_CONFIGTREE_H_