10 #ifndef DtXmlFileIo_H_
11 #define DtXmlFileIo_H_
15 #include <boost/archive/xml_iarchive.hpp>
16 #include <boost/archive/xml_oarchive.hpp>
21 #include <boost/iostreams/device/mapped_file.hpp>
22 #include <boost/iostreams/stream.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);
66 static bool read(
const std::string& filePath, T& t,
const std::string& tagName =
"Record")
71 std::ifstream ifs(filePath.c_str());
78 boost::archive::xml_iarchive ia(ifs);
80 ia >> boost::serialization::make_nvp(tagName.c_str(), t);
82 catch (boost::archive::archive_exception& ex)
84 std::cerr <<
"Archive Exception during deserializing:" << filePath << std::endl;
85 std::cerr << ex.what() << std::endl;
Contains DLL export macros.
static bool read(const std::string &filePath, T &t, const std::string &tagName="Record")
Definition: DtXmlFileIo.h:66
A DtXmlFileIo has the static functions for reading and writing to an XML archive. ...
Definition: DtXmlFileIo.h:29
#define DT_DLL_MAKARCHIVES
Definition: makArchives.h:31
static bool write(const std::string &filePath, const T &t, const std::string &tagName="Record")
Definition: DtXmlFileIo.h:38