Ocean
Ocean::IO::Utilities Class Reference

This class implements utility functions for input and output operations. More...

Public Types

typedef std::vector< uint8_t > Buffer
 Definition of a vector holding 8 bit elements. More...
 

Static Public Member Functions

static bool readFile (const std::string &filename, Buffer &buffer)
 Reads a file and copies the data into a buffer. More...
 
static void encodeHomogenousMatrix4 (const HomogenousMatrix4 &matrix, Buffer &buffer)
 Encodes a 4x4 homogeneous matrix. More...
 
static Buffer encodeHomogenousMatrix4 (const HomogenousMatrix4 &matrix, const size_t reservedHeaderSize=0)
 Encodes a 4x4 homogeneous matrix. More...
 
static bool decodeHomogenousMatrix4 (const uint8_t *&data, size_t &size, HomogenousMatrix4 &matrix)
 Decodes a 4x4 homogeneous matrix. More...
 
static bool decodeHomogenousMatrix4 (const Buffer &buffer, HomogenousMatrix4 &matrix)
 Decodes a 4x4 homogeneous matrix. More...
 
static void encodeVectors2 (const Vector2 *vectors, const size_t size, Buffer &buffer)
 Encodes a set of given 2D vectors. More...
 
static Buffer encodeVectors2 (const Vector2 *vectors, const size_t size, const size_t reservedHeaderSize=0)
 Encodes a set of given 2D vectors. More...
 
static bool decodeVectors2 (const uint8_t *&data, size_t &size, Vectors2 &vectors)
 Decodes a set of 2D vectors. More...
 
static bool decodeVectors2 (const Buffer &buffer, Vectors2 &vectors)
 Decodes a set of 2D vectors. More...
 
static void encodeVectors3 (const Vector3 *vectors, const size_t size, Buffer &buffer)
 Encodes a set of given 3D vectors. More...
 
static Buffer encodeVectors3 (const Vector3 *vectors, const size_t size, const size_t reservedHeaderSize=0)
 Encodes a set of given 3D vectors. More...
 
static bool decodeVectors3 (const uint8_t *&data, size_t &size, Vectors3 &vectors)
 Decodes a set of 3D vectors. More...
 
static bool decodeVectors3 (const Buffer &buffer, Vectors3 &vectors)
 Decodes a set of 3D vectors. More...
 
static void encodeVectors4 (const Vector4 *vectors, const size_t size, Buffer &buffer)
 Encodes a set of given 4D vectors. More...
 
static Buffer encodeVectors4 (const Vector4 *vectors, const size_t size, const size_t reservedHeaderSize=0)
 Encodes a set of given 4D vectors. More...
 
static bool decodeVectors4 (const uint8_t *&data, size_t &size, Vectors4 &vectors)
 Decodes a set of 4D vectors. More...
 
static bool decodeVectors4 (const Buffer &buffer, Vectors4 &vectors)
 Decodes a set of 4D vectors. More...
 

Detailed Description

This class implements utility functions for input and output operations.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8_t> Ocean::IO::Utilities::Buffer

Definition of a vector holding 8 bit elements.

Member Function Documentation

◆ decodeHomogenousMatrix4() [1/2]

bool Ocean::IO::Utilities::decodeHomogenousMatrix4 ( const Buffer buffer,
HomogenousMatrix4 matrix 
)
inlinestatic

Decodes a 4x4 homogeneous matrix.

The buffer must provide the matrix with 64 bit precision.

Parameters
bufferThe buffer providing the matrix data
matrixThe resulting matrix
Returns
True, if succeeded

◆ decodeHomogenousMatrix4() [2/2]

static bool Ocean::IO::Utilities::decodeHomogenousMatrix4 ( const uint8_t *&  data,
size_t &  size,
HomogenousMatrix4 matrix 
)
static

Decodes a 4x4 homogeneous matrix.

The buffer must provide the matrix with 64 bit precision.

Parameters
dataThe pointer to the buffer providing the matrix data, will be shifted by the number of consumed bytes afterwards
sizeThe size of the entire buffer, will be reduced by the number of consumed bytes afterwards
matrixThe resulting matrix
Returns
True, if succeeded

◆ decodeVectors2() [1/2]

bool Ocean::IO::Utilities::decodeVectors2 ( const Buffer buffer,
Vectors2 vectors 
)
inlinestatic

Decodes a set of 2D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
bufferThe buffer providing the 2D vectors
vectorsThe resulting vectors
Returns
True, if succeeded

◆ decodeVectors2() [2/2]

static bool Ocean::IO::Utilities::decodeVectors2 ( const uint8_t *&  data,
size_t &  size,
Vectors2 vectors 
)
static

Decodes a set of 2D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
dataThe pointer to the buffer providing the 2D vectors, will be shifted by the number of consumed bytes afterwards
sizeThe size of the entire buffer, will be reduced by the number of consumed bytes afterwards
vectorsThe resulting vectors
Returns
True, if succeeded

◆ decodeVectors3() [1/2]

bool Ocean::IO::Utilities::decodeVectors3 ( const Buffer buffer,
Vectors3 vectors 
)
inlinestatic

