| 1 | #ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP |
|---|
| 2 | #define BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP |
|---|
| 3 | |
|---|
| 4 | // MS compatible compilers support #pragma once |
|---|
| 5 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
|---|
| 6 | # pragma once |
|---|
| 7 | #endif |
|---|
| 8 | |
|---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|
| 10 | // binary_oarchive_impl.hpp |
|---|
| 11 | |
|---|
| 12 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
|---|
| 13 | // Use, modification and distribution is subject to the Boost Software |
|---|
| 14 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 15 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 16 | |
|---|
| 17 | // See http://www.boost.org for updates, documentation, and revision history. |
|---|
| 18 | |
|---|
| 19 | #include <ostream> |
|---|
| 20 | #include <boost/pfto.hpp> |
|---|
| 21 | #include <boost/archive/basic_binary_oprimitive.hpp> |
|---|
| 22 | #include <boost/archive/basic_binary_oarchive.hpp> |
|---|
| 23 | |
|---|
| 24 | namespace boost { |
|---|
| 25 | namespace archive { |
|---|
| 26 | |
|---|
| 27 | template<class Archive, class Elem, class Tr> |
|---|
| 28 | class binary_oarchive_impl : |
|---|
| 29 | public basic_binary_oprimitive<Archive, Elem, Tr>, |
|---|
| 30 | public basic_binary_oarchive<Archive> |
|---|
| 31 | { |
|---|
| 32 | #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS |
|---|
| 33 | public: |
|---|
| 34 | #else |
|---|
| 35 | friend class detail::interface_oarchive<Archive>; |
|---|
| 36 | friend class basic_binary_oarchive<Archive>; |
|---|
| 37 | friend class save_access; |
|---|
| 38 | protected: |
|---|
| 39 | #endif |
|---|
| 40 | // note: the following should not needed - but one compiler (vc 7.1) |
|---|
| 41 | // fails to compile one test (test_shared_ptr) without it !!! |
|---|
| 42 | // make this protected so it can be called from a derived archive |
|---|
| 43 | template<class T> |
|---|
| 44 | void save_override(T & t, BOOST_PFTO int){ |
|---|
| 45 | basic_binary_oarchive<Archive>::save_override(t, 0); |
|---|
| 46 | } |
|---|
| 47 | void init(unsigned int flags) { |
|---|
| 48 | if(0 != (flags & no_header)) |
|---|
| 49 | return; |
|---|
| 50 | #if ! defined(__MWERKS__) |
|---|
| 51 | this->basic_binary_oarchive<Archive>::init(); |
|---|
| 52 | this->basic_binary_oprimitive<Archive, Elem, Tr>::init(); |
|---|
| 53 | #else |
|---|
| 54 | basic_binary_oarchive<Archive>::init(); |
|---|
| 55 | basic_binary_oprimitive<Archive, Elem, Tr>::init(); |
|---|
| 56 | #endif |
|---|
| 57 | } |
|---|
| 58 | binary_oarchive_impl( |
|---|
| 59 | std::basic_streambuf<Elem, Tr> & bsb, |
|---|
| 60 | unsigned int flags |
|---|
| 61 | ) : |
|---|
| 62 | basic_binary_oprimitive<Archive, Elem, Tr>( |
|---|
| 63 | bsb, |
|---|
| 64 | 0 != (flags & no_codecvt) |
|---|
| 65 | ), |
|---|
| 66 | basic_binary_oarchive<Archive>(flags) |
|---|
| 67 | { |
|---|
| 68 | init(flags); |
|---|
| 69 | } |
|---|
| 70 | binary_oarchive_impl( |
|---|
| 71 | std::basic_ostream<Elem, Tr> & os, |
|---|
| 72 | unsigned int flags |
|---|
| 73 | ) : |
|---|
| 74 | basic_binary_oprimitive<Archive, Elem, Tr>( |
|---|
| 75 | * os.rdbuf(), |
|---|
| 76 | 0 != (flags & no_codecvt) |
|---|
| 77 | ), |
|---|
| 78 | basic_binary_oarchive<Archive>(flags) |
|---|
| 79 | { |
|---|
| 80 | init(flags); |
|---|
| 81 | } |
|---|
| 82 | }; |
|---|
| 83 | |
|---|
| 84 | } // namespace archive |
|---|
| 85 | } // namespace boost |
|---|
| 86 | |
|---|
| 87 | #endif // BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP |
|---|