bool.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2016 FURUHASHI Sadayuki
//
// 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_BOOL_HPP
#define MSGPACK_V1_TYPE_BOOL_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/adaptor/adaptor_base.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace adaptor {
template <>
struct convert<bool> {
msgpack::object const& operator()(msgpack::object const& o, bool& v) const {
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
v = o.via.boolean;
return o;
}
};
template <>
struct pack<bool> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const bool& v) const {
if(v) { o.pack_true(); }
else { o.pack_false(); }
return o;
}
};
template <>
struct object<bool> {
void operator()(msgpack::object& o, bool v) const {
o.type = msgpack::type::BOOLEAN;
o.via.boolean = v;
}
};
template <>
struct object_with_zone<bool> {
void operator()(msgpack::object::with_zone& o, bool v) const {
static_cast<msgpack::object&>(o) << v;
}
};
} // namespace adaptor
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_TYPE_BOOL_HPP
msgpack::type::BOOLEAN
Definition: object_fwd_decl.hpp:30
msgpack::adaptor::object< bool >::operator()
void operator()(msgpack::object &o, bool v) const
Definition: bool.hpp:45
msgpack::object::via
union_type via
Definition: object_fwd.hpp:93
adaptor_base.hpp
msgpack
Definition: adaptor_base.hpp:15
versioning.hpp
msgpack::packer::pack_false
packer< Stream > & pack_false()
Packing false.
Definition: pack.hpp:1151
msgpack::object::union_type::boolean
bool boolean
Definition: object_fwd.hpp:77
msgpack::object::with_zone
Definition: object.hpp:34
msgpack::packer::pack_true
packer< Stream > & pack_true()
Packing true.
Definition: pack.hpp:1143
msgpack::adaptor::object_with_zone
Definition: adaptor_base.hpp:43
msgpack::adaptor::convert< bool >::operator()
msgpack::object const & operator()(msgpack::object const &o, bool &v) const
Definition: bool.hpp:26
msgpack::type_error
Definition: object_fwd.hpp:236
msgpack::adaptor::pack
Definition: adaptor_base.hpp:32
msgpack::adaptor::object_with_zone< bool >::operator()
void operator()(msgpack::object::with_zone &o, bool v) const
Definition: bool.hpp:53
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::adaptor::pack< bool >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const bool &v) const
Definition: bool.hpp:36
msgpack::adaptor::object
Definition: adaptor_base.hpp:38
msgpack::packer
The class template that supports continuous packing.
Definition: adaptor_base_decl.hpp:24
msgpack::adaptor::convert
Definition: adaptor_base.hpp:27