• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_SERIALIZATION_COLLECTION_TRAITS_HPP
2 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // collection_traits.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 // This header assigns a level implemenation trait to a collection type
20 // for all primitives.  It is needed so that archives which are meant to be
21 // portable don't write class information in the archive.  Since, not all
22 // compiles recognize the same set of primitive types, the possibility
23 // exists for archives to be non-portable if class information for primitive
24 // types is included.  This is addressed by the following macros.
25 #include <boost/config.hpp>
26 #include <boost/mpl/integral_c_tag.hpp>
27 
28 #include <boost/cstdint.hpp>
29 #include <boost/integer_traits.hpp>
30 #include <climits> // ULONG_MAX
31 #include <boost/serialization/level.hpp>
32 
33 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(T, C)          \
34 template<>                                                          \
35 struct implementation_level< C < T > > {                            \
36     typedef mpl::integral_c_tag tag;                                \
37     typedef mpl::int_<object_serializable> type;                    \
38     BOOST_STATIC_CONSTANT(int, value = object_serializable);        \
39 };                                                                  \
40 /**/
41 
42 #if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_INTRINSIC_WCHAR_T)
43     #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)
44 #else
45     #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)   \
46     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(wchar_t, C)        \
47     /**/
48 #endif
49 
50 #if defined(BOOST_HAS_LONG_LONG)
51     #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)    \
52     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::long_long_type, C)  \
53     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::ulong_long_type, C) \
54     /**/
55 #else
56     #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)
57 #endif
58 
59 #define BOOST_SERIALIZATION_COLLECTION_TRAITS(C)                     \
60     namespace boost { namespace serialization {                      \
61     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(bool, C)            \
62     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(char, C)            \
63     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed char, C)     \
64     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned char, C)   \
65     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed int, C)      \
66     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned int, C)    \
67     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed long, C)     \
68     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned long, C)   \
69     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(float, C)           \
70     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(double, C)          \
71     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned short, C)  \
72     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed short, C)    \
73     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C)            \
74     BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C)            \
75     } }                                                              \
76     /**/
77 
78 #endif // BOOST_SERIALIZATION_COLLECTION_TRAITS
79