cgul_endian_cxx Class Reference

C++ bindings for cgul_endian More...

#include <cgul_endian_cxx.h>

Collaboration diagram for cgul_endian_cxx:
Collaboration graph

Static Public Member Functions

static int is_big_endian ()
 
static int is_little_endian ()
 
static void swap (void *value, size_t value_size)
 

Detailed Description

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.

Member Function Documentation

§ is_big_endian()

static int cgul_endian_cxx::is_big_endian ( )
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.

Returns
whether the host is big-endian

References cgul_endian__is_big_endian().

§ is_little_endian()

static int cgul_endian_cxx::is_little_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.

Returns
whether the host is little endian

References cgul_endian__is_little_endian().

§ swap()

static void cgul_endian_cxx::swap ( void *  value,
size_t  value_size 
)
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));
        ...
    }
Parameters
[in,out]valuevalue
[in]value_sizesize of value
See also
cgul_int

References cgul_endian__swap().


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