#ifndef SERIALIZE_INTERFACE_H_INCLUDED #define SERIALIZE_INTERFACE_H_INCLUDED #include "include/Utils/DataTypes/DataTypes.h" #include "include/Utils/ErrorTypes/ErrorTypes.h" #include "boost/property_tree/ptree.hpp" #include "boost/property_tree/xml_parser.hpp" #include "boost/shared_array.hpp" #include "boost/foreach.hpp" #include namespace SE { std::shared_ptr StringToPropertyTree(std::string xmlCode, std::map replaceMap = std::map()); std::shared_ptr FileToPropertyTree(boost::shared_array xmlFileArr, cardinal xmlFileSize, std::map replaceMap = std::map()); std::shared_ptr FileToPropertyTree(const std::string& fileName, std::map replaceMap = std::map()); class TSerializeInterface { public: virtual void Serialize(boost::property_tree::ptree& propertyTree) { } }; template class TMapParser : public TSerializeInterface { public: std::map Map; virtual void Serialize(boost::property_tree::ptree& propertyTree) { BOOST_FOREACH(boost::property_tree::ptree::value_type& subTree, propertyTree) { TKEY key = subTree.second.get(".key"); TVALUE value = subTree.second.get(".value"); Map[key] = value; } } }; template std::map SerializeToMap(boost::property_tree::ptree& propertyTree) { TMapParser mapParser; mapParser.Serialize(propertyTree); return mapParser.Map; } } //namespace SE #endif