Skip to content

util

Functions

Name
std::string to_string(const std::vector< unsigned char > & bytes)
Convert a byte array to a hexadecimal string.
bool isLittleEndian()
Checks if the architecture is little endian.
template <typename T >
T
HexASCII2Num(const char * p_char, std::size_t num_nibbles_resolution =sizeof(T) *2)
Converts a hexadecimal ASCII char array into a number.
template <typename T >
std::vector< T >
HexASCII2NumStr(std::string_view string)
Converts a hexadecimal ASCII char array into a vector of numbers.
template <typename T >
std::enable_if< std::is_same< typenameT::value_type, uint8_t >::value >::type
AdjustEndianess(T & data, std::optional< typename T::iterator > start =std::nullopt, std::optional< typename T::iterator > finish =std::nullopt)
Adjust endianess if needed.

Functions Documentation

function to_string

static std::string to_string(
    const std::vector< unsigned char > & bytes
)

Convert a byte array to a hexadecimal string.

Parameters:

  • bytes A vector of bytes to be converted.

Return: A hexadecimal string representation of the bytes.

function isLittleEndian

static bool isLittleEndian()

Checks if the architecture is little endian.

Return: true if little endian, false otherwise

function HexASCII2Num

template <typename T >
static T HexASCII2Num(
    const char * p_char,
    std::size_t num_nibbles_resolution =sizeof(T) *2
)

Converts a hexadecimal ASCII char array into a number.

Parameters:

  • p_char Hexadecimal ASCII char array
  • num_nibbles_resolution How many nibbles will constitute a number

Template Parameters:

  • T uint8_t, uint16_t, uint32_t or uint64_t

Return: The converted number (8-64 bit variable)

function HexASCII2NumStr

template <typename T >
std::vector< T > HexASCII2NumStr(
    std::string_view string
)

Converts a hexadecimal ASCII char array into a vector of numbers.

Parameters:

  • p_char Hexadecimal ASCII char array
  • char_ptr_size Size of the char array

Template Parameters:

  • T uint8_t, uint16_t, uint32_t or uint64_t

Return: The vector of converted numbers

function AdjustEndianess

template <typename T >
static std::enable_if< std::is_same< typenameT::value_type, uint8_t >::value >::type AdjustEndianess(
    T & data,
    std::optional< typename T::iterator > start =std::nullopt,
    std::optional< typename T::iterator > finish =std::nullopt
)

Adjust endianess if needed.

Parameters:

  • data The container of data (vector/array)
  • start Optional beginning of the valid data
  • finish Optional ending of the valid data

Template Parameters:

  • T std::vector or std::array

Updated on 2026-03-04 at 13:10:44 -0800