MessagePack for C++
byte.hpp
Go to the documentation of this file.
1//
2// MessagePack for C++ static resolution routine
3//
4// Copyright (C) 2018 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_BYTE_HPP
11#define MSGPACK_V1_TYPE_BYTE_HPP
12
14
15#if MSGPACK_CPP_VERSION >= 201703
16
21#include "msgpack/object.hpp"
22
23#include <cstddef>
24
25namespace msgpack {
26
30
31namespace adaptor {
32
33template <>
34struct convert<std::byte> {
35 msgpack::object const& operator()(msgpack::object const& o, std::byte& v) const {
36 v = static_cast<std::byte>(type::detail::convert_integer<unsigned char>(o));
37 return o;
38 }
39};
40
41template <>
42struct pack<std::byte> {
43 template <typename Stream>
45 o.pack_unsigned_char(static_cast<unsigned char>(v));
46 return o;
47 }
48};
49
50template <>
51struct object<std::byte> {
52 void operator()(msgpack::object& o, std::byte v) const {
54 o.via.u64 = static_cast<unsigned char>(v);
55 }
56};
57
58template <>
59struct object_with_zone<std::byte> {
60 void operator()(msgpack::object::with_zone& o, const std::byte& v) const {
61 static_cast<msgpack::object&>(o) << v;
62 }
63};
64
65
66} // namespace adaptor
67
69} // MSGPACK_API_VERSION_NAMESPACE(v1)
71
72} // namespace msgpack
73
74#endif // MSGPACK_CPP_VERSION >= 201703
75
76#endif // MSGPACK_V1_TYPE_BYTE_HPP
The class template that supports continuous packing.
Definition: pack.hpp:33
packer< Stream > & pack_unsigned_char(unsigned char d)
Packing unsigned char.
Definition: pack.hpp:999
@ POSITIVE_INTEGER
Definition: object_fwd_decl.hpp:30
Definition: adaptor_base.hpp:15
void pack(msgpack::packer< Stream > &o, const T &v)
Definition: object.hpp:1185
void convert(T &v, msgpack::object const &o)
Definition: object.hpp:1178
msgpack::object const & operator()(msgpack::object const &o, T &v) const
Definition: object.hpp:646
void operator()(msgpack::object::with_zone &o, T const &v) const
Definition: object.hpp:662
void operator()(msgpack::object &o, T const &v) const
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, T const &v) const
Definition: object.hpp:655
Definition: object.hpp:35
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
union_type via
Definition: object_fwd.hpp:93
msgpack::type::object_type type
Definition: object_fwd.hpp:92
uint64_t u64
Definition: object_fwd.hpp:78
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66