mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8
This commit is contained in:
@@ -36,6 +36,8 @@ public:
|
||||
static UInt16 flipBytes(UInt16 value);
|
||||
static Int32 flipBytes(Int32 value);
|
||||
static UInt32 flipBytes(UInt32 value);
|
||||
static float flipBytes(float value);
|
||||
static double flipBytes(double value);
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
static Int64 flipBytes(Int64 value);
|
||||
static UInt64 flipBytes(UInt64 value);
|
||||
@@ -94,6 +96,21 @@ public:
|
||||
static Int64 fromNetwork(Int64 value);
|
||||
static UInt64 fromNetwork (UInt64 value);
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
static T flip(T value)
|
||||
{
|
||||
T flip = value;
|
||||
std::size_t halfSize = sizeof(T) / 2;
|
||||
char* flipP = reinterpret_cast<char*>(&flip);
|
||||
|
||||
for (std::size_t i = 0; i < halfSize; i++)
|
||||
{
|
||||
std::swap(flipP[i], flipP[sizeof(T) - i - 1]);
|
||||
}
|
||||
return flip;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -150,6 +167,18 @@ inline Int32 ByteOrder::flipBytes(Int32 value)
|
||||
}
|
||||
|
||||
|
||||
inline float ByteOrder::flipBytes(float value)
|
||||
{
|
||||
return flip(value);
|
||||
}
|
||||
|
||||
|
||||
inline double ByteOrder::flipBytes(double value)
|
||||
{
|
||||
return flip(value);
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
inline UInt64 ByteOrder::flipBytes(UInt64 value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user