Decodes a set of 3D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
bufferThe buffer providing the 3D vectors
vectorsThe resulting vectors
Returns
True, if succeeded

◆ decodeVectors3() [2/2]

static bool Ocean::IO::Utilities::decodeVectors3 ( const uint8_t *&  data,
size_t &  size,
Vectors3 vectors 
)
static

Decodes a set of 3D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
dataThe pointer to the buffer providing the 3D vectors, will be shifted by the number of consumed bytes afterwards
sizeThe size of the entire buffer, will be reduced by the number of consumed bytes afterwards
vectorsThe resulting vectors
Returns
True, if succeeded

◆ decodeVectors4() [1/2]

bool Ocean::IO::Utilities::decodeVectors4 ( const Buffer buffer,
Vectors4 vectors 
)
inlinestatic

Decodes a set of 4D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
bufferThe buffer providing the 4D vectors
vectorsThe resulting vectors
Returns
True, if succeeded

◆ decodeVectors4() [2/2]

static bool Ocean::IO::Utilities::decodeVectors4 ( const uint8_t *&  data,
size_t &  size,
Vectors4 vectors 
)
static

Decodes a set of 4D vectors.

The buffer must provide the vectors with 64 bit precision.

Parameters
dataThe pointer to the buffer providing the 4D vectors, will be shifted by the number of consumed bytes afterwards
sizeThe size of the entire buffer, will be reduced by the number of consumed bytes afterwards
vectorsThe resulting vectors
Returns
True, if succeeded

◆ encodeHomogenousMatrix4() [1/2]

static void Ocean::IO::Utilities::encodeHomogenousMatrix4 ( const HomogenousMatrix4 matrix,
Buffer buffer 
)
static

Encodes a 4x4 homogeneous matrix.

The matrix will be stored with 64 bit precision.

Parameters
matrixThe homogeneous matrix which will be encoded
bufferThe resulting buffer which will be extended so that already existing data stays untouched

◆ encodeHomogenousMatrix4() [2/2]

Utilities::Buffer Ocean::IO::Utilities::encodeHomogenousMatrix4 ( const HomogenousMatrix4 matrix,
const size_t  reservedHeaderSize = 0 
)
inlinestatic

Encodes a 4x4 homogeneous matrix.

The matrix will be stored with 64 bit precision.

Parameters
matrixThe homogeneous matrix which will be encoded
reservedHeaderSizeThe number of bytes which will be reserved for an optional header, so that the resulting buffer has a header followed by the payload data
Returns
The resulting buffer storing the given matrix

◆ encodeVectors2() [1/2]

static void Ocean::IO::Utilities::encodeVectors2 ( const Vector2 vectors,
const size_t  size,
Buffer buffer 
)
static

Encodes a set of given 2D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
bufferThe resulting buffer which will be extended so that already existing data stays untouched

◆ encodeVectors2() [2/2]

Utilities::Buffer Ocean::IO::Utilities::encodeVectors2 ( const Vector2 vectors,
const size_t  size,
const size_t  reservedHeaderSize = 0 
)
inlinestatic

Encodes a set of given 2D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
reservedHeaderSizeThe number of bytes which will be reserved for an optional header, so that the resulting buffer has a header followed by the payload data
Returns
The resulting buffer storing the given vectors

◆ encodeVectors3() [1/2]

static void Ocean::IO::Utilities::encodeVectors3 ( const Vector3 vectors,
const size_t  size,
Buffer buffer 
)
static

Encodes a set of given 3D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
bufferThe resulting buffer which will be extended so that already existing data stays untouched

◆ encodeVectors3() [2/2]

Utilities::Buffer Ocean::IO::Utilities::encodeVectors3 ( const Vector3 vectors,
const size_t  size,
const size_t  reservedHeaderSize = 0 
)
inlinestatic

Encodes a set of given 3D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
reservedHeaderSizeThe number of bytes which will be reserved for an optional header, so that the resulting buffer has a header followed by the payload data
Returns
The resulting buffer storing the given vectors

◆ encodeVectors4() [1/2]

static void Ocean::IO::Utilities::encodeVectors4 ( const Vector4 vectors,
const size_t  size,
Buffer buffer 
)
static

Encodes a set of given 4D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
bufferThe resulting buffer which will be extended so that already existing data stays untouched

◆ encodeVectors4() [2/2]

Utilities::Buffer Ocean::IO::Utilities::encodeVectors4 ( const Vector4 vectors,
const size_t  size,
const size_t  reservedHeaderSize = 0 
)
inlinestatic

Encodes a set of given 4D vectors.

The vectors will be stored with 64 bit precision.

Parameters
vectorsThe vectors to encode
sizeThe number of given vectors
reservedHeaderSizeThe number of bytes which will be reserved for an optional header, so that the resulting buffer has a header followed by the payload data
Returns
The resulting buffer storing the given vectors

◆ readFile()

static bool Ocean::IO::Utilities::readFile ( const std::string &  filename,
Buffer buffer 
)
static

Reads a file and copies the data into a buffer.

In case the file exists but is empty, the resulting buffer will be empty but the function succeeds.

Parameters
filenameThe name of the file from which the data will be read, must be valid
bufferThe buffer receiving the data
Returns
True, if succeeded

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