13 #ifndef DtXmlFileIo_H_
14 #define DtXmlFileIo_H_
18 #include <boost/archive/xml_iarchive.hpp>
19 #include <boost/archive/xml_oarchive.hpp>
38 static bool write(
const std::string& filePath,
const T& t,
const std::string& tagName =
"Record")
43 std::ofstream ofs(filePath.c_str());
50 boost::archive::xml_oarchive oa(ofs);
51 oa << boost::serialization::make_nvp(tagName.c_str(), t);
64 static bool read(
const std::string& filePath, T& t,
const std::string& tagName =
"Record")
69 std::ifstream ifs(filePath.c_str());
76 boost::archive::xml_iarchive ia(ifs);
78 ia >> boost::serialization::make_nvp(tagName.c_str(), t);
81 catch( boost::archive::archive_exception& ex )
83 std::cerr <<
"Archive Exception during deserializing:" << filePath << std::endl;
84 std::cerr << ex.what() << std::endl;