Corelink CPP Client
Corelink C++ client library
 
Loading...
Searching...
No Matches
corelink::utils::system Namespace Reference

Namespaces

namespace  _internals
 

Enumerations

enum class  endianness { big , little , unknown }
 Mark the endianness of data in the memory. More...
 

Functions

CORELINK_EXPORT endianness sys_endianness ()
 
template<typename num_typ , size_t sz = sizeof(num_typ), endianness e = endianness::little>
CORELINK_EXPORT std::vector< uint8_t > to_bytes (num_typ val)
 
template<typename num_typ , endianness e = endianness::little>
CORELINK_EXPORT num_typ from_bytes (std::vector< uint8_t > bytes, num_typ default_val=num_typ())
 

Enumeration Type Documentation

◆ endianness

Mark the endianness of data in the memory.

this enum facilitates different types of endianness-es of data in memory C++ 20 has std::endian but since we are still floating between 11-17, we define some rudimentary items ourselves

Enumerator
big 
little 
unknown 

Function Documentation

◆ from_bytes()

template<typename num_typ , endianness e = endianness::little>
CORELINK_EXPORT num_typ corelink::utils::system::from_bytes ( std::vector< uint8_t > bytes,
num_typ default_val = num_typ() )
inline

Convert a byte array to a numeric value will raise a compiler error if non-numeric type is indicated.

Template Parameters
num_typnumeric type to convert to
eendianness of the data passed in the array. it is defaulted to endianness::little
Parameters
bytesbyte array
default_valin case the endianness of the system or the data is unknown, we just return the default value
Returns
value of num_typ

◆ sys_endianness()

CORELINK_EXPORT endianness corelink::utils::system::sys_endianness ( )
inline

Determine the endianness of the current system architecture

Returns

◆ to_bytes()

template<typename num_typ , size_t sz = sizeof(num_typ), endianness e = endianness::little>
CORELINK_EXPORT std::vector< uint8_t > corelink::utils::system::to_bytes ( num_typ val)
inline

Convert a numeric value to an array of bytes. will raise a compiler error if non-numeric type is indicated.

Template Parameters
num_typnumeric type
szthe number of bytes to convert. it is defaulted to sizeof(num_typ)
eendianness of data needed. it is defaulted to endianness::little
Parameters
valvalue to convert in to bytes
Returns
array with bytes of data as signified by the endianness if the required order is anything other than endianness::little or endianness::big an empty buffer is returned