7 #ifndef COAL_SERIALIZATION_ARCHIVE_H 
    8 #define COAL_SERIALIZATION_ARCHIVE_H 
   12 #include <boost/serialization/nvp.hpp> 
   13 #include <boost/archive/text_iarchive.hpp> 
   14 #include <boost/archive/text_oarchive.hpp> 
   15 #include <boost/archive/xml_iarchive.hpp> 
   16 #include <boost/archive/xml_oarchive.hpp> 
   17 #include <boost/archive/binary_iarchive.hpp> 
   18 #include <boost/archive/binary_oarchive.hpp> 
   25 #if BOOST_VERSION / 100 % 1000 == 78 && __APPLE__ 
   29 #ifndef BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC 
   30 #define DEFINE_BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC 
   31 #define BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC 
   34 #include <boost/asio/streambuf.hpp> 
   36 #ifdef DEFINE_BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC 
   37 #undef BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC 
   41 #include <boost/asio/streambuf.hpp> 
   44 #include <boost/iostreams/device/array.hpp> 
   45 #include <boost/iostreams/stream.hpp> 
   46 #include <boost/iostreams/stream_buffer.hpp> 
   49 #include <boost/math/special_functions/nonfinite_num_facets.hpp> 
   52 namespace serialization {
 
   66     std::locale 
const new_loc(ifs.getloc(),
 
   67                               new boost::math::nonfinite_num_get<char>);
 
   69     boost::archive::text_iarchive ia(ifs, boost::archive::no_codecvt);
 
   72     const std::string exception_message(
filename +
 
   73                                         " does not seem to be a valid file.");
 
   74     throw std::invalid_argument(exception_message);
 
   90     boost::archive::text_oarchive oa(ofs);
 
   93     const std::string exception_message(
filename +
 
   94                                         " does not seem to be a valid file.");
 
   95     throw std::invalid_argument(exception_message);
 
  108 template <
typename T>
 
  110   std::locale 
const new_loc(is.getloc(),
 
  111                             new boost::math::nonfinite_num_get<char>);
 
  113   boost::archive::text_iarchive ia(is, boost::archive::no_codecvt);
 
  126 template <
typename T>
 
  128   boost::archive::text_oarchive oa(ss);
 
  140 template <
typename T>
 
  142   std::istringstream is(
str);
 
  155 template <
typename T>
 
  157   std::stringstream ss;
 
  171 template <
typename T>
 
  173                         const std::string& tag_name) {
 
  178   std::ifstream ifs(
filename.c_str());
 
  180     std::locale 
const new_loc(ifs.getloc(),
 
  181                               new boost::math::nonfinite_num_get<char>);
 
  183     boost::archive::xml_iarchive ia(ifs, boost::archive::no_codecvt);
 
  184     ia >> boost::serialization::make_nvp(tag_name.c_str(), 
object);
 
  186     const std::string exception_message(
filename +
 
  187                                         " does not seem to be a valid file.");
 
  188     throw std::invalid_argument(exception_message);
 
  201 template <
typename T>
 
  203                       const std::string& tag_name) {
 
  208   std::ofstream ofs(
filename.c_str());
 
  210     boost::archive::xml_oarchive oa(ofs);
 
  211     oa& boost::serialization::make_nvp(tag_name.c_str(), 
object);
 
  213     const std::string exception_message(
filename +
 
  214                                         " does not seem to be a valid file.");
 
  215     throw std::invalid_argument(exception_message);
 
  227 template <
typename T>
 
  229   std::ifstream ifs(
filename.c_str(), std::ios::binary);
 
  231     boost::archive::binary_iarchive ia(ifs);
 
  234     const std::string exception_message(
filename +
 
  235                                         " does not seem to be a valid file.");
 
  236     throw std::invalid_argument(exception_message);
 
  248 template <
typename T>
 
  250   std::ofstream ofs(
filename.c_str(), std::ios::binary);
 
  252     boost::archive::binary_oarchive oa(ofs);
 
  255     const std::string exception_message(
filename +
 
  256                                         " does not seem to be a valid file.");
 
  257     throw std::invalid_argument(exception_message);
 
  269 template <
typename T>
 
  271   boost::archive::binary_iarchive ia(buffer);
 
  283 template <
typename T>
 
  285   boost::archive::binary_oarchive oa(buffer);
 
  292 #endif  // ifndef COAL_SERIALIZATION_ARCHIVE_H