Move bitconverter from crosslang to tessesframework

This commit is contained in:
2025-09-23 20:29:29 -05:00
parent a19e4fa0bd
commit 36b050fc08
4 changed files with 135 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#pragma once
#include "../Common.hpp"
namespace Tesses::Framework::Serialization
{
/**
* @brief A bit converter
*
*/
class BitConverter {
public:
/**
* @brief Get the bits of a double from a int64_t
*
* @param v a int64_t with double's bits
* @return double the double
*/
static double ToDoubleBits(uint64_t v);
/**
* @brief Get the bits of a int64_t from a double
*
* @param v a double with int64_t's bits
* @return uint64_t the int64_t
*/
static uint64_t ToUintBits(double v);
/**
* @brief Get big endian double from uint8_t reference of first element of 8 byte array
*
* @param b a reference to the first byte of an array
* @return double the double
*/
static double ToDoubleBE(uint8_t& b);
/**
* @brief Get big endian uint64_t from uint8_t reference of first element of 8 byte array
*
* @param b a reference to the first byte of an array
* @return uint64_t the uint64_t
*/
static uint64_t ToUint64BE(uint8_t& b);
static uint32_t ToUint32BE(uint8_t& b);
static uint16_t ToUint16BE(uint8_t& b);
static void FromDoubleBE(uint8_t& b, double v);
static void FromUint64BE(uint8_t& b, uint64_t v);
static void FromUint32BE(uint8_t& b, uint32_t v);
static void FromUint16BE(uint8_t& b, uint16_t v);
};
}

View File

@@ -37,3 +37,4 @@
#include "Platform/Environment.hpp"
#include "Platform/Process.hpp"
#include "Text/StringConverter.hpp"
#include "Serialization/BitConverter.hpp"