#pragma once #include "EHS.h" #include "Serializer.h" namespace ehs { class EHS_LIB_IO Data { public: template static void SwapEndianness(T* value) { Byte tmp = 0; for (UInt_64 i = 0; i < sizeof(T) / 2; ++i) { tmp = ((Byte*)value)[i]; ((Byte*)value)[i] = ((Byte*)value)[sizeof(T) - i - 1]; ((Byte*)value)[sizeof(T) - i - 1] = tmp; } } template static Array SwapEndianness(const T* const array, const UInt_64 size) { Array result(size); for (UInt_64 i = size; i; --i) result[size - i] = array[i - 1]; return result; } template static Serializer SwapEndianness(const Serializer& data) { Serializer result(data.Size()); for (N i = 0; i < data.Size(); ++i) result[i] = data[data.Size() - i - 1]; return result; } }; }