MessagePack for C++
nil.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ static resolution routine
3 //
4 // Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 #ifndef MSGPACK_V1_TYPE_NIL_HPP
11 #define MSGPACK_V1_TYPE_NIL_HPP
12 
14 
15 namespace msgpack {
16 
20 
21 namespace type {
22 
23 struct nil_t { };
24 
25 inline bool operator<(nil_t const& lhs, nil_t const& rhs) {
26  return &lhs < &rhs;
27 }
28 
29 inline bool operator==(nil_t const& lhs, nil_t const& rhs) {
30  return &lhs == &rhs;
31 }
32 
33 } // namespace type
34 
35 namespace adaptor {
36 
37 template <>
38 struct convert<type::nil_t> {
40  if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
41  return o;
42  }
43 };
44 
45 template <>
46 struct pack<type::nil_t> {
47  template <typename Stream>
49  o.pack_nil();
50  return o;
51  }
52 };
53 
54 template <>
55 struct object<type::nil_t> {
58  }
59 };
60 
61 template <>
62 struct object_with_zone<type::nil_t> {
64  static_cast<msgpack::object&>(o) << v;
65  }
66 };
67 
68 } // namespace adaptor
69 
71 } // MSGPACK_API_VERSION_NAMESPACE(v1)
73 
74 } // namespace msgpack
75 
76 #endif // MSGPACK_V1_TYPE_NIL_HPP
msgpack::type::operator==
bool operator==(nil_t const &lhs, nil_t const &rhs)
Definition: nil.hpp:29
msgpack::adaptor::convert< type::nil_t >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::nil_t &) const
Definition: nil.hpp:39
msgpack::packer
The class template that supports continuous packing.
Definition: adaptor_base_decl.hpp:24
msgpack::adaptor::object_with_zone
Definition: adaptor_base.hpp:43
msgpack
Definition: adaptor_base.hpp:15
msgpack::adaptor::convert
Definition: adaptor_base.hpp:27
nil_decl.hpp
msgpack::type::operator<
bool operator<(nil_t const &lhs, nil_t const &rhs)
Definition: nil.hpp:25
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
msgpack::adaptor::object_with_zone< type::nil_t >::operator()
void operator()(msgpack::object::with_zone &o, type::nil_t v) const
Definition: nil.hpp:63
msgpack::adaptor::object< type::nil_t >::operator()
void operator()(msgpack::object &o, type::nil_t) const
Definition: nil.hpp:56
msgpack::adaptor::object
Definition: adaptor_base.hpp:38
msgpack::type::NIL
@ NIL
Definition: object_fwd_decl.hpp:29
msgpack::adaptor::pack< type::nil_t >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::nil_t &) const
Definition: nil.hpp:48
msgpack::type_error
Definition: object_fwd.hpp:236
msgpack::adaptor::pack
Definition: adaptor_base.hpp:32
msgpack::packer::pack_nil
packer< Stream > & pack_nil()
Packing nil.
Definition: pack.hpp:1135
msgpack::type::nil_t
Definition: nil.hpp:23
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
v2::object::with_zone
Definition: object.hpp:35
msgpack::object::type
msgpack::type::object_type type
Definition: object_fwd.hpp:92