Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | List of all members
om::io::BinaryEncoder Class Reference

A class that handles encoding of standard types to binary data. More...

#include <omBinaryEncoder.h>

Inheritance diagram for om::io::BinaryEncoder:
om::io::DataOutputStream

Public Member Functions

 BinaryEncoder ()
 Create a new binary encoder that uses the native endianness for primitive types. More...
 
 BinaryEncoder (const BinaryEncoder &other)
 Create a copy of another binary encoder and its current state. More...
 
 ~BinaryEncoder ()
 Destroy a binary encoder and release its internal data. More...
 
BinaryEncoderoperator= (const BinaryEncoder &other)
 Assign the current state of one binary encoder to this one. More...
 
const BinaryFormatgetFormat () const
 Return a reference to the binary format this encoder is using. More...
 
void setFormat (const BinaryFormat &newFormat)
 Set the binary format this encoder is using. More...
 
DataOutputStreamgetStream () const
 Return a pointer to a data stream that is the destination of this encoder. More...
 
void setStream (DataOutputStream *newStream)
 Set a pointer to a data stream that is the destination of this encoder. More...
 
const UBytegetBufferData () const
 Return a pointer to the start of the data encoding buffer. More...
 
Size getBufferSize () const
 Return the number of bytes that have been written to the buffer. More...
 
Size getBufferCapacity () const
 Return the total capacity of the internal buffer. More...
 
Bool setBufferCapacity (Size newCapacity)
 Set the total capacity of the internal buffer. More...
 
void pad ()
 Pad the alignment of the write position to the next aligned object boundary. More...
 
void write (Bool value)
 Write a boolean and advance the position. More...
 
void write (Int8 value)
 Write a signed 8-bit and advance the position. More...
 
void write (UInt8 value)
 Write an unsigned 8-bit integer and advance the position. More...
 
void write (Int16 value)
 Write a signed 16-bit integer and advance the position. More...
 
void write (UInt16 value)
 Write an unsigned 16-bit integer and advance the position. More...
 
void write (Int32 value)
 Write a signed 32-bit integer and advance the position. More...
 
void write (UInt32 value)
 Write an unsigned 32-bit integer and advance the position. More...
 
void write (Int64 value)
 Write a signed 64-bit integer and advance the position. More...
 
void write (UInt64 value)
 Write an unsigned 64-bit integer and advance the position. More...
 
void write (Float32 value)
 Write a 32-bit float and advance the position. More...
 
void write (Float64 value)
 Write a 64-bit float and advance the position. More...
 
template<typename T >
void write (const math::Complex< T > &value)
 Write a complex number of the templated type and advance the position. More...
 
template<typename T >
void write (const math::VectorND< T, 2 > &value)
 Write a 2D vector of the templated type and advance the position. More...
 
template<typename T >
void write (const math::VectorND< T, 3 > &value)
 Write a 3D vector of the templated type and advance the position. More...
 
template<typename T >
void write (const math::VectorND< T, 4 > &value)
 Write a 4D vector of the templated type and advance the position. More...
 
template<typename T >
void write (const math::MatrixND< T, 2, 2 > &value)
 Write a 2x2 matrix of the templated type and advance the position. More...
 
template<typename T >
void write (const math::MatrixND< T, 3, 3 > &value)
 Write a 3x3 matrix of the templated type and advance the position. More...
 
template<typename T >
void write (const math::MatrixND< T, 4, 4 > &value)
 Write a 4x4 matrix of the templated type and advance the position. More...
 
template<typename T >
void write (const math::Transform3D< T > &value)
 Write a 3D transform of the templated type and advance the position. More...
 
template<typename T >
void write (const math::AABB1D< T > &value)
 Write a 1D range of the templated type and advance the position. More...
 
template<typename T >
void write (const math::AABB2D< T > &value)
 Write a 2D range of the templated type and advance the position. More...
 
template<typename T >
void write (const math::AABB3D< T > &value)
 Write a 3D range of the templated type and advance the position. More...
 
template<typename T >
void writeArray (const T *array, Size number)
 Write an array of values of the templated type and advance the data pointer. More...
 
