mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Move bitconverter from crosslang to tessesframework
This commit is contained in:
48
include/TessesFramework/Serialization/BitConverter.hpp
Normal file
48
include/TessesFramework/Serialization/BitConverter.hpp
Normal 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);
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user