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()) |
|
strong |
|
inline |
Convert a byte array to a numeric value will raise a compiler error if non-numeric type is indicated.
num_typ | numeric type to convert to |
e | endianness of the data passed in the array. it is defaulted to endianness::little |
bytes | byte array |
default_val | in case the endianness of the system or the data is unknown, we just return the default value |
|
inline |
Determine the endianness of the current system architecture
|
inline |
Convert a numeric value to an array of bytes. will raise a compiler error if non-numeric type is indicated.
num_typ | numeric type |
sz | the number of bytes to convert. it is defaulted to sizeof(num_typ) |
e | endianness of data needed. it is defaulted to endianness::little |
val | value to convert in to bytes |