void writeASCIIString (const data::String &string)
 Write an ASCII encoded string starting at the specified data pointer and return it and advance the position. More...
 
void writeUTF8String (const data::UTF8String &string)
 Write a UTF-8 encoded string starting at the specified data pointer and return it and advance the position. More...
 
void writeUTF16String (const data::UTF16String &string)
 Write a UTF-16 encoded string starting at the specified data pointer and return it and advance the position. More...
 
void writeUTF32String (const data::UTF32String &string)
 Write a UTF-32 encoded string starting at the specified data pointer and return it and advance the position. More...
 
Bool write (const UByte *newData, Size number)
 Write the specified number of bytes of data from the buffer to the stream. More...
 
virtual Size writeData (const UByte *newData, Size number)
 Write the specified number of bytes of data from the buffer to the stream. More...
 
virtual Bool canSeek () const
 Return whether or not this type of stream allows seeking. More...
 
virtual Bool canSeek (Int64 relativeOffset) const
 Return whether or not this stream can seek by the specified amount in bytes. More...
 
virtual Int64 seek (Int64 relativeOffset)
 Move the current position in the stream by the specified relative signed offset in bytes. More...
 
virtual void flush ()
 Flush buffered output to the stream if the encoder has a valid stream. More...
 
virtual LargeIndex getPosition () const
 Return the current write position of the encoder relative to the start of the output. More...
 
- Public Member Functions inherited from om::io::DataOutputStream
virtual ~DataOutputStream ()
 Destroy an output stream and free all of its resources (close it). More...
 
Size writeData (const data::Data &data)
 Write as much of the specified data array to the stream and return the number of bytes written. More...
 
Size writeData (const data::DataBuffer &dataBuffer)
 Write as much of the specified data array to the stream and return the number of bytes written. More...
 

Detailed Description

A class that handles encoding of standard types to binary data.

Constructor & Destructor Documentation

om::io::BinaryEncoder::BinaryEncoder ( )

Create a new binary encoder that uses the native endianness for primitive types.

om::io::BinaryEncoder::BinaryEncoder ( const BinaryEncoder other)

Create a copy of another binary encoder and its current state.

om::io::BinaryEncoder::~BinaryEncoder ( )

Destroy a binary encoder and release its internal data.

Member Function Documentation

BinaryEncoder& om::io::BinaryEncoder::operator= ( const BinaryEncoder other)

Assign the current state of one binary encoder to this one.

const BinaryFormat& om::io::BinaryEncoder::getFormat ( ) const
inline

Return a reference to the binary format this encoder is using.

void om::io::BinaryEncoder::setFormat ( const BinaryFormat newFormat)
inline

Set the binary format this encoder is using.

DataOutputStream* om::io::BinaryEncoder::getStream ( ) const
inline

Return a pointer to a data stream that is the destination of this encoder.

If the stream is NULL, the encoder keeps enlarging its internal buffer as necessary.

void om::io::BinaryEncoder::setStream ( DataOutputStream newStream)
inline

Set a pointer to a data stream that is the destination of this encoder.

If the stream is NULL, the encoder keeps enlarging its internal buffer as necessary.

const UByte* om::io::BinaryEncoder::getBufferData ( ) const
inline

Return a pointer to the start of the data encoding buffer.

Size om::io::BinaryEncoder::getBufferSize ( ) const
inline

Return the number of bytes that have been written to the buffer.

Size om::io::BinaryEncoder::getBufferCapacity ( ) const
inline

Return the total capacity of the internal buffer.

Bool om::io::BinaryEncoder::setBufferCapacity ( Size  newCapacity)

Set the total capacity of the internal buffer.

The method returns whether or not the capacity was successfully changed.

void om::io::BinaryEncoder::pad ( )
inline

Pad the alignment of the write position to the next aligned object boundary.

void om::io::BinaryEncoder::write ( Bool  value)
inline

Write a boolean and advance the position.

void om::io::BinaryEncoder::write ( Int8  value)
inline

Write a signed 8-bit and advance the position.

