Endian is a helper class that figures out the host's byte order.
More...
#include <Endian.h>
List of all members.
Public Member Functions |
| Endian (void) |
bool | isHostBigEndian (void) const |
| Determine if the host is big endian.
|
bool | isHostLittleEndian (void) const |
| Determine if the host is little endian.
|
Static Public Member Functions |
template<size_t size> |
static void | swap (void *buffer) |
| Swap byte order.
|
static void | swap (void *buffer, size_t size) |
| Swap byte order.
|
Protected Attributes |
union { |
int word |
char byte [sizeof(int)] |
}; | |
Detailed Description
The Endian class is used to figure out if the host is big or little endian and swap between byte orders.
Definition at line 30 of file Endian.h.
Constructor & Destructor Documentation
Member Function Documentation
This method returns true when the host is big endian. The compiler should be able the optimize this function call away.
Definition at line 41 of file Endian.h.
References byte.
This method returns true when the host is little endian. The compiler should be able the optimize this function call away.
Definition at line 48 of file Endian.h.
References byte.
This method swaps the byte order of the buffer.
- Parameters:
-
size | the length of the buffer (in most cases it is a power of 2) |
buffer | the data to be swapped |
Definition at line 59 of file Endian.h.
static void Endian::swap |
( |
void * |
buffer, |
|
|
size_t |
size |
|
) |
| [inline, static] |
This method swaps the byte order of the buffer.
- Parameters:
-
buffer | the data to be swapped |
size | the length of the buffer (in most cases it is a power of 2) |
Definition at line 79 of file Endian.h.
Member Data Documentation
union { ... } [protected] |
The documentation for this class was generated from the following file: