From e9a218df0eda1d2db2630bf019bd5a15a8e91b2b Mon Sep 17 00:00:00 2001 From: "Dmitry Yu. Naumov" <github@naumov.de> Date: Sat, 24 Oct 2015 16:08:28 +0000 Subject: [PATCH] [BL] Move propertyTreeToString into ConfigTree. --- BaseLib/ConfigTree.cpp | 10 ++++++++++ BaseLib/ConfigTree.h | 3 +++ BaseLib/StringTools.cpp | 8 -------- BaseLib/StringTools.h | 6 ------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index 82902a4b7bb..465245b5c72 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -11,11 +11,13 @@ #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/xml_parser.hpp> +#include <boost/property_tree/json_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; @@ -28,4 +30,12 @@ boost::property_tree::ptree read_xml_config(boost::filesystem::path const& path) return ptree; } + +std::string propertyTreeToString(boost::property_tree::ptree const& tree) +{ + std::ostringstream ss; + boost::property_tree::write_json(ss, tree); + return ss.str(); +} + } diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index ec8efcf72ad..a7dde55dd14 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -18,6 +18,9 @@ namespace BaseLib boost::property_tree::ptree read_xml_config( boost::filesystem::path const& path); + +/// Returns the JSON-representation of the given boost::property_tree. +std::string propertyTreeToString(boost::property_tree::ptree const& tree); } #endif // BASELIB_CONFIGTREE_H_ diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index 0da26d250c0..2a9ba62638f 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -20,7 +20,6 @@ #include "logog/include/logog.hpp" -#include <boost/property_tree/json_parser.hpp> #include <boost/algorithm/string/replace.hpp> namespace BaseLib @@ -73,13 +72,6 @@ std::string padLeft(std::string const& str, int maxlen, char ch) return ss.str(); } -std::string propertyTreeToString(boost::property_tree::ptree const& tree) -{ - std::ostringstream ss; - boost::property_tree::write_json(ss, tree); - return ss.str(); -} - } // end namespace BaseLib #ifdef MSVC diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index f887ad56ec2..e59032c8f6f 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -15,7 +15,6 @@ #ifndef STRINGTOOLS_H #define STRINGTOOLS_H -#include <boost/property_tree/ptree.hpp> #include <string> #include <list> @@ -71,11 +70,6 @@ void simplify(std::string &str); */ std::string padLeft(std::string const& str, int maxlen, char ch=' '); -/** - * Returns the JSON-representation of the given boost::property_tree. - */ -std::string propertyTreeToString(boost::property_tree::ptree const& tree); - } // end namespace BaseLib #ifdef MSVC -- GitLab