BIE |
/home/weinberg/src/BIE/persistence/BIE_polymorphic_xml_oarchive.h00001 #ifndef BIE_POLYMORPHIC_XML_OARCHIVE_HPP 00002 #define BIE_POLYMORPHIC_XML_OARCHIVE_HPP 00003 00004 00005 #include <boost/version.hpp> 00006 #include <boost/config.hpp> 00007 // #include <boost/archive/xml_oarchive.hpp> 00008 #if BOOST_VERSION <= 103500 00009 #include <boost/archive/detail/polymorphic_oarchive_dispatch.hpp> 00010 #else 00011 #include <boost/archive/polymorphic_xml_oarchive.hpp> 00012 #endif 00013 00014 namespace BIE { 00015 00016 template<class Archive> 00017 class BIE_xml_oarchive_impl : 00018 public boost::archive::xml_oarchive_impl<Archive> 00019 { 00020 /* #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS */ 00021 /* public: */ 00022 /* #else */ 00023 /* friend class boost::archive::detail::interface_oarchive<Archive>; */ 00024 /* friend class boost::archive::basic_xml_oarchive<Archive>; */ 00025 /* friend class boost::archive::save_access; */ 00026 /* protected: */ 00027 /* #endif */ 00028 public: 00029 template<class T> 00030 void save(const T & t){ 00031 boost::archive::xml_oarchive_impl<Archive>::save(t); 00032 } 00033 00034 template<class T> 00035 void save_override(const T & t, BOOST_PFTO int n) { 00036 boost::archive::xml_oarchive_impl<Archive>::save_override(t, n); 00037 } 00038 00039 BOOST_ARCHIVE_DECL(void) 00040 save_override(const float & t, int) { 00041 this->save_binary(&t, sizeof(t)); 00042 } 00043 00044 BOOST_ARCHIVE_DECL(void) 00045 save_override(const double & t, int) { 00046 this->save_binary(&t, sizeof(t)); 00047 } 00048 00049 BOOST_ARCHIVE_DECL(void) 00050 save(const char * t) { 00051 boost::archive::xml_oarchive_impl<Archive>::save(t); 00052 } 00053 #ifndef BOOST_NO_INTRINSIC_WCHAR_T 00054 BOOST_ARCHIVE_DECL(void) 00055 save(const wchar_t * t) { 00056 boost::archive::xml_oarchive_impl<Archive>::save(t); 00057 } 00058 #endif 00059 BOOST_ARCHIVE_DECL(void) 00060 save(const std::string &s) { 00061 boost::archive::xml_oarchive_impl<Archive>::save(s); 00062 } 00063 #ifndef BOOST_NO_STD_WSTRING 00064 BOOST_ARCHIVE_DECL(void) 00065 save(const std::wstring &ws) { 00066 boost::archive::xml_oarchive_impl<Archive>::save(ws); 00067 } 00068 #endif 00069 BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) 00070 BIE_xml_oarchive_impl(std::ostream & os, unsigned int flags) : 00071 boost::archive::xml_oarchive_impl<Archive>(os, flags) {} 00072 ~BIE_xml_oarchive_impl(){} 00073 }; 00074 00075 class BIE_xml_oarchive : 00076 public BIE_xml_oarchive_impl<BIE_xml_oarchive> 00077 { 00078 public: 00079 BIE_xml_oarchive(std::ostream & os, unsigned int flags = 0) : 00080 BIE_xml_oarchive_impl<BIE_xml_oarchive>(os, flags) 00081 {} 00082 ~BIE_xml_oarchive() {} 00083 }; 00084 00085 typedef BIE_xml_oarchive BIE_naked_xml_oarchive; 00086 00087 #if BOOST_VERSION <= 103500 00088 typedef boost::archive::detail::polymorphic_oarchive_dispatch< 00089 boost::archive::xml_oarchive_impl<BIE_naked_xml_oarchive> 00090 > BIE_polymorphic_xml_oarchive; 00091 #else 00092 typedef boost::archive::detail::polymorphic_oarchive_route< 00093 boost::archive::xml_oarchive_impl<BIE_naked_xml_oarchive> 00094 > BIE_polymorphic_xml_oarchive; 00095 #endif 00096 00097 } // namespace BIE 00098 00099 // required by export 00100 BOOST_SERIALIZATION_REGISTER_ARCHIVE(BIE::BIE_xml_oarchive) 00101 BOOST_SERIALIZATION_REGISTER_ARCHIVE(BIE::BIE_polymorphic_xml_oarchive) 00102 00103 #endif // BIE_POLYMORPHIC_XML_OARCHIVE_HPP 00104 Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU. Documentation generated at Fri Mar 26 00:35:11 2010 by
|