fixint.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2016 FURUHASHI Sadayuki and KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V1_TYPE_FIXINT_HPP
#define MSGPACK_V1_TYPE_FIXINT_HPP
#include "msgpack/v1/adaptor/fixint_decl.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
template <typename T>
struct fix_int {
fix_int() : value(0) { }
fix_int(T value) : value(value) { }
operator T() const { return value; }
T get() const { return value; }
private:
T value;
};
} // namespace type
namespace adaptor {
template <>
struct convert<type::fix_int8> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_int8& v) const
{ v = type::detail::convert_integer<int8_t>(o); return o; }
};
template <>
struct convert<type::fix_int16> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_int16& v) const
{ v = type::detail::convert_integer<int16_t>(o); return o; }
};
template <>
struct convert<type::fix_int32> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_int32& v) const
{ v = type::detail::convert_integer<int32_t>(o); return o; }
};
template <>
struct convert<type::fix_int64> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_int64& v) const
{ v = type::detail::convert_integer<int64_t>(o); return o; }
};
template <>
struct convert<type::fix_uint8> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint8& v) const
{ v = type::detail::convert_integer<uint8_t>(o); return o; }
};
template <>
struct convert<type::fix_uint16> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint16& v) const
{ v = type::detail::convert_integer<uint16_t>(o); return o; }
};
template <>
struct convert<type::fix_uint32> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint32& v) const
{ v = type::detail::convert_integer<uint32_t>(o); return o; }
};
template <>
struct convert<type::fix_uint64> {
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint64& v) const
{ v = type::detail::convert_integer<uint64_t>(o); return o; }
};
template <>
struct pack<type::fix_int8> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int8& v) const
{ o.pack_fix_int8(v); return o; }
};
template <>
struct pack<type::fix_int16> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int16& v) const
{ o.pack_fix_int16(v); return o; }
};
template <>
struct pack<type::fix_int32> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int32& v) const
{ o.pack_fix_int32(v); return o; }
};
template <>
struct pack<type::fix_int64> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int64& v) const
{ o.pack_fix_int64(v); return o; }
};
template <>
struct pack<type::fix_uint8> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint8& v) const
{ o.pack_fix_uint8(v); return o; }
};
template <>
struct pack<type::fix_uint16> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint16& v) const
{ o.pack_fix_uint16(v); return o; }
};
template <>
struct pack<type::fix_uint32> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint32& v) const
{ o.pack_fix_uint32(v); return o; }
};
template <>
struct pack<type::fix_uint64> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint64& v) const
{ o.pack_fix_uint64(v); return o; }
};
template <>
struct object<type::fix_int8> {
void operator()(msgpack::object& o, type::fix_int8 v) const {
if (v.get() < 0) {
o.type = msgpack::type::NEGATIVE_INTEGER;
o.via.i64 = v.get();
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
}
}
};
template <>
struct object<type::fix_int16> {
void operator()(msgpack::object& o, type::fix_int16 v) const {
if(v.get() < 0) {
o.type = msgpack::type::NEGATIVE_INTEGER;
o.via.i64 = v.get();
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
}
}
};
template <>
struct object<type::fix_int32> {
void operator()(msgpack::object& o, type::fix_int32 v) const {
if (v.get() < 0) {
o.type = msgpack::type::NEGATIVE_INTEGER;
o.via.i64 = v.get();
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
}
}
};
template <>
struct object<type::fix_int64> {
void operator()(msgpack::object& o, type::fix_int64 v) const {
if (v.get() < 0) {
o.type = msgpack::type::NEGATIVE_INTEGER;
o.via.i64 = v.get();
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
}
}
};
template <>
struct object<type::fix_uint8> {
void operator()(msgpack::object& o, type::fix_uint8 v) const
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
};
template <>
struct object<type::fix_uint16> {
void operator()(msgpack::object& o, type::fix_uint16 v) const
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
};
template <>
struct object<type::fix_uint32> {
void operator()(msgpack::object& o, type::fix_uint32 v) const
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
};
template <>
struct object<type::fix_uint64> {
void operator()(msgpack::object& o, type::fix_uint64 v) const
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
};
template <>
struct object_with_zone<type::fix_int8> {
void operator()(msgpack::object::with_zone& o, type::fix_int8 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_int16> {
void operator()(msgpack::object::with_zone& o, type::fix_int16 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_int32> {
void operator()(msgpack::object::with_zone& o, type::fix_int32 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_int64> {
void operator()(msgpack::object::with_zone& o, type::fix_int64 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_uint8> {
void operator()(msgpack::object::with_zone& o, type::fix_uint8 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_uint16> {
void operator()(msgpack::object::with_zone& o, type::fix_uint16 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_uint32> {
void operator()(msgpack::object::with_zone& o, type::fix_uint32 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
template <>
struct object_with_zone<type::fix_uint64> {
void operator()(msgpack::object::with_zone& o, type::fix_uint64 v) const
{ static_cast<msgpack::object&>(o) << v; }
};
} // namespace adaptor
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_TYPE_FIXINT_HPP
msgpack::packer::pack_fix_uint16
packer< Stream > & pack_fix_uint16(uint16_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:746
msgpack::type::fix_uint32
fix_int< uint32_t > fix_uint32
Definition: fixint_decl.hpp:30
msgpack::packer::pack_fix_uint32
packer< Stream > & pack_fix_uint32(uint32_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:755
msgpack::adaptor::object_with_zone< type::fix_int64 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_int64 v) const
Definition: fixint.hpp:246
msgpack::adaptor::object_with_zone< type::fix_int8 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_int8 v) const
Definition: fixint.hpp:228
msgpack::adaptor::convert< type::fix_int16 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_int16 &v) const
Definition: fixint.hpp:48
msgpack::adaptor::object_with_zone< type::fix_uint8 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_uint8 v) const
Definition: fixint.hpp:253
msgpack::type::fix_uint64
fix_int< uint64_t > fix_uint64
Definition: fixint_decl.hpp:31
msgpack::adaptor::object_with_zone< type::fix_int16 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_int16 v) const
Definition: fixint.hpp:234
msgpack::object::via
union_type via
Definition: object_fwd.hpp:93
msgpack::adaptor::object< type::fix_int8 >::operator()
void operator()(msgpack::object &o, type::fix_int8 v) const
Definition: fixint.hpp:148
msgpack::adaptor::object< type::fix_uint64 >::operator()
void operator()(msgpack::object &o, type::fix_uint64 v) const
Definition: fixint.hpp:222
msgpack::adaptor::pack< type::fix_int64 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_int64 &v) const
Definition: fixint.hpp:113
msgpack::adaptor::object< type::fix_int16 >::operator()
void operator()(msgpack::object &o, type::fix_int16 v) const
Definition: fixint.hpp:162
msgpack::type::fix_int::fix_int
fix_int(T value)
Definition: fixint.hpp:26
msgpack::type::fix_uint8
fix_int< uint8_t > fix_uint8
Definition: fixint_decl.hpp:26
msgpack::adaptor::pack< type::fix_int32 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_int32 &v) const
Definition: fixint.hpp:106
msgpack::adaptor::convert< type::fix_int64 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_int64 &v) const
Definition: fixint.hpp:60
msgpack
Definition: adaptor_base.hpp:15
msgpack::adaptor::object< type::fix_int32 >::operator()
void operator()(msgpack::object &o, type::fix_int32 v) const
Definition: fixint.hpp:176
msgpack::adaptor::convert< type::fix_int8 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_int8 &v) const
Definition: fixint.hpp:42
msgpack::object::with_zone
Definition: object.hpp:34
msgpack::adaptor::convert< type::fix_int32 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_int32 &v) const
Definition: fixint.hpp:54
msgpack::type::fix_int64
fix_int< int64_t > fix_int64
Definition: fixint_decl.hpp:36
msgpack::adaptor::pack< type::fix_int8 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_int8 &v) const
Definition: fixint.hpp:92
msgpack::object::union_type::i64
int64_t i64
Definition: object_fwd.hpp:79
msgpack::type::NEGATIVE_INTEGER
Definition: object_fwd_decl.hpp:32
msgpack::adaptor::object_with_zone< type::fix_uint64 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_uint64 v) const
Definition: fixint.hpp:271
msgpack::adaptor::object_with_zone
Definition: adaptor_base.hpp:43
msgpack::adaptor::object_with_zone< type::fix_uint32 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_uint32 v) const
Definition: fixint.hpp:265
fixint_decl.hpp
msgpack::adaptor::pack< type::fix_int16 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_int16 &v) const
Definition: fixint.hpp:99
msgpack::adaptor::object< type::fix_uint8 >::operator()
void operator()(msgpack::object &o, type::fix_uint8 v) const
Definition: fixint.hpp:204
msgpack::adaptor::object< type::fix_int64 >::operator()
void operator()(msgpack::object &o, type::fix_int64 v) const
Definition: fixint.hpp:190
msgpack::adaptor::pack
Definition: adaptor_base.hpp:32
msgpack::type::fix_int8
fix_int< int8_t > fix_int8
Definition: fixint_decl.hpp:33
msgpack::packer::pack_fix_int32
packer< Stream > & pack_fix_int32(int32_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:790
msgpack::adaptor::pack< type::fix_uint16 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_uint16 &v) const
Definition: fixint.hpp:128
msgpack::adaptor::pack< type::fix_uint64 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_uint64 &v) const
Definition: fixint.hpp:142
msgpack::adaptor::object< type::fix_uint16 >::operator()
void operator()(msgpack::object &o, type::fix_uint16 v) const
Definition: fixint.hpp:210
msgpack::type::fix_int::get
T get() const
Definition: fixint.hpp:30
msgpack::adaptor::convert< type::fix_uint8 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_uint8 &v) const
Definition: fixint.hpp:67
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::type::fix_int
Definition: fixint.hpp:24
msgpack::object::type
msgpack::type::object_type type
Definition: object_fwd.hpp:92
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
msgpack::packer::pack_fix_int16
packer< Stream > & pack_fix_int16(int16_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:781
msgpack::adaptor::pack< type::fix_uint8 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_uint8 &v) const
Definition: fixint.hpp:121
msgpack::adaptor::convert< type::fix_uint64 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_uint64 &v) const
Definition: fixint.hpp:85
msgpack::packer::pack_fix_int8
packer< Stream > & pack_fix_int8(int8_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:773
msgpack::adaptor::object< type::fix_uint32 >::operator()
void operator()(msgpack::object &o, type::fix_uint32 v) const
Definition: fixint.hpp:216
msgpack::adaptor::convert< type::fix_uint32 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_uint32 &v) const
Definition: fixint.hpp:79
msgpack::adaptor::object_with_zone< type::fix_int32 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_int32 v) const
Definition: fixint.hpp:240
msgpack::adaptor::object
Definition: adaptor_base.hpp:38
msgpack::packer
The class template that supports continuous packing.
Definition: adaptor_base_decl.hpp:24
msgpack::type::fix_uint16
fix_int< uint16_t > fix_uint16
Definition: fixint_decl.hpp:29
msgpack::adaptor::object_with_zone< type::fix_uint16 >::operator()
void operator()(msgpack::object::with_zone &o, type::fix_uint16 v) const
Definition: fixint.hpp:259
msgpack::packer::pack_fix_uint8
packer< Stream > & pack_fix_uint8(uint8_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:738
msgpack::type::fix_int32
fix_int< int32_t > fix_int32
Definition: fixint_decl.hpp:35
msgpack::type::fix_int16
fix_int< int16_t > fix_int16
Definition: fixint_decl.hpp:34
msgpack::type::fix_int::fix_int
fix_int()
Definition: fixint.hpp:25
msgpack::packer::pack_fix_uint64
packer< Stream > & pack_fix_uint64(uint64_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:764
msgpack::adaptor::convert< type::fix_uint16 >::operator()
msgpack::object const & operator()(msgpack::object const &o, type::fix_uint16 &v) const
Definition: fixint.hpp:73
msgpack::adaptor::convert
Definition: adaptor_base.hpp:27
msgpack::adaptor::pack< type::fix_uint32 >::operator()
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::fix_uint32 &v) const
Definition: fixint.hpp:135
msgpack::type::POSITIVE_INTEGER
Definition: object_fwd_decl.hpp:31
msgpack::object::union_type::u64
uint64_t u64
Definition: object_fwd.hpp:78
msgpack::packer::pack_fix_int64
packer< Stream > & pack_fix_int64(int64_t d)
Packing uint8 (fixed packed type).
Definition: pack.hpp:799