mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-06-04 21:59:20 +02:00
Tabified.
Indent adjusted.
This commit is contained in:
parent
27629a8dd6
commit
7ce8abe5d6
@ -112,7 +112,7 @@ private:
|
|||||||
template <typename Stream, typename T>
|
template <typename Stream, typename T>
|
||||||
inline void pack(Stream* s, const T& v)
|
inline void pack(Stream* s, const T& v)
|
||||||
{
|
{
|
||||||
packer<Stream>(s).pack(v);
|
packer<Stream>(*s).pack(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
template <typename Stream, typename T>
|
||||||
@ -121,23 +121,6 @@ inline void pack(Stream& s, const T& v)
|
|||||||
packer<Stream>(s).pack(v);
|
packer<Stream>(s).pack(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define msgpack_pack_inline_func(name) \
|
|
||||||
template <typename Stream> \
|
|
||||||
inline void packer<Stream>::_pack ## name
|
|
||||||
|
|
||||||
#define msgpack_pack_inline_func_cint(name) \
|
|
||||||
template <typename Stream> \
|
|
||||||
inline void packer<Stream>::_pack ## name
|
|
||||||
|
|
||||||
#define msgpack_pack_inline_func_fixint(name) \
|
|
||||||
template <typename Stream> \
|
|
||||||
inline void packer<Stream>::_pack_fix ## name
|
|
||||||
|
|
||||||
#define msgpack_pack_user Stream&
|
|
||||||
|
|
||||||
#define msgpack_pack_append_buffer append_buffer
|
|
||||||
|
|
||||||
#if defined(__LITTLE_ENDIAN__)
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
#define TAKE8_8(d) ((uint8_t*)&d)[0]
|
#define TAKE8_8(d) ((uint8_t*)&d)[0]
|
||||||
#define TAKE8_16(d) ((uint8_t*)&d)[0]
|
#define TAKE8_16(d) ((uint8_t*)&d)[0]
|
||||||
@ -197,8 +180,8 @@ template <typename Stream>
|
|||||||
inline packer<Stream>& packer<Stream>::pack_fix_uint8(uint8_t d)
|
inline packer<Stream>& packer<Stream>::pack_fix_uint8(uint8_t d)
|
||||||
{
|
{
|
||||||
unsigned char buf[2] = {0xcc, TAKE8_8(d)};
|
unsigned char buf[2] = {0xcc, TAKE8_8(d)};
|
||||||
append_buffer(buf, 2);
|
append_buffer(buf, 2);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -206,8 +189,8 @@ inline packer<Stream>& packer<Stream>::pack_fix_uint16(uint16_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
|
buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
|
||||||
append_buffer(buf, 3);
|
append_buffer(buf, 3);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -215,8 +198,8 @@ inline packer<Stream>& packer<Stream>::pack_fix_uint32(uint32_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[5];
|
unsigned char buf[5];
|
||||||
buf[0] = 0xce; _msgpack_store32(&buf[1], d);
|
buf[0] = 0xce; _msgpack_store32(&buf[1], d);
|
||||||
append_buffer(buf, 5);
|
append_buffer(buf, 5);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -224,16 +207,16 @@ inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[9];
|
unsigned char buf[9];
|
||||||
buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
|
buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
|
||||||
append_buffer(buf, 9);
|
append_buffer(buf, 9);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
inline packer<Stream>& packer<Stream>::pack_fix_int8(int8_t d)
|
inline packer<Stream>& packer<Stream>::pack_fix_int8(int8_t d)
|
||||||
{
|
{
|
||||||
unsigned char buf[2] = {0xd0, TAKE8_8(d)};
|
unsigned char buf[2] = {0xd0, TAKE8_8(d)};
|
||||||
append_buffer(buf, 2);
|
append_buffer(buf, 2);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -241,8 +224,8 @@ inline packer<Stream>& packer<Stream>::pack_fix_int16(int16_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
|
buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
|
||||||
append_buffer(buf, 3);
|
append_buffer(buf, 3);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -250,8 +233,8 @@ inline packer<Stream>& packer<Stream>::pack_fix_int32(int32_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[5];
|
unsigned char buf[5];
|
||||||
buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
|
buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
|
||||||
append_buffer(buf, 5);
|
append_buffer(buf, 5);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@ -259,8 +242,8 @@ inline packer<Stream>& packer<Stream>::pack_fix_int64(int64_t d)
|
|||||||
{
|
{
|
||||||
unsigned char buf[9];
|
unsigned char buf[9];
|
||||||
buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
|
buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
|
||||||
append_buffer(buf, 9);
|
append_buffer(buf, 9);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -294,13 +277,13 @@ inline packer<Stream>& packer<Stream>::pack_short(short d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(short) == 2) {
|
if(sizeof(short) == 2) {
|
||||||
pack_real_int16(d);
|
pack_real_int16(d);
|
||||||
} else if(sizeof(short) == 4) {
|
} else if(sizeof(short) == 4) {
|
||||||
pack_real_int32(d);
|
pack_real_int32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_int64(d);
|
pack_real_int64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -327,13 +310,13 @@ inline packer<Stream>& packer<Stream>::pack_int(int d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(int) == 2) {
|
if(sizeof(int) == 2) {
|
||||||
pack_real_int16(d);
|
pack_real_int16(d);
|
||||||
} else if(sizeof(int) == 4) {
|
} else if(sizeof(int) == 4) {
|
||||||
pack_real_int32(d);
|
pack_real_int32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_int64(d);
|
pack_real_int64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -360,13 +343,13 @@ inline packer<Stream>& packer<Stream>::pack_long(long d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(long) == 2) {
|
if(sizeof(long) == 2) {
|
||||||
pack_real_int16(d);
|
pack_real_int16(d);
|
||||||
} else if(sizeof(long) == 4) {
|
} else if(sizeof(long) == 4) {
|
||||||
pack_real_int32(d);
|
pack_real_int32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_int64(d);
|
pack_real_int64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -393,13 +376,13 @@ inline packer<Stream>& packer<Stream>::pack_long_long(long long d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(long long) == 2) {
|
if(sizeof(long long) == 2) {
|
||||||
pack_real_int16(d);
|
pack_real_int16(d);
|
||||||
} else if(sizeof(long long) == 4) {
|
} else if(sizeof(long long) == 4) {
|
||||||
pack_real_int32(d);
|
pack_real_int32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_int64(d);
|
pack_real_int64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -431,13 +414,13 @@ inline packer<Stream>& packer<Stream>::pack_unsigned_short(unsigned short d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(unsigned short) == 2) {
|
if(sizeof(unsigned short) == 2) {
|
||||||
pack_real_uint16(d);
|
pack_real_uint16(d);
|
||||||
} else if(sizeof(unsigned short) == 4) {
|
} else if(sizeof(unsigned short) == 4) {
|
||||||
pack_real_uint32(d);
|
pack_real_uint32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_uint64(d);
|
pack_real_uint64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -464,13 +447,13 @@ inline packer<Stream>& packer<Stream>::pack_unsigned_int(unsigned int d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(unsigned int) == 2) {
|
if(sizeof(unsigned int) == 2) {
|
||||||
pack_real_uint16(d);
|
pack_real_uint16(d);
|
||||||
} else if(sizeof(unsigned int) == 4) {
|
} else if(sizeof(unsigned int) == 4) {
|
||||||
pack_real_uint32(d);
|
pack_real_uint32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_uint64(d);
|
pack_real_uint64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -497,13 +480,13 @@ inline packer<Stream>& packer<Stream>::pack_unsigned_long(unsigned long d)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(unsigned long) == 2) {
|
if(sizeof(unsigned long) == 2) {
|
||||||
pack_real_uint16(d);
|
pack_real_uint16(d);
|
||||||
} else if(sizeof(unsigned long) == 4) {
|
} else if(sizeof(unsigned long) == 4) {
|
||||||
pack_real_uint32(d);
|
pack_real_uint32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_uint64(d);
|
pack_real_uint64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -530,13 +513,13 @@ inline packer<Stream>& packer<Stream>::pack_unsigned_long_long(unsigned long lon
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(sizeof(unsigned long long) == 2) {
|
if(sizeof(unsigned long long) == 2) {
|
||||||
pack_real_uint16(d);
|
pack_real_uint16(d);
|
||||||
} else if(sizeof(unsigned long long) == 4) {
|
} else if(sizeof(unsigned long long) == 4) {
|
||||||
pack_real_uint32(d);
|
pack_real_uint32(d);
|
||||||
} else {
|
} else {
|
||||||
pack_real_uint64(d);
|
pack_real_uint64(d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -561,10 +544,10 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
|
|||||||
unsigned char buf[9];
|
unsigned char buf[9];
|
||||||
buf[0] = 0xcb;
|
buf[0] = 0xcb;
|
||||||
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
||||||
// https://github.com/msgpack/msgpack-perl/pull/1
|
// https://github.com/msgpack/msgpack-perl/pull/1
|
||||||
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
|
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
|
||||||
#endif
|
#endif
|
||||||
_msgpack_store64(&buf[1], mem.i);
|
_msgpack_store64(&buf[1], mem.i);
|
||||||
append_buffer(buf, 9);
|
append_buffer(buf, 9);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user