Collage  1.6.0
High-performance C++ library for developing object-oriented distributed applications.
dataIStreamArchive.h
1 
2 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@googlemail.com>
3  * 2012, Stefan Eilemann <eile@eyescale.ch>
4  *
5  * This file is part of Collage <https://github.com/Eyescale/Collage>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 2.1 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 // Based on portable_iarchive.hpp
22 // https://github.com/boost-vault/serialization/eos_portable_archive.zip
23 // Copyright Christian Pfligersdorffer, 2007. All rights reserved.
24 //
25 // Distributed under the Boost Software License, Version 1.0. (See
26 // accompanying file LICENSE_1_0.txt or copy at
27 // http://www.boost.org/LICENSE_1_0.txt)
28 
29 #ifndef CO_DATAISTREAMARCHIVE_H
30 #define CO_DATAISTREAMARCHIVE_H
31 
32 #include <co/api.h>
33 #include <co/types.h>
34 
35 #include <boost/version.hpp>
36 #pragma warning( push )
37 #pragma warning( disable: 4800 )
38 #include <boost/archive/basic_binary_iarchive.hpp>
39 #pragma warning( pop )
40 #include <boost/archive/detail/register_archive.hpp>
41 #if BOOST_VERSION < 105600
42 # include <boost/archive/shared_ptr_helper.hpp>
43 #endif
44 #include <boost/serialization/is_bitwise_serializable.hpp>
45 
46 #include <boost/spirit/home/support/detail/endian.hpp>
47 #include <boost/spirit/home/support/detail/math/fpclassify.hpp>
48 
49 #include <boost/type_traits/is_integral.hpp>
50 #include <boost/type_traits/is_unsigned.hpp>
51 #include <boost/type_traits/is_floating_point.hpp>
52 
53 #include <boost/utility/enable_if.hpp>
54 
55 namespace co
56 {
59  : public boost::archive::basic_binary_iarchive< DataIStreamArchive >
60 #if BOOST_VERSION < 105600
61  , public boost::archive::detail::shared_ptr_helper
62 #endif
63 {
64  typedef boost::archive::basic_binary_iarchive< DataIStreamArchive > Super;
65 
66 public:
68  CO_API explicit DataIStreamArchive( DataIStream& stream );
69 
71  CO_API void load_binary( void* data, std::size_t size );
72 
74  template< typename T >
75  void load_array( boost::serialization::array< T >& a, unsigned int );
76 
79  {
80  template< class T >
81  struct apply
82  : public boost::serialization::is_bitwise_serializable< T > {};
83  };
84 
85 private:
86  friend class boost::archive::load_access;
87 
95  CO_API void load( bool& b );
96 
98  template< class C, class T, class A >
99  void load( std::basic_string< C, T, A >& s );
100 
108  template< typename T >
109  typename boost::enable_if< boost::is_integral<T> >::type load( T& t );
110 
138  template< typename T >
139  typename boost::enable_if< boost::is_floating_point<T> >::type load( T& t );
140 
141 #if BOOST_VERSION >= 104400
142  // in boost 1.44 version_type was splitted into library_version_type and
143  // item_version_type, plus a whole bunch of additional strong typedefs
144  CO_API void load( boost::archive::library_version_type& version );
145  CO_API void load( boost::archive::class_id_type& class_id );
146  CO_API void load( boost::serialization::item_version_type& version );
147  CO_API void load( boost::serialization::collection_size_type& version );
148  CO_API void load( boost::archive::object_id_type& object_id );
149  CO_API void load( boost::archive::version_type& version );
150 #endif
151 
152  CO_API signed char _loadSignedChar();
153 
154  DataIStream& _stream;
155 };
156 
157 }
158 
159 #include "dataIStreamArchive.ipp" // template implementation
160 
161 // contains load_override impl for class_name_type
162 #include <boost/archive/impl/basic_binary_iarchive.ipp>
163 
164 BOOST_SERIALIZATION_REGISTER_ARCHIVE(co::DataIStreamArchive)
165 BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(co::DataIStreamArchive)
166 
167 #endif //CO_DATAISTREAMARCHIVE_H
A boost.serialization input archive reading from a co::DataIStream.
Defines export visibility macros for library Collage.
Object-oriented network library.
Definition: barrier.h:27
A std::istream-like input data stream for binary data.
Definition: dataIStream.h:41
CO_API DataIStreamArchive(DataIStream &stream)
Construct a new deserialization archive.