VR-Engage  2.2
Loading...
Searching...
No Matches
makRadarFx::DtStreamWriter Class Reference

Detailed Description

This class writes and encodes various data types into a byte array in little endian format. It provides methods for writing primitive types as well as common complex data structures.

#include <byteStream.h>

Inheritance diagram for makRadarFx::DtStreamWriter:
[legend]

Public Member Functions

 DtStreamWriter (int length)
 
 DtStreamWriter (unsigned char *buffer, int length)
 
virtual ~DtStreamWriter ()
 
Buffer Access Methods
virtual unsigned char * buffer ()
 
virtual int length ()
 

Value Writing Methods

Each method writes a value and advances the write position

unsigned char * myBuffer
 
unsigned char * myWriteHead
 
int myLength
 
bool myShouldDelete
 
virtual void writeBool (bool b)
 
virtual void writeInt8 (char num)
 
virtual void writeUInt8 (unsigned char num)
 
virtual void writeInt16 (short num)
 
virtual void writeUInt16 (unsigned short num)
 
virtual void writeInt32 (int num)
 
virtual void writeUInt32 (unsigned int num)
 
virtual void writeInt64 (long long num)
 
virtual void writeUInt64 (unsigned long long num)
 
virtual void writeSingle (float num)
 
virtual void writeDouble (double num)
 
virtual void writeString (std::string &str)
 
virtual void writeVector (DtVector &vec)
 
virtual void writeTaitBryan (DtTaitBryan &tb)
 
virtual void writeQuaternion (const DtQuaternion &q)
 
virtual void writeEntityId (const DtEntityIdentifier &id)
 
virtual void writeEntityType (const DtEntityType &type)
 
virtual void writeBytes (unsigned char *buffer, int length)
 
void encodeStringSize (int size)
 

Constructor & Destructor Documentation

◆ DtStreamWriter() [1/2]

makRadarFx::DtStreamWriter::DtStreamWriter ( int length)

Constructor that creates an internal buffer.

Parameters
lengthSize of the internal buffer to create

Creates a new stream writer with an internal buffer of the specified size. Care must be taken to allocate enough space for all the intended writes.

References length().

◆ DtStreamWriter() [2/2]

makRadarFx::DtStreamWriter::DtStreamWriter ( unsigned char * buffer,
int length )

Constructor that uses an existing buffer.

Parameters
bufferPointer to the buffer to write to
lengthSize of the buffer in bytes

Creates a new stream writer using the provided buffer. Care must be taken to ensure the buffer has enough space for all writes.

References buffer(), and length().

◆ ~DtStreamWriter()

virtual makRadarFx::DtStreamWriter::~DtStreamWriter ( )
virtual

Virtual destructor.

Cleans up resources, including the buffer if it was allocated internally

Member Function Documentation

◆ buffer()

virtual unsigned char * makRadarFx::DtStreamWriter::buffer ( )
virtual

Gets a pointer to the internal buffer.

Returns
Pointer to the internal buffer

Referenced by makRadarFx::DtBigEndianStreamWriter::DtBigEndianStreamWriter(), DtStreamWriter(), and writeBytes().

◆ length()

virtual int makRadarFx::DtStreamWriter::length ( )
virtual

Gets the current write position as a length.

Returns
Number of bytes written to the buffer so far

Referenced by makRadarFx::DtBigEndianStreamWriter::DtBigEndianStreamWriter(), makRadarFx::DtBigEndianStreamWriter::DtBigEndianStreamWriter(), DtStreamWriter(), DtStreamWriter(), and writeBytes().

◆ writeBool()

virtual void makRadarFx::DtStreamWriter::writeBool ( bool b)
virtual

Writes a boolean value.

Parameters
bBoolean value to write

◆ writeInt8()

virtual void makRadarFx::DtStreamWriter::writeInt8 ( char num)
virtual

Writes an 8-bit signed integer.

Parameters
numValue to write

◆ writeUInt8()

virtual void makRadarFx::DtStreamWriter::writeUInt8 ( unsigned char num)
virtual

Writes an 8-bit unsigned integer.

Parameters
numValue to write

◆ writeInt16()

virtual void makRadarFx::DtStreamWriter::writeInt16 ( short num)
virtual

Writes a 16-bit signed integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeUInt16()

virtual void makRadarFx::DtStreamWriter::writeUInt16 ( unsigned short num)
virtual

Writes a 16-bit unsigned integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeInt32()

virtual void makRadarFx::DtStreamWriter::writeInt32 ( int num)
virtual

Writes a 32-bit signed integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeUInt32()

virtual void makRadarFx::DtStreamWriter::writeUInt32 ( unsigned int num)
virtual

Writes a 32-bit unsigned integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeInt64()

virtual void makRadarFx::DtStreamWriter::writeInt64 ( long long num)
virtual

Writes a 64-bit signed integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeUInt64()

virtual void makRadarFx::DtStreamWriter::writeUInt64 ( unsigned long long num)
virtual

Writes a 64-bit unsigned integer.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeSingle()

virtual void makRadarFx::DtStreamWriter::writeSingle ( float num)
virtual

Writes a 32-bit floating point value.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeDouble()

virtual void makRadarFx::DtStreamWriter::writeDouble ( double num)
virtual

Writes a 64-bit floating point value.

Parameters
numValue to write

Reimplemented in makRadarFx::DtBigEndianStreamWriter.

◆ writeString()

virtual void makRadarFx::DtStreamWriter::writeString ( std::string & str)
virtual

Writes a string.

Parameters
strString value to write

◆ writeVector()

virtual void makRadarFx::DtStreamWriter::writeVector ( DtVector & vec)
virtual

Writes a 3D vector.

Parameters
vecVector to write

◆ writeTaitBryan()

virtual void makRadarFx::DtStreamWriter::writeTaitBryan ( DtTaitBryan & tb)
virtual

Writes a Tait-Bryan angle set.

Parameters
tbTait-Bryan angles to write

◆ writeQuaternion()

virtual void makRadarFx::DtStreamWriter::writeQuaternion ( const DtQuaternion & q)
virtual

Writes a quaternion.

Parameters
qQuaternion to write

◆ writeEntityId()

virtual void makRadarFx::DtStreamWriter::writeEntityId ( const DtEntityIdentifier & id)
virtual

Writes an entity identifier.

Parameters
idEntity identifier to write

◆ writeEntityType()

virtual void makRadarFx::DtStreamWriter::writeEntityType ( const DtEntityType & type)
virtual

Writes an entity type.

Parameters
typeEntity type to write

◆ writeBytes()

virtual void makRadarFx::DtStreamWriter::writeBytes ( unsigned char * buffer,
int length )
virtual

Writes raw bytes.

Parameters
bufferPointer to the source buffer
lengthNumber of bytes to write

References buffer(), and length().

◆ encodeStringSize()

void makRadarFx::DtStreamWriter::encodeStringSize ( int size)
protected

Encodes the size of the string as a variable length integer.

Parameters
sizeSize to encode

Member Data Documentation

◆ myBuffer

unsigned char* makRadarFx::DtStreamWriter::myBuffer
protected

Pointer to the beginning of the buffer.

◆ myWriteHead

unsigned char* makRadarFx::DtStreamWriter::myWriteHead
protected

Current write position within the buffer.

◆ myLength

int makRadarFx::DtStreamWriter::myLength
protected

Total length of the buffer in bytes.

◆ myShouldDelete

bool makRadarFx::DtStreamWriter::myShouldDelete
protected

Flag indicating if the buffer should be deleted on destruction.


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