NkEndianness.h
#include "NKPlatform/NkEndianness.h"nkentseu::platformnkentseudependson(["NKPlatform"])Types
NkEndianness | Enumeration of the supported byte orders |
Functions · 50
NkGetCompileTimeEndianness | Byte order detection at compile time (NK API) |
NkGetRuntimeEndianness | Byte order detection at run time (NK API) |
NkIsLittleEndian | Checks whether the system is little-endian |
NkIsBigEndian | Checks whether the system is big-endian |
ByteSwap16 | Reverses the bytes of a 16-bit integer |
NkByteSwap16 | NK alias for ByteSwap16 |
ByteSwap32 | Reverses the bytes of a 32-bit integer |
NkByteSwap32 | NK alias for ByteSwap32 |
ByteSwap64 | Reverses the bytes of a 64-bit integer |
NkByteSwap64 | NK alias for ByteSwap64 |
ByteSwap | Generic byte swap through a template |
HostToNetwork16 | Converts a uint16 from host to network byte order (big-endian) |
NkHostToNetwork16 | NK alias for HostToNetwork16 |
HostToNetwork32 | Converts a uint32 from host to network byte order (big-endian) |
NkHostToNetwork32 | NK alias for HostToNetwork32 |
HostToNetwork64 | Converts a uint64 from host to network byte order (big-endian) |
NkHostToNetwork64 | NK alias for HostToNetwork64 |
NetworkToHost16 | Converts a uint16 from network to host byte order |
NkNetworkToHost16 | NK alias for NetworkToHost16 |
NetworkToHost32 | Converts a uint32 from network to host byte order |
NkNetworkToHost32 | NK alias for NetworkToHost32 |
NetworkToHost64 | Converts a uint64 from network to host byte order |
NkNetworkToHost64 | NK alias for NetworkToHost64 |
ToLittleEndian | Converts a value to little-endian |
FromLittleEndian | Converts a value from little-endian |
ToBigEndian | Converts a value to big-endian |
FromBigEndian | Converts a value from big-endian |
ByteSwapBuffer | Reverses the bytes of every element of a buffer |
BufferToLittleEndian | Converts a buffer to little-endian |
BufferFromLittleEndian | Converts a buffer from little-endian |
BufferToBigEndian | Converts a buffer to big-endian |
BufferFromBigEndian | Converts a buffer from big-endian |
ReadUnaligned16 | Reads a uint16 from a possibly unaligned address |
ReadUnaligned32 | Reads a uint32 from a possibly unaligned address |
ReadUnaligned64 | Reads a uint64 from a possibly unaligned address |
WriteUnaligned16 | Writes a uint16 to a possibly unaligned address |
WriteUnaligned32 | Writes a uint32 to a possibly unaligned address |
WriteUnaligned64 | Writes a uint64 to a possibly unaligned address |
ReadLE16 | Reads a little-endian uint16 from unaligned memory |
ReadLE32 | Reads a little-endian uint32 from unaligned memory |
ReadLE64 | Reads a little-endian uint64 from unaligned memory |
ReadBE16 | Reads a big-endian uint16 from unaligned memory |
ReadBE32 | Reads a big-endian uint32 from unaligned memory |
ReadBE64 | Reads a big-endian uint64 from unaligned memory |
WriteLE16 | Writes a little-endian uint16 to unaligned memory |
WriteLE32 | Writes a little-endian uint32 to unaligned memory |
WriteLE64 | Writes a little-endian uint64 to unaligned memory |
WriteBE16 | Writes a big-endian uint16 to unaligned memory |
WriteBE32 | Writes a big-endian uint32 to unaligned memory |
WriteBE64 | Writes a big-endian uint64 to unaligned memory |
Macros · 13
NKENTSEU_FORCE_INLINE | |
NK_LITTLE_ENDIAN | Macro telling whether the platform is little-endian |
NK_BIG_ENDIAN | Macro telling whether the platform is big-endian |
NK_ENDIAN_UNKNOWN | Macro signalling an unknown byte order |
NK_BSWAP16 | Short alias for ByteSwap16 |
NK_BSWAP32 | Short alias for ByteSwap32 |
NK_BSWAP64 | Short alias for ByteSwap64 |
NK_HTON16 | Short alias for HostToNetwork16 (htons equivalent) |
NK_HTON32 | Short alias for HostToNetwork32 (htonl equivalent) |
NK_HTON64 | Short alias for HostToNetwork64 |
NK_NTOH16 | Short alias for NetworkToHost16 (ntohs equivalent) |
NK_NTOH32 | Short alias for NetworkToHost32 (ntohl equivalent) |
NK_NTOH64 | Short alias for NetworkToHost64 |
Member details
Byte order detection at compile time (NK API)
if constexpr (NkGetCompileTimeEndianness() == NkEndianness::NK_LITTLE) { // Code optimisé pour little-endian }
Byte order detection at run time (NK API)
Checks whether the system is little-endian
Checks whether the system is big-endian
Macro telling whether the platform is little-endian
Macro telling whether the platform is big-endian
Macro signalling an unknown byte order
Reverses the bytes of a 16-bit integer
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
NK alias for ByteSwap16
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
Reverses the bytes of a 32-bit integer
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
NK alias for ByteSwap32
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
Reverses the bytes of a 64-bit integer
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
NK alias for ByteSwap64
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
Generic byte swap through a template
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | T |
uint32_t swapped = ByteSwap(myValue); float floatSwapped = ByteSwap(myFloat); // via union interne
Converts a uint16 from host to network byte order (big-endian)
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
NK alias for HostToNetwork16
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
Converts a uint32 from host to network byte order (big-endian)
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
NK alias for HostToNetwork32
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
Converts a uint64 from host to network byte order (big-endian)
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
NK alias for HostToNetwork64
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
Converts a uint16 from network to host byte order
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
NK alias for NetworkToHost16
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint16_t |
Converts a uint32 from network to host byte order
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
NK alias for NetworkToHost32
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint32_t |
Converts a uint64 from network to host byte order
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
NK alias for NetworkToHost64
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | uint64_t |
Converts a value to little-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | T |
Converts a value from little-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | T |
Converts a value to big-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | T |
Converts a value from big-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
value | T |
Reverses the bytes of every element of a buffer
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
data | T * | ||
count | size_t |
Converts a buffer to little-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
data | T * | ||
count | size_t |
Converts a buffer from little-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
data | T * | ||
count | size_t |
Converts a buffer to big-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
data | T * | ||
count | size_t |
Converts a buffer from big-endian
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
data | T * | ||
count | size_t |
Reads a uint16 from a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a uint32 from a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a uint64 from a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Writes a uint16 to a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint16_t |
Writes a uint32 to a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint32_t |
Writes a uint64 to a possibly unaligned address
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint64_t |
Reads a little-endian uint16 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a little-endian uint32 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a little-endian uint64 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a big-endian uint16 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a big-endian uint32 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Reads a big-endian uint64 from unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | const void * |
Writes a little-endian uint16 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint16_t |
Writes a little-endian uint32 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint32_t |
Writes a little-endian uint64 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint64_t |
Writes a big-endian uint16 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint16_t |
Writes a big-endian uint32 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint32_t |
Writes a big-endian uint64 to unaligned memory
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
ptr | void * | ||
value | uint64_t |
Short alias for ByteSwap16
Short alias for ByteSwap32
Short alias for ByteSwap64
Short alias for HostToNetwork16 (htons equivalent)
Short alias for HostToNetwork32 (htonl equivalent)
Short alias for HostToNetwork64
Short alias for NetworkToHost16 (ntohs equivalent)
Short alias for NetworkToHost32 (ntohl equivalent)
Short alias for NetworkToHost64