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
15namespace msgpack {
16
20
21namespace type {
22
23struct nil_t { };
24
25inline bool operator<(nil_t const& lhs, nil_t const& rhs) {
26 return &lhs < &rhs;
27}
28
29inline bool operator==(nil_t const& lhs, nil_t const& rhs) {
30 return &lhs == &rhs;
31}
32
33} // namespace type
34
35namespace adaptor {
36
37template <>
38struct convert<type::nil_t> {
40 if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
41 return o;
42 }
43};
44
45template <>
46struct pack<type::nil_t> {
47 template <typename Stream>
49 o.pack_nil();
50 return o;
51 }
52};
53
54template <>
55struct object<type::nil_t> {
58 }
59};
60
61template <>
62struct 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
The class template that supports continuous packing.
Definition: pack.hpp:33
packer< Stream > & pack_nil()
Packing nil.
Definition: pack.hpp:1192
Definition: object_fwd.hpp:231
bool operator<(basic_variant< STR, BIN, EXT > const &lhs, basic_variant< STR, BIN, EXT > const &rhs)
Definition: msgpack_variant.hpp:258
@ NIL
Definition: object_fwd_decl.hpp:28
bool operator==(basic_variant< STR, BIN, EXT > const &lhs, basic_variant< STR, BIN, EXT > const &rhs)
Definition: msgpack_variant.hpp:265
Definition: adaptor_base.hpp:15
msgpack::object const & operator()(msgpack::object const &o, type::nil_t &) const
Definition: nil.hpp:39
Definition: adaptor_base.hpp:27
void operator()(msgpack::object &o, type::nil_t) const
Definition: nil.hpp:56
void operator()(msgpack::object::with_zone &o, type::nil_t v) const
Definition: nil.hpp:63
Definition: adaptor_base.hpp:43
Definition: adaptor_base.hpp:38
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::nil_t &) const
Definition: nil.hpp:48
Definition: adaptor_base.hpp:32
Definition: object.hpp:35
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::type::object_type type
Definition: object_fwd.hpp:92
Definition: nil.hpp:23
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66