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

Revision 857, 5.0 KB checked in by igarcia, 19 years ago (diff)
Line 
1#ifndef BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
2#define BOOST_ARCHIVE_POLYMORPHIC_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// polymorphic_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 <cstddef> // size_t
20#include <string>
21
22#include <boost/config.hpp>
23#if defined(BOOST_NO_STDC_NAMESPACE)
24namespace std{
25    using ::size_t;
26} // namespace std
27#endif
28
29#include <boost/cstdint.hpp>
30#include <boost/pfto.hpp>
31#include <boost/archive/detail/oserializer.hpp>
32#include <boost/archive/detail/interface_oarchive.hpp>
33#include <boost/serialization/nvp.hpp>
34
35// determine if its necessary to handle (u)int64_t specifically
36// i.e. that its not a synonym for (unsigned) long
37// if there is no 64 bit int or if its the same as a long
38// we shouldn't define separate functions for int64 data types.
39#if defined(BOOST_NO_INT64_T) \
40    || (ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615u) // 2**64 - 1
41#   define BOOST_NO_INTRINSIC_INT64_T
42#endif
43
44namespace boost {
45template<class T>
46class shared_ptr;
47namespace serialization {
48    class extended_type_info;
49} // namespace serialization
50namespace archive {
51namespace detail {
52    class basic_oarchive;
53    class basic_oserializer;
54}
55
56class polymorphic_oarchive :
57    public detail::interface_oarchive<polymorphic_oarchive>
58{
59#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
60public:
61#else
62    friend class detail::interface_oarchive<polymorphic_oarchive>;
63    friend class save_access;
64#endif
65    // primitive types the only ones permitted by polymorphic archives
66    virtual void save(const bool t) = 0;
67
68    virtual void save(const char t) = 0;
69    virtual void save(const signed char t) = 0;
70    virtual void save(const unsigned char t) = 0;
71    #ifndef BOOST_NO_CWCHAR
72    #ifndef BOOST_NO_INTRINSIC_WCHAR_T
73    virtual void save(const wchar_t t) = 0;
74    #endif
75    #endif
76    virtual void save(const short t) = 0;
77    virtual void save(const unsigned short t) = 0;
78    virtual void save(const int t) = 0;
79    virtual void save(const unsigned int t) = 0;
80    virtual void save(const long t) = 0;
81    virtual void save(const unsigned long t) = 0;
82    #if !defined(BOOST_NO_INTRINSIC_INT64_T)
83    virtual void save(const boost::int64_t t) = 0;
84    virtual void save(const boost::uint64_t t) = 0;
85    #endif
86    virtual void save(const float t) = 0;
87    virtual void save(const double t) = 0;
88
89    // string types are treated as primitives
90    virtual void save(const std::string & t) = 0;
91    #ifndef BOOST_NO_STD_WSTRING
92    virtual void save(const std::wstring & t) = 0;
93    #endif
94
95    virtual void save_null_pointer() = 0;
96    // used for xml and other tagged formats
97    virtual void save_start(const char * name) = 0;
98    virtual void save_end(const char * name) = 0;
99    virtual void register_basic_serializer(const detail::basic_oserializer & bos) = 0;
100    virtual void lookup_basic_helper(
101        const boost::serialization::extended_type_info * const eti,
102                boost::shared_ptr<void> & sph
103    ) = 0;
104    virtual void insert_basic_helper(
105        const boost::serialization::extended_type_info * const eti,
106                shared_ptr<void> & sph
107    ) = 0;
108
109    virtual unsigned int get_library_version() const = 0;
110    virtual void end_preamble() = 0;
111
112    // msvc and borland won't automatically pass these to the base class so
113    // make it explicit here
114    template<class T>
115    void save_override(T & t, BOOST_PFTO int)
116    {
117        archive::save(* this, t);
118    }
119    // special treatment for name-value pairs.
120    template<class T>
121    void save_override(
122                #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
123                const
124                #endif
125                ::boost::serialization::nvp<T> & t, int
126        ){
127        save_start(t.name());
128        archive::save(* this, t.const_value());
129        save_end(t.name());
130    }
131public:
132    virtual unsigned int get_flags() const = 0;
133    // utility function implemented by all legal archives
134    virtual void save_binary(const void * t, std::size_t size) = 0;
135
136    virtual void save_object(
137        const void *x,
138        const detail::basic_oserializer & bos
139    ) = 0;
140    virtual void save_pointer(
141        const void * t,
142        const detail::basic_pointer_oserializer * bpos_ptr
143    ) = 0;
144};
145
146} // namespace archive
147} // namespace boost
148
149// required by smart_cast for compilers not implementing
150// partial template specialization
151BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_oarchive)
152
153#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
Note: See TracBrowser for help on using the repository browser.