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

Detailed Description

This class provides methods for writing various data types to a byte stream, maintaining the current write position, and handling platform-specific byte ordering.

#include <byteStream.h>

Public Member Functions

 DtStreamWriter (int length=0)
 
 DtStreamWriter (char *buffer, int length)
 
virtual ~DtStreamWriter ()
 
Buffer Access

Methods to access the internal buffer

char * buffer ()
 
int length ()
 

Value Writers

Methods to write values to the byte stream

These methods write a value and increment the current position in the byte stream based on the size of the value written.

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

Constructor & Destructor Documentation

◆ DtStreamWriter() [1/2]

makVre::DtStreamWriter::DtStreamWriter ( int length = 0)

Constructor that creates an internal buffer.

Parameters
lengthSize of internal buffer to create (in bytes)
Note
Care must be taken to allocate enough space

References length().

◆ DtStreamWriter() [2/2]

makVre::DtStreamWriter::DtStreamWriter ( char * buffer,
int length )

Constructor that uses an existing buffer.

Parameters
bufferPointer to the buffer to write to
lengthLength of the buffer in bytes
Note
Care must be taken to ensure the buffer has enough space

References buffer(), and length().

◆ ~DtStreamWriter()

virtual makVre::DtStreamWriter::~DtStreamWriter ( )
virtual

Virtual destructor.

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

Member Function Documentation

◆ buffer()

char * makVre::DtStreamWriter::buffer ( )

Gets a pointer to the internal buffer.

Returns
Pointer to the buffer

Referenced by DtStreamWriter().

◆ length()

int makVre::DtStreamWriter::length ( )

Gets the current length of data in the buffer.

Returns
Current length in bytes

Referenced by DtStreamWriter(), DtStreamWriter(), and writeBytes().

◆ writeBool()

void makVre::DtStreamWriter::writeBool ( bool b)

Writes a boolean value.

Parameters
bThe boolean value to write

◆ writeInt8()

void makVre::DtStreamWriter::writeInt8 ( char num)

Writes a signed 8-bit integer.

Parameters
numThe signed 8-bit integer to write

◆ writeUInt8()

void makVre::DtStreamWriter::writeUInt8 ( unsigned char num)

Writes an unsigned 8-bit integer.

Parameters
numThe unsigned 8-bit integer to write

◆ writeInt16()

void makVre::DtStreamWriter::writeInt16 ( short num)

Writes a signed 16-bit integer.

Parameters
numThe signed 16-bit integer to write

◆ writeUInt16()

void makVre::DtStreamWriter::writeUInt16 ( unsigned short num)

Writes an unsigned 16-bit integer.

Parameters
numThe unsigned 16-bit integer to write

◆ writeInt32()

void makVre::DtStreamWriter::writeInt32 ( int num)

Writes a signed 32-bit integer.

Parameters
numThe signed 32-bit integer to write

◆ writeUInt32()

void makVre::DtStreamWriter::writeUInt32 ( unsigned int num)

Writes an unsigned 32-bit integer.

Parameters
numThe unsigned 32-bit integer to write

◆ writeInt64()

void makVre::DtStreamWriter::writeInt64 ( Int64 num)

Writes a signed 64-bit integer.

Parameters
numThe signed 64-bit integer to write

◆ writeUInt64()

void makVre::DtStreamWriter::writeUInt64 ( UInt64 num)

Writes an unsigned 64-bit integer.

Parameters
numThe unsigned 64-bit integer to write

◆ writeSingle()

void makVre::DtStreamWriter::writeSingle ( float num)

Writes a 32-bit floating point value.

Parameters
numThe 32-bit float to write

◆ writeDouble()

void makVre::DtStreamWriter::writeDouble ( double num)

Writes a 64-bit floating point value.

Parameters
numThe 64-bit double to write

◆ writeString()

void makVre::DtStreamWriter::writeString ( const std::string & str)

Writes a string value.

Parameters
strThe string to write

◆ writeVector()

void makVre::DtStreamWriter::writeVector ( const DtVector & vec)

Writes a 3D vector.

Parameters
vecThe vector to write

◆ writeTaitBryan()

void makVre::DtStreamWriter::writeTaitBryan ( const DtTaitBryan & tb)

Writes a Tait-Bryan angles representation.

Parameters
tbThe Tait-Bryan angles to write

◆ writeQuaternion()

void makVre::DtStreamWriter::writeQuaternion ( const DtQuaternion & q)

Writes a quaternion.

Parameters
qThe quaternion to write

◆ writeEntityId()

void makVre::DtStreamWriter::writeEntityId ( const DtEntityIdentifier & id)

Writes an entity identifier.

Parameters
idThe entity identifier to write

◆ writeSimulationAddress()

void makVre::DtStreamWriter::writeSimulationAddress ( const DtSimulationAddress & addr)

Writes a simulation address.

Parameters
addrThe simulation address to write

◆ writeEntityType()

void makVre::DtStreamWriter::writeEntityType ( const DtEntityType & type)

Writes an entity type.

Parameters
typeThe entity type to write

◆ writeBytes()

void makVre::DtStreamWriter::writeBytes ( char * bytes,
int length )

Writes a byte array.

Parameters
bytesPointer to the bytes to write
lengthNumber of bytes to write

References length().

◆ encodeStringSize()

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

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

Parameters
sizeThe size to encode

Member Data Documentation

◆ myBuffer

char* makVre::DtStreamWriter::myBuffer
protected

Pointer to the buffer being written to.

◆ myWriteHead

char* makVre::DtStreamWriter::myWriteHead
protected

Current position in the buffer.

◆ myLength

int makVre::DtStreamWriter::myLength
protected

Total length of the buffer.

◆ myShouldDelete

bool makVre::DtStreamWriter::myShouldDelete
protected

Flag indicating if the buffer should be deleted on destruction.


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