void om::io::BinaryEncoder::write ( UInt8  value)
inline

Write an unsigned 8-bit integer and advance the position.

void om::io::BinaryEncoder::write ( Int16  value)
inline

Write a signed 16-bit integer and advance the position.

void om::io::BinaryEncoder::write ( UInt16  value)
inline

Write an unsigned 16-bit integer and advance the position.

void om::io::BinaryEncoder::write ( Int32  value)
inline

Write a signed 32-bit integer and advance the position.

void om::io::BinaryEncoder::write ( UInt32  value)
inline

Write an unsigned 32-bit integer and advance the position.

void om::io::BinaryEncoder::write ( Int64  value)
inline

Write a signed 64-bit integer and advance the position.

void om::io::BinaryEncoder::write ( UInt64  value)
inline

Write an unsigned 64-bit integer and advance the position.

void om::io::BinaryEncoder::write ( Float32  value)
inline

Write a 32-bit float and advance the position.

void om::io::BinaryEncoder::write ( Float64  value)
inline

Write a 64-bit float and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::Complex< T > &  value)
inline

Write a complex number of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::VectorND< T, 2 > &  value)
inline

Write a 2D vector of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::VectorND< T, 3 > &  value)
inline

Write a 3D vector of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::VectorND< T, 4 > &  value)
inline

Write a 4D vector of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::MatrixND< T, 2, 2 > &  value)
inline

Write a 2x2 matrix of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::MatrixND< T, 3, 3 > &  value)
inline

Write a 3x3 matrix of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::MatrixND< T, 4, 4 > &  value)
inline

Write a 4x4 matrix of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::Transform3D< T > &  value)
inline

Write a 3D transform of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::AABB1D< T > &  value)
inline

Write a 1D range of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::AABB2D< T > &  value)
inline

Write a 2D range of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::write ( const math::AABB3D< T > &  value)
inline

Write a 3D range of the templated type and advance the position.

template<typename T >
void om::io::BinaryEncoder::writeArray ( const T *  array,
Size  number 
)
inline

Write an array of values of the templated type and advance the data pointer.

void om::io::BinaryEncoder::writeASCIIString ( const data::String string)

Write an ASCII encoded string starting at the specified data pointer and return it and advance the position.

void om::io::BinaryEncoder::writeUTF8String ( const data::UTF8String string)

Write a UTF-8 encoded string starting at the specified data pointer and return it and advance the position.

void om::io::BinaryEncoder::writeUTF16String ( const data::UTF16String string)

Write a UTF-16 encoded string starting at the specified data pointer and return it and advance the position.

void om::io::BinaryEncoder::writeUTF32String ( const data::UTF32String string)

Write a UTF-32 encoded string starting at the specified data pointer and return it and advance the position.

Bool om::io::BinaryEncoder::write ( const UByte newData,
Size  number 
)

Write the specified number of bytes of data from the buffer to the stream.

virtual Size om::io::BinaryEncoder::writeData ( const UByte newData,
Size  number 
)
virtual

Write the specified number of bytes of data from the buffer to the stream.

The method returns the number of bytes that were actually written.

Implements om::io::DataOutputStream.

virtual Bool om::io::BinaryEncoder::canSeek ( ) const
virtual

Return whether or not this type of stream allows seeking.

Implements om::io::DataOutputStream.

virtual Bool om::io::BinaryEncoder::canSeek ( Int64  relativeOffset) const
virtual

Return whether or not this stream can seek by the specified amount in bytes.

Implements om::io::DataOutputStream.

virtual Int64 om::io::BinaryEncoder::seek ( Int64  relativeOffset)
virtual

Move the current position in the stream by the specified relative signed offset in bytes.

Implements om::io::DataOutputStream.

virtual void om::io::BinaryEncoder::flush ( )
virtual

Flush buffered output to the stream if the encoder has a valid stream.

Implements om::io::DataOutputStream.

virtual LargeIndex om::io::BinaryEncoder::getPosition ( ) const
virtual

Return the current write position of the encoder relative to the start of the output.

Implements om::io::DataOutputStream.


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