MessagePack for C++
Loading...
Searching...
No Matches
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
13#if __cplusplus >= 201703
14
19#include "msgpack/object.hpp"
20
21#include <cstddef>
22
23namespace msgpack {
24
28
29namespace adaptor {
30
31template <>
32struct convert<std::byte> {
33 msgpack::object const& operator()(msgpack::object const& o, std::byte& v) const {
34 v = static_cast<std::byte>(type::detail::convert_integer<unsigned char>(o));
35 return o;
36 }
37};
38
39template <>
40struct pack<std::byte> {
41 template <typename Stream>
43 o.pack_unsigned_char(static_cast<unsigned char>(v));
44 return o;
45 }
46};
47
48template <>
49struct object<std::byte> {
50 void operator()(msgpack::object& o, std::byte v) const {
52 o.via.u64 = static_cast<unsigned char>(v);
53 }
54};
55
56template <>
57struct object_with_zone<std::byte> {
58 void operator()(msgpack::object::with_zone& o, const std::byte& v) const {
59 static_cast<msgpack::object&>(o) << v;
60 }
61};
62
63
64} // namespace adaptor
65
67} // MSGPACK_API_VERSION_NAMESPACE(v1)
69
70} // namespace msgpack
71
72#endif // __cplusplus >= 201703
73
74#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:31
Definition adaptor_base.hpp:15
void pack(msgpack::packer< Stream > &o, const T &v)
Definition object.hpp:1201
void convert(T &v, msgpack::object const &o)
Definition object.hpp:1194
msgpack::object const & operator()(msgpack::object const &o, T &v) const
Definition object.hpp:641
void operator()(msgpack::object::with_zone &o, T const &v) const
Definition object.hpp:657
void operator()(msgpack::object &o, T const &v) const
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, T const &v) const
Definition object.hpp:650
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:58