Fix some compilation errors on Mac OS X
This commit is contained in:
parent
1cb702bd5e
commit
94b603c9f2
2 changed files with 14 additions and 14 deletions
|
@ -7,35 +7,31 @@
|
||||||
|
|
||||||
namespace serialization
|
namespace serialization
|
||||||
{
|
{
|
||||||
template<typename T> struct unsigned_of {};
|
template<size_t n> struct unsigned_of {};
|
||||||
template<> struct unsigned_of<int8_t> { typedef uint8_t t; };
|
template<> struct unsigned_of<1> { typedef uint8_t t; };
|
||||||
template<> struct unsigned_of<uint8_t> { typedef uint8_t t; };
|
template<> struct unsigned_of<2> { typedef uint16_t t; };
|
||||||
template<> struct unsigned_of<int16_t> { typedef uint16_t t; };
|
template<> struct unsigned_of<4> { typedef uint32_t t; };
|
||||||
template<> struct unsigned_of<uint16_t> { typedef uint16_t t; };
|
template<> struct unsigned_of<8> { typedef uint64_t t; };
|
||||||
template<> struct unsigned_of<int32_t> { typedef uint32_t t; };
|
|
||||||
template<> struct unsigned_of<uint32_t> { typedef uint32_t t; };
|
|
||||||
template<> struct unsigned_of<int64_t> { typedef uint64_t t; };
|
|
||||||
template<> struct unsigned_of<uint64_t> { typedef uint64_t t; };
|
|
||||||
|
|
||||||
template<typename T1, bool be>
|
template<typename T1, bool be>
|
||||||
void write_common(uint8_t* target, T1 value)
|
void write_common(uint8_t* target, T1 value)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < sizeof(T1); i++)
|
for(size_t i = 0; i < sizeof(T1); i++)
|
||||||
if(be)
|
if(be)
|
||||||
target[i] = static_cast<typename unsigned_of<T1>::t>(value) >> 8 * (sizeof(T1) - i - 1);
|
target[i] = static_cast<typename unsigned_of<sizeof(T1)>::t>(value) >> 8 * (sizeof(T1) - i - 1);
|
||||||
else
|
else
|
||||||
target[i] = static_cast<typename unsigned_of<T1>::t>(value) >> 8 * i;
|
target[i] = static_cast<typename unsigned_of<sizeof(T1)>::t>(value) >> 8 * i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, bool be>
|
template<typename T1, bool be>
|
||||||
T1 read_common(const uint8_t* source)
|
T1 read_common(const uint8_t* source)
|
||||||
{
|
{
|
||||||
typename unsigned_of<T1>::t value = 0;
|
typename unsigned_of<sizeof(T1)>::t value = 0;
|
||||||
for(size_t i = 0; i < sizeof(T1); i++)
|
for(size_t i = 0; i < sizeof(T1); i++)
|
||||||
if(be)
|
if(be)
|
||||||
value |= static_cast<typename unsigned_of<T1>::t>(source[i]) << 8 * (sizeof(T1) - i - 1);
|
value |= static_cast<typename unsigned_of<sizeof(T1)>::t>(source[i]) << 8 * (sizeof(T1) - i - 1);
|
||||||
else
|
else
|
||||||
value |= static_cast<typename unsigned_of<T1>::t>(source[i]) << 8 * i;
|
value |= static_cast<typename unsigned_of<sizeof(T1)>::t>(source[i]) << 8 * i;
|
||||||
return static_cast<T1>(value);
|
return static_cast<T1>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,10 @@ void _ref()
|
||||||
_ref2<ss_uint24_t>();
|
_ref2<ss_uint24_t>();
|
||||||
_ref2<uint32_t>();
|
_ref2<uint32_t>();
|
||||||
_ref2<uint64_t>();
|
_ref2<uint64_t>();
|
||||||
|
_ref2<unsigned int>();
|
||||||
|
_ref2<unsigned long>();
|
||||||
|
_ref2<unsigned long long>();
|
||||||
|
_ref2<size_t>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue