Enumerations | Functions

GridClientByteUtils Namespace Reference

Enumerations

enum  ByteOrder { BIG_ENDIAN_ORDER = 1, LITTLE_ENDIAN_ORDER = 2 }

Functions

template<class T >
void bytesToValue (const int8_t *buf, size_t nBytes, T &res, const ByteOrder &order=BIG_ENDIAN_ORDER)
template<class T >
void valueToBytes (const T &val, std::vector< int8_t > &bytes, const ByteOrder &order=BIG_ENDIAN_ORDER)
template<class T >
void valueToBytes (const T &val, int8_t *buf, size_t nBytes, const ByteOrder &order=BIG_ENDIAN_ORDER)
template<class IT , class T >
T bitwiseOr (IT first, IT last, T initVal)

Detailed Description

Utilities for converting simple types to byte array and back.


Enumeration Type Documentation

Byte order on current platform.


Function Documentation

template<class IT , class T >
T GridClientByteUtils::bitwiseOr ( IT  first,
IT  last,
T  initVal 
)

Calculates a bitwise OR result for members of a given range.

Parameters:
first First range element, inclusive.
last Last range element, exclusive.
initVal Initial value for the calculation.
Returns:
A bitwise OR result.
template<class T >
void GridClientByteUtils::bytesToValue ( const int8_t *  buf,
size_t  nBytes,
T &  res,
const ByteOrder &  order = BIG_ENDIAN_ORDER 
)

Convert byte array to a primitive value.

Parameters:
buf Byte array.
nBytes Number of bytes in array.
res Resulting value.
order Byte order.
template<class T >
void GridClientByteUtils::valueToBytes ( const T &  val,
int8_t *  buf,
size_t  nBytes,
const ByteOrder &  order = BIG_ENDIAN_ORDER 
)

Convert a primitive value to byte array.

Parameters:
val Value to convert to bytes.
buf Resulting array.
nBytes Byte array length.
order Byte order.
template<class T >
void GridClientByteUtils::valueToBytes ( const T &  val,
std::vector< int8_t > &  bytes,
const ByteOrder &  order = BIG_ENDIAN_ORDER 
)

Convert a primitive value to a vector of bytes.

Parameters:
val Value to convert to bytes.
bytes Resulting array.
order Byte order.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends