Dependents:   hello_message_pack

msgpack-c & msgpack-c++ https://github.com/msgpack/msgpack-c implementation for embedded systems (mbed / Arduino)

Committer:
hideakitai
Date:
Mon Feb 22 01:43:48 2016 +0000
Revision:
4:bd0c06dd6e92
Parent:
0:3f9dbf1e2cb0
fix throw error

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hideakitai 0:3f9dbf1e2cb0 1 //
hideakitai 0:3f9dbf1e2cb0 2 // MessagePack for C++ static resolution routine
hideakitai 0:3f9dbf1e2cb0 3 //
hideakitai 0:3f9dbf1e2cb0 4 // Copyright (C) 2008-2009 FURUHASHI Sadayuki
hideakitai 0:3f9dbf1e2cb0 5 //
hideakitai 0:3f9dbf1e2cb0 6 // Distributed under the Boost Software License, Version 1.0.
hideakitai 0:3f9dbf1e2cb0 7 // (See accompanying file LICENSE_1_0.txt or copy at
hideakitai 0:3f9dbf1e2cb0 8 // http://www.boost.org/LICENSE_1_0.txt)
hideakitai 0:3f9dbf1e2cb0 9 //
hideakitai 0:3f9dbf1e2cb0 10 #ifndef MSGPACK_TYPE_BOOL_HPP
hideakitai 0:3f9dbf1e2cb0 11 #define MSGPACK_TYPE_BOOL_HPP
hideakitai 0:3f9dbf1e2cb0 12
hideakitai 0:3f9dbf1e2cb0 13 #include "msgpack/versioning.hpp"
hideakitai 0:3f9dbf1e2cb0 14 #include "msgpack/adaptor/adaptor_base.hpp"
hideakitai 0:3f9dbf1e2cb0 15
hideakitai 0:3f9dbf1e2cb0 16 namespace msgpack {
hideakitai 0:3f9dbf1e2cb0 17
hideakitai 0:3f9dbf1e2cb0 18 /// @cond
hideakitai 0:3f9dbf1e2cb0 19 MSGPACK_API_VERSION_NAMESPACE(v1) {
hideakitai 0:3f9dbf1e2cb0 20 /// @endcond
hideakitai 0:3f9dbf1e2cb0 21
hideakitai 0:3f9dbf1e2cb0 22 namespace adaptor {
hideakitai 0:3f9dbf1e2cb0 23
hideakitai 0:3f9dbf1e2cb0 24 template <>
hideakitai 0:3f9dbf1e2cb0 25 struct convert<bool> {
hideakitai 0:3f9dbf1e2cb0 26 msgpack::object const& operator()(msgpack::object const& o, bool& v) const {
hideakitai 0:3f9dbf1e2cb0 27 if(o.type != msgpack::type::BOOLEAN) {
hideakitai 0:3f9dbf1e2cb0 28 // throw msgpack::type_error();
hideakitai 0:3f9dbf1e2cb0 29 }
hideakitai 0:3f9dbf1e2cb0 30 v = o.via.boolean;
hideakitai 0:3f9dbf1e2cb0 31 return o;
hideakitai 0:3f9dbf1e2cb0 32 }
hideakitai 0:3f9dbf1e2cb0 33 };
hideakitai 0:3f9dbf1e2cb0 34
hideakitai 0:3f9dbf1e2cb0 35 template <>
hideakitai 0:3f9dbf1e2cb0 36 struct pack<bool> {
hideakitai 0:3f9dbf1e2cb0 37 template <typename Stream>
hideakitai 0:3f9dbf1e2cb0 38 msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const bool& v) const {
hideakitai 0:3f9dbf1e2cb0 39 if(v) { o.pack_true(); }
hideakitai 0:3f9dbf1e2cb0 40 else { o.pack_false(); }
hideakitai 0:3f9dbf1e2cb0 41 return o;
hideakitai 0:3f9dbf1e2cb0 42 }
hideakitai 0:3f9dbf1e2cb0 43 };
hideakitai 0:3f9dbf1e2cb0 44
hideakitai 0:3f9dbf1e2cb0 45 template <>
hideakitai 0:3f9dbf1e2cb0 46 struct object<bool> {
hideakitai 0:3f9dbf1e2cb0 47 void operator()(msgpack::object& o, bool v) const {
hideakitai 0:3f9dbf1e2cb0 48 o.type = msgpack::type::BOOLEAN;
hideakitai 0:3f9dbf1e2cb0 49 o.via.boolean = v;
hideakitai 0:3f9dbf1e2cb0 50 }
hideakitai 0:3f9dbf1e2cb0 51 };
hideakitai 0:3f9dbf1e2cb0 52
hideakitai 0:3f9dbf1e2cb0 53 template <>
hideakitai 0:3f9dbf1e2cb0 54 struct object_with_zone<bool> {
hideakitai 0:3f9dbf1e2cb0 55 void operator()(msgpack::object::with_zone& o, bool v) const {
hideakitai 0:3f9dbf1e2cb0 56 static_cast<msgpack::object&>(o) << v;
hideakitai 0:3f9dbf1e2cb0 57 }
hideakitai 0:3f9dbf1e2cb0 58 };
hideakitai 0:3f9dbf1e2cb0 59
hideakitai 0:3f9dbf1e2cb0 60 } // namespace adaptor
hideakitai 0:3f9dbf1e2cb0 61
hideakitai 0:3f9dbf1e2cb0 62 /// @cond
hideakitai 0:3f9dbf1e2cb0 63 } // MSGPACK_API_VERSION_NAMESPACE(v1)
hideakitai 0:3f9dbf1e2cb0 64 /// @endcond
hideakitai 0:3f9dbf1e2cb0 65
hideakitai 0:3f9dbf1e2cb0 66 } // namespace msgpack
hideakitai 0:3f9dbf1e2cb0 67
hideakitai 0:3f9dbf1e2cb0 68 #endif // MSGPACK_TYPE_BOOL_HPP