C++ Utilities 5.26.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
binaryconversion.h File Reference
#include "../global.h"
#include "../misc/traits.h"
#include <cstdint>
#include <cstring>
#include "./binaryconversionprivate.h"
Include dependency graph for binaryconversion.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  CppUtilities
 Contains all utilities provides by the c++utilities library.
 
namespace  CppUtilities::BE
 Encapsulates binary conversion functions using the big endian byte order.
 
namespace  CppUtilities::LE
 Encapsulates binary conversion functions using the little endian byte order.
 

Macros

#define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL   0
 
#define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL   1
 

Functions

CPP_UTILITIES_EXPORT constexpr std::uint16_t CppUtilities::toFixed8 (float float32value)
 Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
 
CPP_UTILITIES_EXPORT constexpr float CppUtilities::toFloat32 (std::uint16_t fixed8value)
 Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::toFixed16 (float float32value)
 Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
 
CPP_UTILITIES_EXPORT constexpr float CppUtilities::toFloat32 (std::uint32_t fixed16value)
 Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::toSynchsafeInt (std::uint32_t normalInt)
 Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::toNormalInt (std::uint32_t synchsafeInt)
 Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
 
CPP_UTILITIES_EXPORT constexpr std::uint16_t CppUtilities::swapOrder (std::uint16_t value)
 Swaps the byte order of the specified 16-bit unsigned integer.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::swapOrder (std::uint32_t value)
 Swaps the byte order of the specified 32-bit unsigned integer.
 
CPP_UTILITIES_EXPORT constexpr std::uint64_t CppUtilities::swapOrder (std::uint64_t value)
 Swaps the byte order of the specified 64-bit unsigned integer.
 
CPP_UTILITIES_EXPORT constexpr std::int16_t CppUtilities::swapOrder (std::int16_t value)
 Swaps the byte order of the specified 16-bit integer.
 
CPP_UTILITIES_EXPORT constexpr std::int32_t CppUtilities::swapOrder (std::int32_t value)
 Swaps the byte order of the specified 32-bit integer.
 
CPP_UTILITIES_EXPORT constexpr std::int64_t CppUtilities::swapOrder (std::int64_t value)
 Swaps the byte order of the specified 64-bit integer.
 
CPP_UTILITIES_EXPORT constexpr std::int16_t CppUtilities::BE::toInt16 (const char *value)
 Returns a 16-bit signed integer converted from two bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint16_t CppUtilities::BE::toUInt16 (const char *value)
 Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::int32_t CppUtilities::BE::toInt32 (const char *value)
 Returns a 32-bit signed integer converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::BE::toUInt24 (const char *value)
 Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::BE::toUInt32 (const char *value)
 Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::int64_t CppUtilities::BE::toInt64 (const char *value)
 Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint64_t CppUtilities::BE::toUInt64 (const char *value)
 Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT float CppUtilities::BE::toFloat32 (const char *value)
 Returns a 32-bit floating point number converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT double CppUtilities::BE::toFloat64 (const char *value)
 Returns a 64-bit floating point number converted from eight bytes at a specified position in a char array.
 
template<class T , Traits::EnableIf< std::is_integral< T > > * = nullptr>
CPP_UTILITIES_EXPORTCppUtilities::BE::toInt (const char *value)
 Returns the specified (unsigned) integer converted from the specified char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::BE::getBytes24 (std::uint32_t value, char *outputbuffer)
 Stores the specified 24-bit unsigned integer value at a specified position in a char array.
 
template<class T , Traits::EnableIf< std::is_integral< T > > * = nullptr>
CPP_UTILITIES_EXPORT void CppUtilities::BE::getBytes (T value, char *outputbuffer)
 Stores the specified (unsigned) integer value in a char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::BE::getBytes (float value, char *outputbuffer)
 Stores the specified 32-bit floating point value at a specified position in a char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::BE::getBytes (double value, char *outputbuffer)
 Stores the specified 64-bit floating point value at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::int16_t CppUtilities::LE::toInt16 (const char *value)
 Returns a 16-bit signed integer converted from two bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint16_t CppUtilities::LE::toUInt16 (const char *value)
 Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::int32_t CppUtilities::LE::toInt32 (const char *value)
 Returns a 32-bit signed integer converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::LE::toUInt24 (const char *value)
 Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint32_t CppUtilities::LE::toUInt32 (const char *value)
 Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::int64_t CppUtilities::LE::toInt64 (const char *value)
 Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT constexpr std::uint64_t CppUtilities::LE::toUInt64 (const char *value)
 Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT float CppUtilities::LE::toFloat32 (const char *value)
 Returns a 32-bit floating point number converted from four bytes at a specified position in a char array.
 
CPP_UTILITIES_EXPORT double CppUtilities::LE::toFloat64 (const char *value)
 Returns a 64-bit floating point number converted from eight bytes at a specified position in a char array.
 
template<class T , Traits::EnableIf< std::is_integral< T > > * = nullptr>
CPP_UTILITIES_EXPORTCppUtilities::LE::toInt (const char *value)
 Returns the specified (unsigned) integer converted from the specified char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::LE::getBytes24 (std::uint32_t value, char *outputbuffer)
 Stores the specified 24-bit unsigned integer value at a specified position in a char array.
 
template<class T , Traits::EnableIf< std::is_integral< T > > * = nullptr>
CPP_UTILITIES_EXPORT void CppUtilities::LE::getBytes (T value, char *outputbuffer)
 Stores the specified (unsigned) integer value in a char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::LE::getBytes (float value, char *outputbuffer)
 Stores the specified 32-bit floating point value at a specified position in a char array.
 
CPP_UTILITIES_EXPORT void CppUtilities::LE::getBytes (double value, char *outputbuffer)
 Stores the specified 64-bit floating point value at a specified position in a char array.
 

Macro Definition Documentation

◆ CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL [1/2]

#define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL   0

Definition at line 209 of file binaryconversion.h.

◆ CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL [2/2]

#define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL   1

Definition at line 209 of file binaryconversion.h.