First commit.
Some checks failed
Build & Release / Linux-x86_64-Build (push) Successful in 40s
Build & Release / Linux-AARCH64-Build (push) Has been cancelled

This commit is contained in:
2024-01-31 22:28:19 -08:00
commit 1a4a1ecd9c
246 changed files with 42404 additions and 0 deletions

45
include/ehs/Data.h Normal file
View File

@@ -0,0 +1,45 @@
#pragma once
#include "EHS.h"
#include "Serializer.h"
namespace ehs
{
class Data
{
public:
template<typename T>
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<typename T>
static Array<T> SwapEndianness(const T* const array, const UInt_64 size)
{
Array<T> result(size);
for (UInt_64 i = size; i; --i)
result[size - i] = array[i - 1];
return result;
}
template<typename N>
static Serializer<N> SwapEndianness(const Serializer<N>& data)
{
Serializer<N> result(data.Size());
for (N i = 0; i < data.Size(); ++i)
result[i] = data[data.Size() - i - 1];
return result;
}
};
}