Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cMemT Struct Reference

#include <cMem.h>

Inheritance diagram for Gray::cMemT:
Gray::cValT

Static Public Member Functions

template<class TYPE >
static TYPE ReverseType (TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE HtoN (TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE NtoH (TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE HtoLE (TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE LEtoH (TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE GetUnaligned (const void *pData) noexcept
 
template<typename TYPE >
static void SetUnaligned (void *pData, TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE GetLEtoH (const void *pData) noexcept
 
template<typename TYPE >
static void SetHtoLE (void *pData, TYPE nVal) noexcept
 
template<typename TYPE >
static TYPE GetNtoH (const void *pData) noexcept
 
template<typename TYPE >
static void SetHtoN (void *pData, TYPE nVal) noexcept
 
static DWORD GetNVal3 (const BYTE *p) noexcept
 
static void SetNVal3 (BYTE *p, DWORD nVal) noexcept
 
template<>
WORD ReverseType (WORD nVal) noexcept
 
template<>
UINT32 ReverseType (UINT32 nVal) noexcept
 
template<>
UINT64 ReverseType (UINT64 nVal) noexcept
 
template<>
ULONG ReverseType (ULONG nVal) noexcept
 
- Static Public Member Functions inherited from Gray::cValT
template<class TYPE >
static void Swap (TYPE &a, TYPE &b) noexcept
 
template<class TYPE >
static COMPARE_t Compare (const TYPE &a, const TYPE &b) noexcept
 
template<>
COMPARE_t Compare (const cTimeFile &t1, const cTimeFile &t2)
 

Detailed Description

collection of templates to handle An arbitrary value type in memory. cValT in heap, const or stack. Deal with it as an array of bytes.

Member Function Documentation

◆ GetLEtoH()

template<typename TYPE >
static TYPE Gray::cMemT::GetLEtoH ( const void *  pData)
inlinestaticnoexcept

Get bytes packed as LE (Intel). ( Not "Network order" which is big endian.)

◆ GetNtoH()

template<typename TYPE >
static TYPE Gray::cMemT::GetNtoH ( const void *  pData)
inlinestaticnoexcept

Get bytes packed as BE (Network order, Not Intel). similar to CopyNtoH()

◆ GetNVal3()

static DWORD Gray::cMemT::GetNVal3 ( const BYTE *  p)
inlinestaticnoexcept

Get 3 packed BYTEs as a host value. from Network order. Big Endian. opposite of SetNVal3()

◆ GetUnaligned()

template<typename TYPE >
static TYPE Gray::cMemT::GetUnaligned ( const void *  pData)
inlinestaticnoexcept

Get a data value from an unaligned TYPE pointer. Like the _WIN32 UNALIGNED macro.

Note
some architectures will crash if you try to access unaligned data. (PowerPC) In this case we need to memcpy() to a temporary buffer first.

◆ HtoLE()

template<typename TYPE >
static TYPE Gray::cMemT::HtoLE ( TYPE  nVal)
inlinestaticnoexcept

Host byte order to little endian. (Intel)

Assume bytes are correct bit order but larger types are not ordered correctly.

◆ HtoN()

template<typename TYPE >
static TYPE Gray::cMemT::HtoN ( TYPE  nVal)
inlinestaticnoexcept

Host byte order to network order (big endian). like htonl() htons()

◆ LEtoH()

template<typename TYPE >
static TYPE Gray::cMemT::LEtoH ( TYPE  nVal)
inlinestaticnoexcept

Little Endian (Intel) to host byte order.

Assume bytes are correct bit order but larger types are not ordered correctly.

◆ NtoH()

template<typename TYPE >
static TYPE Gray::cMemT::NtoH ( TYPE  nVal)
inlinestaticnoexcept

Network byte order (big endian) to host order. like ntohl() ntohs() Network order = BigEndian = High order comes first = Not Intel.

◆ ReverseType() [1/5]

template<class TYPE >
static TYPE Gray::cMemT::ReverseType ( TYPE  nVal)
inlinestaticnoexcept

Reverse the byte order in an intrinsic type. Like GNUC __builtin_bswap16(), __builtin_bswap32, etc Similar to: ntohl(), htonl(), ntohs(), htons().

◆ ReverseType() [2/5]

template<>
UINT32 Gray::cMemT::ReverseType ( UINT32  nVal)
inlinestaticnoexcept

Reverse the bytes in an intrinsic 32 bit type UINT32. like ntohl(),htonl()

◆ ReverseType() [3/5]

template<>
UINT64 Gray::cMemT::ReverseType ( UINT64  nVal)
inlinestaticnoexcept

Reverse the bytes in an intrinsic 64 bit type UINT64.

◆ ReverseType() [4/5]

template<>
ULONG Gray::cMemT::ReverseType ( ULONG  nVal)
inlinestaticnoexcept

ULONG may be equiv to UINT32 or UINT64

◆ ReverseType() [5/5]

template<>
WORD Gray::cMemT::ReverseType ( WORD  nVal)
inlinestaticnoexcept

Reverse the bytes in an intrinsic 16 bit type WORD. e.g. 0x1234 = 0x3412 like ntohs(),htons(), MAKEWORD()

◆ SetHtoLE()

template<typename TYPE >
static void Gray::cMemT::SetHtoLE ( void *  pData,
TYPE  nVal 
)
inlinestaticnoexcept

Set bytes packed as LE (Intel). ( Not "Network order" which is big endian.)

◆ SetHtoN()

template<typename TYPE >
static void Gray::cMemT::SetHtoN ( void *  pData,
TYPE  nVal 
)
inlinestaticnoexcept

Set bytes packed as BE (Network order, Not Intel). similar to CopyHtoN()

◆ SetNVal3()

static void Gray::cMemT::SetNVal3 ( BYTE *  p,
DWORD  nVal 
)
inlinestaticnoexcept

Set 3 packed BYTEs as a value. Network order. Big Endian. opposite of GetNVal3()

◆ SetUnaligned()

template<typename TYPE >
static void Gray::cMemT::SetUnaligned ( void *  pData,
TYPE  nVal 
)
inlinestaticnoexcept

Get a data value from an unaligned TYPE pointer. Like the _WIN32 UNALIGNED macro.

Note
some architectures will crash if you try to access unaligned data. (PowerPC) In this case we need to memcpy() to a temporary buffer first.

The documentation for this struct was generated from the following file: