C++ bindings for cgul_endian
More...
#include <cgul_endian_cxx.h>

Static Public Member Functions | |
| static int | is_big_endian () |
| static int | is_little_endian () |
| static void | swap (void *value, size_t value_size) |
This class provides the C++ bindings for C cgul_endian external functions. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_endian into C++-style function calls and exception handling.
|
inlinestatic |
Return whether the host is big endian. This is a fast run-time test, but calling it before each swap will adversely affect performance.
References cgul_endian__is_big_endian().
|
inlinestatic |
Return whether the host is little endian. This is a fast run-time test, but calling it before each swap will adversely affect performance.
References cgul_endian__is_little_endian().
|
inlinestatic |
Byte swap the first value_size bytes in the region of memory pointed to by value. If value is in big-endian format, it will be converted to little-endian format and vice versa.
The following example shows how to convert an unsigned, big-endian 32-bit integer to the host format (assuming the host is either big endian or little endian instead of one of the more exotic formats):
cgul_uint32_t value;
... if (cgul_endian_cxx::is_little_endian(cex)) {
...
cgul_endian_cxx::swap(cex, (char*)&value, sizeof(value));
...
}
| [in,out] | value | value |
| [in] | value_size | size of value |
References cgul_endian__swap().