nvp.hpp
Go to the documentation of this file.
1 #ifndef BOOST_SERIALIZATION_NVP_HPP
2 #define BOOST_SERIALIZATION_NVP_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 
10 // nvp.hpp: interface for serialization system.
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 <utility>
20 
21 #include <boost/config.hpp>
23 
30 
31 namespace boost {
32 namespace serialization {
33 
34 template<class T>
35 struct nvp :
36  public std::pair<const char *, T *>,
37  public wrapper_traits<const nvp< T > >
38 {
39 //private:
40  nvp(const nvp & rhs) :
41  std::pair<const char *, T *>(rhs.first, rhs.second)
42  {}
43 public:
44  explicit nvp(const char * name_, T & t) :
45  // note: added _ to suppress useless gcc warning
46  std::pair<const char *, T *>(name_, & t)
47  {}
48 
49  const char * name() const {
50  return this->first;
51  }
52  T & value() const {
53  return *(this->second);
54  }
55 
56  const T & const_value() const {
57  return *(this->second);
58  }
59 
60  template<class Archive>
61  void save(
62  Archive & ar,
63  const unsigned int /* file_version */
64  ) const {
65  ar.operator<<(const_value());
66  }
67  template<class Archive>
68  void load(
69  Archive & ar,
70  const unsigned int /* file_version */
71  ){
72  ar.operator>>(value());
73  }
75 };
76 
77 template<class T>
78 inline
79 const nvp< T > make_nvp(const char * name, T & t){
80  return nvp< T >(name, t);
81 }
82 
83 // to maintain efficiency and portability, we want to assign
84 // specific serialization traits to all instances of this wrappers.
85 // we can't strait forward method below as it depends upon
86 // Partial Template Specialization and doing so would mean that wrappers
87 // wouldn't be treated the same on different platforms. This would
88 // break archive portability. Leave this here as reminder not to use it !!!
89 
90 template <class T>
92 {
93  typedef mpl::integral_c_tag tag;
94  typedef mpl::int_<object_serializable> type;
95  BOOST_STATIC_CONSTANT(int, value = implementation_level::type::value);
96 };
97 
98 // nvp objects are generally created on the stack and are never tracked
99 template<class T>
100 struct tracking_level<nvp< T > >
101 {
102  typedef mpl::integral_c_tag tag;
103  typedef mpl::int_<track_never> type;
104  BOOST_STATIC_CONSTANT(int, value = tracking_level::type::value);
105 };
106 
107 } // seralization
108 } // boost
109 
111 
112 #define BOOST_SERIALIZATION_NVP(name) \
113  boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), name)
114 
115 
116 #define BOOST_SERIALIZATION_BASE_OBJECT_NVP(name) \
117  boost::serialization::make_nvp( \
118  BOOST_PP_STRINGIZE(name), \
119  boost::serialization::base_object<name >(*this) \
120  )
121 
122 
123 #endif // BOOST_SERIALIZATION_NVP_HPP
boost::serialization::nvp::save
void save(Archive &ar, const unsigned int) const
Definition: nvp.hpp:61
wrapper.hpp
traits.hpp
T
T
Definition: mem_fn_cc.hpp:25
config.hpp
level.hpp
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::serialization::tracking_level< nvp< T > >::type
mpl::int_< track_never > type
Definition: nvp.hpp:103
boost::serialization::tracking_level< nvp< T > >::tag
mpl::integral_c_tag tag
Definition: nvp.hpp:102
boost::serialization::implementation_level< nvp< T > >::tag
mpl::integral_c_tag tag
Definition: nvp.hpp:93
tracking.hpp
boost::serialization::nvp::nvp
nvp(const nvp &rhs)
Definition: nvp.hpp:40
boost::serialization::nvp
Definition: nvp.hpp:35
boost::serialization::nvp::value
T & value() const
Definition: nvp.hpp:52
boost::serialization::nvp::nvp
nvp(const char *name_, T &t)
Definition: nvp.hpp:44
boost::serialization::implementation_level< nvp< T > >::type
mpl::int_< object_serializable > type
Definition: nvp.hpp:94
stringize.hpp
boost::serialization::tracking_level_impl< const T >::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(int, value=type::value)
boost::serialization::wrapper_traits
Definition: wrapper.hpp:29
boost::serialization::nvp::name
const char * name() const
Definition: nvp.hpp:49
boost::serialization::nvp::const_value
const T & const_value() const
Definition: nvp.hpp:56
BOOST_SERIALIZATION_SPLIT_MEMBER
#define BOOST_SERIALIZATION_SPLIT_MEMBER()
Definition: split_member.hpp:76
split_member.hpp
boost::serialization::tracking_level
Definition: tracking.hpp:74
boost::serialization::implementation_level_impl< const T >::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(int, value=type::value)
std
boost::serialization::make_nvp
const nvp< T > make_nvp(const char *name, T &t)
Definition: nvp.hpp:79
base_object.hpp
workaround.hpp
boost::serialization::nvp::load
void load(Archive &ar, const unsigned int)
Definition: nvp.hpp:68
boost::serialization::implementation_level
Definition: level.hpp:83


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:45:33