Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: hello_message_pack
bool.hpp
00001 // 00002 // MessagePack for C++ static resolution routine 00003 // 00004 // Copyright (C) 2008-2009 FURUHASHI Sadayuki 00005 // 00006 // Distributed under the Boost Software License, Version 1.0. 00007 // (See accompanying file LICENSE_1_0.txt or copy at 00008 // http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 #ifndef MSGPACK_TYPE_BOOL_HPP 00011 #define MSGPACK_TYPE_BOOL_HPP 00012 00013 #include "msgpack/versioning.hpp" 00014 #include "msgpack/adaptor/adaptor_base.hpp" 00015 00016 namespace msgpack { 00017 00018 /// @cond 00019 MSGPACK_API_VERSION_NAMESPACE(v1) { 00020 /// @endcond 00021 00022 namespace adaptor { 00023 00024 template <> 00025 struct convert<bool> { 00026 msgpack::object const& operator()(msgpack::object const& o, bool& v) const { 00027 if(o.type != msgpack::type::BOOLEAN) { 00028 // throw msgpack::type_error(); 00029 } 00030 v = o.via.boolean; 00031 return o; 00032 } 00033 }; 00034 00035 template <> 00036 struct pack<bool> { 00037 template <typename Stream> 00038 msgpack::packer<Stream> & operator()(msgpack::packer<Stream> & o, const bool& v) const { 00039 if(v) { o.pack_true(); } 00040 else { o.pack_false(); } 00041 return o; 00042 } 00043 }; 00044 00045 template <> 00046 struct object<bool> { 00047 void operator()(msgpack::object& o, bool v) const { 00048 o.type = msgpack::type::BOOLEAN; 00049 o.via.boolean = v; 00050 } 00051 }; 00052 00053 template <> 00054 struct object_with_zone<bool> { 00055 void operator()(msgpack::object::with_zone& o, bool v) const { 00056 static_cast<msgpack::object&>(o) << v; 00057 } 00058 }; 00059 00060 } // namespace adaptor 00061 00062 /// @cond 00063 } // MSGPACK_API_VERSION_NAMESPACE(v1) 00064 /// @endcond 00065 00066 } // namespace msgpack 00067 00068 #endif // MSGPACK_TYPE_BOOL_HPP
Generated on Tue Jul 12 2022 22:51:44 by
1.7.2