10 #ifndef MSGPACK_V1_TYPE_EXT_HPP
11 #define MSGPACK_V1_TYPE_EXT_HPP
28 ext() : m_data(1, 0) {}
29 ext(int8_t t,
const char* p, uint32_t s) {
30 msgpack::detail::check_container_size_for_ext<sizeof(std::size_t)>(s);
31 m_data.reserve(
static_cast<std::size_t
>(s) + 1);
32 m_data.push_back(
static_cast<char>(t));
33 m_data.insert(m_data.end(), p, p + s);
35 ext(int8_t t, uint32_t s) {
36 msgpack::detail::check_container_size_for_ext<sizeof(std::size_t)>(s);
37 m_data.resize(
static_cast<std::size_t
>(s) + 1);
38 m_data[0] =
static_cast<char>(t);
42 return static_cast<int8_t
>(m_data[0]);
45 return &m_data[0] + 1;
48 return &m_data[0] + 1;
51 return static_cast<uint32_t
>(m_data.size()) - 1;
54 return m_data == x.m_data;
62 return m_data < x.m_data;
66 return m_data > x.m_data;
69 std::vector<char> m_data;
90 template <
typename Stream>
109 ptr[0] =
static_cast<char>(v.
type());
110 std::memcpy(ptr + 1, v.
data(),
size);
125 ext_ref() : m_ptr(static_cast<char*>(static_cast<void*>(&m_size))), m_size(0) {}
127 m_ptr(s == 0 ? static_cast<char*>(static_cast<void*>(&m_size)) : p),
128 m_size(s == 0 ? 0 : s - 1) {
129 msgpack::detail::check_container_size_for_ext<sizeof(std::size_t)>(s);
144 return static_cast<int8_t
>(m_ptr[0]);
148 return std::string(m_ptr + 1, m_size);
152 return m_size == x.m_size && std::memcmp(m_ptr, x.m_ptr, m_size) == 0;
156 return !(*
this == x);
160 if (m_size < x.m_size)
return true;
161 if (m_size > x.m_size)
return false;
162 return std::memcmp(m_ptr, x.m_ptr, m_size) < 0;
166 if (m_size > x.m_size)
return true;
167 if (m_size < x.m_size)
return false;
168 return std::memcmp(m_ptr, x.m_ptr, m_size) > 0;
179 m_data.reserve(x.size() + 1);
181 m_data.push_back(
static_cast<char>(x.type()));
182 m_data.insert(m_data.end(), x.data(), x.data() + x.size());
200 template <
typename Stream>
The class template that supports continuous packing.
Definition: pack.hpp:33
packer< Stream > & pack_ext(size_t l, int8_t type)
Packing ext header, type, and length.
Definition: pack.hpp:1316
packer< Stream > & pack_ext_body(const char *b, uint32_t l)
Packing ext body.
Definition: pack.hpp:1375
bool operator!=(const ext_ref &x) const
Definition: ext.hpp:155
bool operator<(const ext_ref &x) const
Definition: ext.hpp:159
bool operator==(const ext_ref &x) const
Definition: ext.hpp:151
ext_ref(ext const &x)
Definition: ext.hpp:133
int8_t type() const
Definition: ext.hpp:143
std::string str() const
Definition: ext.hpp:147
uint32_t size() const
Definition: ext.hpp:139
bool operator>(const ext_ref &x) const
Definition: ext.hpp:165
ext_ref(const char *p, uint32_t s)
Definition: ext.hpp:126
const char * data() const
Definition: ext.hpp:135
ext_ref()
Definition: ext.hpp:125
ext(int8_t t, uint32_t s)
Definition: ext.hpp:35
bool operator>(const ext &x) const
Definition: ext.hpp:65
bool operator!=(const ext &x) const
Definition: ext.hpp:57
uint32_t size() const
Definition: ext.hpp:50
char * data()
Definition: ext.hpp:47
bool operator==(const ext &x) const
Definition: ext.hpp:53
const char * data() const
Definition: ext.hpp:44
ext()
Definition: ext.hpp:28
int8_t type() const
Definition: ext.hpp:41
ext(int8_t t, const char *p, uint32_t s)
Definition: ext.hpp:29
bool operator<(const ext &x) const
Definition: ext.hpp:61
Definition: object_fwd.hpp:231
void * allocate_align(size_t size, size_t align=MSGPACK_ZONE_ALIGN)
Definition: cpp03_zone.hpp:256
std::size_t size(T const &t)
Definition: size_equal_only.hpp:24
@ EXT
Definition: object_fwd_decl.hpp:42
Definition: adaptor_base.hpp:15
msgpack::object const & operator()(msgpack::object const &o, msgpack::type::ext &v) const
Definition: ext.hpp:79
msgpack::object const & operator()(msgpack::object const &o, msgpack::type::ext_ref &v) const
Definition: ext.hpp:191
Definition: adaptor_base.hpp:27
void operator()(msgpack::object &o, const msgpack::type::ext_ref &v) const
Definition: ext.hpp:212
void operator()(msgpack::object::with_zone &o, const msgpack::type::ext &v) const
Definition: ext.hpp:102
void operator()(msgpack::object::with_zone &o, const msgpack::type::ext_ref &v) const
Definition: ext.hpp:223
Definition: adaptor_base.hpp:43
Definition: adaptor_base.hpp:38
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const msgpack::type::ext &v) const
Definition: ext.hpp:91
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const msgpack::type::ext_ref &v) const
Definition: ext.hpp:201
Definition: adaptor_base.hpp:32
Definition: object.hpp:35
msgpack::zone & zone
Definition: object.hpp:37
const char * data() const
Definition: object_fwd.hpp:44
int8_t type() const
Definition: object_fwd.hpp:43
const char * ptr
Definition: object_fwd.hpp:46
uint32_t size
Definition: object_fwd.hpp:45
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
msgpack::object_ext ext
Definition: object_fwd.hpp:89
#define MSGPACK_ZONE_ALIGNOF(type)
Definition: cpp03_zone_decl.hpp:30
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66