C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
Archive.h
Go to the documentation of this file.
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
3 #ifndef CPPQEDCORE_UTILS_ARCHIVE_H_INCLUDED
4 #define CPPQEDCORE_UTILS_ARCHIVE_H_INCLUDED
5 
6 #include "core_config.h"
7 
8 #ifdef DO_NOT_USE_BOOST_SERIALIZATION
9 
10 #include <cstddef> // std::size_t
11 #include <iosfwd>
12 
13 #include <boost/mpl/bool.hpp>
14 
15 
16 namespace cpputils {
17 
19 
20 
22 
23 class trivial_iarchive {
24 public:
25  typedef boost::mpl::bool_<false> is_saving;
26  typedef boost::mpl::bool_<true> is_loading;
27 
28  trivial_iarchive(std::istream&) {}
29 
30  template<class T> void register_type(){}
31  template<class T> trivial_iarchive & operator>>(const T & ){
32  return *this;
33  }
34  template<class T> trivial_iarchive & operator&(const T & t){
35  return *this >> t;
36  }
37  void load_binary(void *, std::size_t){};
38 };
39 
40 
42 
43 class trivial_oarchive {
44 public:
45  typedef boost::mpl::bool_<true> is_saving;
46  typedef boost::mpl::bool_<false> is_loading;
47 
48  trivial_oarchive(std::ostream&) {}
49 
50  template<class T> void register_type(){}
51  template<class T> trivial_oarchive & operator<<(const T & ){
52  return *this;
53  }
54  template<class T> trivial_oarchive & operator&(const T & t){
55  return *this << t;
56  }
57  void save_binary(void *, std::size_t){};
58 };
59 
60 
61 typedef trivial_iarchive iarchive;
62 typedef trivial_oarchive oarchive;
63 
64 } // cpputils
65 
66 #else // DO_NOT_USE_BOOST_SERIALIZATION
67 
68 #include <boost/archive/binary_oarchive.hpp>
69 #include <boost/archive/binary_iarchive.hpp>
70 
71 namespace cpputils {
72 
73 typedef boost::archive::binary_iarchive iarchive;
74 typedef boost::archive::binary_oarchive oarchive;
75 
76 } // cpputils
77 
78 #endif // DO_NOT_USE_BOOST_SERIALIZATION
79 
80 #endif // CPPQEDCORE_UTILS_ARCHIVE_H_INCLUDED
Namespace comprising otherwise hard-to-classify generic utilities.
Definition: Algorithm.h:10
boost::archive::binary_oarchive oarchive
delegated to Boost.Serialization
Definition: Archive.h:74
boost::archive::binary_iarchive iarchive
delegated to Boost.Serialization
Definition: Archive.h:73