template class ugcs::vsm::Bo_value

Overview

Helper class for byte-order-dependent value representation. More…

#include <endian.h>

template <typename T, class Converter>
class Bo_value
{
public:
    // construction

    Bo_value(T value = 0);

    // methods

    Bo_value& operator = (T value);
    operator T () const;
    T Get() const;
    static T Get(const void* buffer);
    static void Set(void* buffer, const T value);
};

Detailed Documentation

Helper class for byte-order-dependent value representation.

Construction

Bo_value(T value = 0)

Construct value.

Parameters:

value

Value in host byte order.

Methods

Bo_value& operator = (T value)

Assign new value.

Parameters:

value

Value in host byte order.

operator T () const

Cast to underlying type.

Returns:

Value in host byte order.

T Get() const

Get the value of underlying type.

Returns:

Value in host byte order.

static T Get(const void* buffer)

Interpret byte buffer as a storage for underlying type and return host byte order value.

Caller is responsible for the size of the input buffer.

Parameters:

buffer

Input buffer with original value.

Returns:

Value in host byte order.

static void Set(void* buffer, const T value)

Save value given in host order to byte buffer.

Caller is responsible for the size of the buffer.

Parameters:

buffer

Output buffer to save value to.

value

value in host byte order.