1 #ifndef JULIAN_SERIALIZATION_HPP 2 #define JULIAN_SERIALIZATION_HPP 4 #include <boost/archive/binary_oarchive.hpp> 5 #include <boost/archive/binary_iarchive.hpp> 6 #include <boost/archive/text_oarchive.hpp> 7 #include <boost/archive/text_iarchive.hpp> 8 #include <boost/archive/xml_oarchive.hpp> 9 #include <boost/archive/xml_iarchive.hpp> 10 #include <boost/serialization/utility.hpp> 11 #include <boost/serialization/map.hpp> 12 #include <boost/assert.hpp> 30 std::ofstream ofs(file);
31 boost::archive::text_oarchive oa(ofs);
32 oa << BOOST_SERIALIZATION_NVP(
object);
43 std::ofstream ofs(file);
44 boost::archive::binary_oarchive oa(ofs);
45 oa << BOOST_SERIALIZATION_NVP(
object);
56 std::ofstream ofs(file);
57 boost::archive::xml_oarchive oa(ofs);
58 oa << BOOST_SERIALIZATION_NVP(
object);
71 std::ifstream ifs(file);
72 BOOST_ASSERT_MSG(ifs.good(),
"file does not exists");
73 boost::archive::text_iarchive ia(ifs);
74 ia >> BOOST_SERIALIZATION_NVP(obj);
88 std::ifstream ifs(file);
89 BOOST_ASSERT_MSG(ifs.good(),
"file does not exists");
90 boost::archive::binary_iarchive ia(ifs);
91 ia >> BOOST_SERIALIZATION_NVP(obj);
105 std::ifstream ifs(file);
106 BOOST_ASSERT_MSG(ifs.good(),
"file does not exists");
107 boost::archive::xml_iarchive ia(ifs);
108 ia >> BOOST_SERIALIZATION_NVP(obj);
114 namespace serialization {
117 template<
class Archive,
class T>
120 const unsigned int ){
121 const T *
const tx = t->clone();
122 ar << BOOST_SERIALIZATION_NVP(tx);
126 template<
class Archive,
class T>
127 inline void load( Archive & ar,
129 const unsigned int ) {
131 ar >> BOOST_SERIALIZATION_NVP(pTarget);
136 template<
class Archive,
class T>
137 inline void serialize(Archive & ar,
139 const unsigned int file_version ){
140 boost::serialization::split_free(ar, t, file_version);
Contains headers of all files with definitions of classes gathered in interest rate module...
Template of deep-coping smart pointer.
Definition: smartPointer.hpp:14
void load(Archive &ar, julian::SmartPointer< T > &t, const unsigned int)
Definition: serialization.hpp:127
void serializeBinary(T object, std::string file)
Serialize object to binary file.
Definition: serialization.hpp:42
T deserializeText(std::string file)
Deserializes object from text file.
Definition: serialization.hpp:69
void save(Archive &ar, const julian::SmartPointer< T > &t, const unsigned int)
Definition: serialization.hpp:118
void serializeText(T object, std::string file)
Serialize object to text file.
Definition: serialization.hpp:29
void serializeXML(T object, std::string file)
Serialize object to xml file.
Definition: serialization.hpp:55
Definition: serialization.hpp:113
T deserializeXML(std::string file)
Deserializes object from xml file.
Definition: serialization.hpp:103
T deserializeBinary(std::string file)
Deserializes object from binary file.
Definition: serialization.hpp:86
Financial instruments module.