source: NonGTP/Boost/boost/archive/binary_oarchive.hpp @ 857

Revision 857, 3.0 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1#ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
2#define BOOST_ARCHIVE_BINARY_OARCHIVE_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.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/archive/detail/auto_link_archive.hpp>
21#include <boost/archive/basic_binary_oprimitive.hpp>
22#include <boost/archive/basic_binary_oarchive.hpp>
23
24#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
25
26namespace boost {
27namespace archive {
28
29template<class Archive>
30class binary_oarchive_impl :
31    public basic_binary_oprimitive<Archive, std::ostream>,
32    public basic_binary_oarchive<Archive>
33{
34#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
35public:
36#else
37    friend class detail::interface_oarchive<Archive>;
38    friend class basic_binary_oarchive<Archive>;
39    friend class save_access;
40protected:
41#endif
42    // note: the following should not needed - but one compiler (vc 7.1)
43    // fails to compile one test (test_shared_ptr) without it !!!
44    // make this protected so it can be called from a derived archive
45    template<class T>
46    void save_override(T & t, BOOST_PFTO int){
47        basic_binary_oarchive<Archive>::save_override(t, 0);
48    }
49    void init() {
50        #if ! defined(__MWERKS__)
51            this->basic_binary_oarchive<Archive>::init();
52            this->basic_binary_oprimitive<Archive, std::ostream>::init();
53        #else
54            basic_binary_oarchive<Archive>::init();
55            basic_binary_oprimitive<Archive, std::ostream>::init();
56        #endif
57    }
58    binary_oarchive_impl(std::ostream & os, unsigned int flags) :
59        basic_binary_oprimitive<Archive, std::ostream>(
60            os,
61            0 != (flags & no_codecvt)
62        ),
63        basic_binary_oarchive<Archive>(flags)
64    {
65        if(0 == (flags & no_header))
66            init();
67    }
68};
69
70// do not derive from this class.  If you want to extend this functionality
71// via inhertance, derived from binary_oarchive_impl instead.  This will
72// preserve correct static polymorphism.
73class binary_oarchive :
74    public binary_oarchive_impl<binary_oarchive>
75{
76public:
77    binary_oarchive(std::ostream & os, unsigned int flags = 0) :
78        binary_oarchive_impl<binary_oarchive>(os, flags)
79    {}
80};
81
82} // namespace archive
83} // namespace boost
84
85// required by smart_cast for compilers not implementing
86// partial template specialization
87BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_oarchive)
88
89#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
90
91#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.