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

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