nil.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V1_TYPE_NIL_HPP
#define MSGPACK_V1_TYPE_NIL_HPP
#include "msgpack/v1/adaptor/nil_decl.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
struct nil_t { };
inline bool operator<(nil_t const& lhs, nil_t const& rhs) {
return &lhs < &rhs;
}
inline bool operator==(nil_t const& lhs, nil_t const& rhs) {
return &lhs == &rhs;
}
} // namespace type
namespace adaptor {
template <>
struct convert<type::nil_t> {
msgpack::object const& operator()(msgpack::object const& o, type::nil_t&) const {
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
return o;
}
};
template <>
struct pack<type::nil_t> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::nil_t&) const {
o.pack_nil();
return o;
}
};
template <>
struct object<type::nil_t> {
void operator()(msgpack::object& o, type::nil_t) const {
o.type = msgpack::type::NIL;
}
};
template <>
struct object_with_zone<type::nil_t> {
void operator()(msgpack::object::with_zone& o, type::nil_t v) const {
static_cast<msgpack::object&>(o) << v;
}
};
} // namespace adaptor
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_TYPE_NIL_HPP
msgpack::type::nil_t
Definition: nil.hpp:23
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
Definition: adaptor_base.hpp:15
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::object::with_zone
Definition: object.hpp:34
nil_decl.hpp
msgpack::type::NIL
Definition: object_fwd_decl.hpp:29
msgpack::adaptor::object< type::nil_t >::operator()
void operator()(msgpack::object &o, type::nil_t) const
Definition: nil.hpp:56
msgpack::adaptor::object_with_zone
Definition: adaptor_base.hpp:43
msgpack::type_error
Definition: object_fwd.hpp:236
msgpack::adaptor::pack
Definition: adaptor_base.hpp:32
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::object::type
msgpack::type::object_type type
Definition: object_fwd.hpp:92
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
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::adaptor::object
Definition: adaptor_base.hpp:38
msgpack::packer
The class template that supports continuous packing.
Definition: adaptor_base_decl.hpp:24
msgpack::packer::pack_nil
packer< Stream > & pack_nil()
Packing nil.
Definition: pack.hpp:1135
msgpack::adaptor::convert
Definition: adaptor_base.hpp:27
msgpack::type::operator<
bool operator<(nil_t const &lhs, nil_t const &rhs)
Definition: nil.hpp:25