|
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) && (_MSC_VER >= 1020) |
|
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.hpp> |
|
27 #include <boost/mpl/integral_c_tag.hpp> |
|
28 |
|
29 #include <boost/cstdint.hpp> |
|
30 #include <boost/serialization/level.hpp> |
|
31 |
|
32 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(T, C) \ |
|
33 template<> \ |
|
34 struct implementation_level< C < T > > { \ |
|
35 typedef mpl::integral_c_tag tag; \ |
|
36 typedef mpl::int_<object_serializable> type; \ |
|
37 BOOST_STATIC_CONSTANT(int, value = object_serializable); \ |
|
38 }; \ |
|
39 /**/ |
|
40 |
|
41 #if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_INTRINSIC_WCHAR_T) |
|
42 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) |
|
43 #else |
|
44 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \ |
|
45 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(wchar_t, C) \ |
|
46 /**/ |
|
47 #endif |
|
48 |
|
49 // determine if its necessary to handle (u)int64_t specifically |
|
50 // i.e. that its not a synonym for (unsigned) long |
|
51 // if there is no 64 bit int or if its the same as a long |
|
52 // we shouldn't define separate functions for int64 data types. |
|
53 #if defined(BOOST_NO_INT64_T) \ |
|
54 || (ULONG_MAX != 0xffffffff && ULONG_MAX == 18446744073709551615u) // 2**64 - 1 |
|
55 # define BOOST_NO_INTRINSIC_INT64_T |
|
56 #endif |
|
57 |
|
58 #if !defined(BOOST_NO_INTRINSIC_INT64_T) |
|
59 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \ |
|
60 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::int64_t, C) \ |
|
61 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(boost::uint64_t, C) \ |
|
62 /**/ |
|
63 #else |
|
64 #define BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) |
|
65 #endif |
|
66 |
|
67 #define BOOST_SERIALIZATION_COLLECTION_TRAITS(C) \ |
|
68 namespace boost { namespace serialization { \ |
|
69 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(bool, C) \ |
|
70 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(char, C) \ |
|
71 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed char, C) \ |
|
72 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned char, C) \ |
|
73 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed int, C) \ |
|
74 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned int, C) \ |
|
75 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed long, C) \ |
|
76 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned long, C) \ |
|
77 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(float, C) \ |
|
78 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(double, C) \ |
|
79 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(unsigned short, C) \ |
|
80 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER(signed short, C) \ |
|
81 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_INT64(C) \ |
|
82 BOOST_SERIALIZATION_COLLECTION_TRAITS_HELPER_WCHAR(C) \ |
|
83 } } \ |
|
84 /**/ |
|
85 |
|
86 #endif // BOOST_SERIALIZATION_COLLECTION_TRAITS |