summaryrefslogtreecommitdiff
path: root/src/system.hh.in
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-30 18:06:37 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-30 18:06:37 -0400
commita757b19f51ac7aa120e6829b573187b1ff36301a (patch)
tree5e6d4ef278f3f9915713f958979a4c35a53378fb /src/system.hh.in
parent1b8811f997568d8aede86197a36fc65586996494 (diff)
downloadfork-ledger-a757b19f51ac7aa120e6829b573187b1ff36301a.tar.gz
fork-ledger-a757b19f51ac7aa120e6829b573187b1ff36301a.tar.bz2
fork-ledger-a757b19f51ac7aa120e6829b573187b1ff36301a.zip
Added serialization methods for most type
This allows journal_t objects to be completed serialized to disk and deserialized.
Diffstat (limited to 'src/system.hh.in')
-rw-r--r--src/system.hh.in74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/system.hh.in b/src/system.hh.in
index 56cb491b..8495600e 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -167,6 +167,80 @@ typedef std::ostream::pos_type ostream_pos_type;
#include <boost/variant.hpp>
#include <boost/version.hpp>
+#if defined(HAVE_BOOST_SERIALIZATION)
+
+#include <boost/archive/binary_iarchive.hpp>
+#include <boost/archive/binary_oarchive.hpp>
+
+#include <boost/serialization/base_object.hpp>
+#include <boost/serialization/binary_object.hpp>
+#include <boost/serialization/optional.hpp>
+#include <boost/serialization/shared_ptr.hpp>
+#include <boost/serialization/variant.hpp>
+#include <boost/serialization/utility.hpp>
+#include <boost/serialization/export.hpp>
+#include <boost/serialization/level.hpp>
+#include <boost/serialization/string.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/deque.hpp>
+#include <boost/serialization/list.hpp>
+#include <boost/serialization/map.hpp>
+
+#include <boost/date_time/posix_time/time_serialize.hpp>
+#include <boost/date_time/gregorian/greg_serialize.hpp>
+
+BOOST_CLASS_IMPLEMENTATION(boost::filesystem::path, boost::serialization::primitive_type)
+#ifndef BOOST_NO_STD_WSTRING
+BOOST_CLASS_IMPLEMENTATION(boost::filesystem::wpath, boost::serialization::primitive_type)
+#endif
+
+namespace boost {
+namespace serialization {
+
+template <class Archive, class String, class Traits>
+void serialize(Archive& ar, boost::filesystem::basic_path<String, Traits>& p,
+ const unsigned int)
+{
+ String s;
+ if (Archive::is_saving::value)
+ s = p.string();
+
+ ar & s;
+
+ if (Archive::is_loading::value)
+ p = s;
+}
+
+template <class Archive, class T>
+void serialize(Archive& ar, boost::intrusive_ptr<T>& ptr, const unsigned int)
+{
+ if (Archive::is_saving::value) {
+ T * p = ptr.get();
+ ar & p;
+ }
+ else if (Archive::is_loading::value) {
+ T * p;
+ ar & p;
+ ptr.reset(p);
+ }
+}
+
+template <class Archive, class T>
+void serialize(Archive&, boost::function<T>&, const unsigned int)
+{
+}
+
+template <class Archive>
+void serialize(Archive& ar, istream_pos_type& pos, const unsigned int)
+{
+ ar & make_binary_object(&pos, sizeof(istream_pos_type));
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif // HAVE_BOOST_SERIALIZATION
+
#if defined(HAVE_BOOST_PYTHON)
#include <boost/python.hpp>