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

A class that handles decoding of standard types from binary data. More...

#include <omResourceDecoder.h>

Inheritance diagram for om::resources::ResourceDecoder:
om::io::DataInputStream

Public Member Functions

const ResourceIDgetFileID () const
 Return the resource ID of the resource set file that is being decoded. More...
 
void setFileID (const ResourceID &newFileID)
 Set the resource ID of the resource set file that is being decoded. More...
 
const io::BinaryFormatgetFormat () const
 Return a reference to the binary format this decoder is using. More...
 
void setFormat (const io::BinaryFormat &newFormat)
 Set the binary format this decoder is using. More...
 
Size getDataSize () const
 Return the total size of the decoder's data source in bytes. More...
 
void setData (const UByte *newData, Size dataSizeInBytes)
 Set a pointer to an external data source that should be read with this decoder. More...
 
void pad (const UByte *&data)
 Pad the alignment of the specified pointer to the next aligned object boundary. More...
 
template<typename T >
Bool read (T &value)
 Read a value of the templated type into the output value parameter and advance the pointer. More...
 
template<typename T >
void readArray (T *array, Size number)
 Read an array of values of the templated type and advance the data pointer. More...
 
void readReference (ResourceReferencePatcher &references, Index userType=0, Index userID=0, void *userData=((void *) 0))
 Read a resource reference for the specified pointer to a concrete template resource type. More...
 
void readOpaqueReference (ResourceReferencePatcher &references, Index userType=0, Index userID=0, void *userData=((void *) 0))
 Read an opaque resource reference for the specified pointer to a concrete template resource type. More...
 
data::String readASCIIString ()
 Read an ASCII encoded string starting at the specified data pointer and return it and advance the pointer. More...
 
data::UTF8String readUTF8String ()
 Read a UTF-8 encoded string starting at the specified data pointer and return it and advance the pointer. More...
 
data::UTF16String readUTF16String ()
 Read a UTF-16 encoded string starting at the specified data pointer and return it and advance the pointer. More...
 
data::UTF32String readUTF32String ()
 Read a UTF-32 encoded string starting at the specified data pointer and return it and advance the pointer. More...
 
Bool read (UByte *newData, Size number)
 Read the specified number of bytes of data into the buffer. More...
 
virtual Size readData (UByte *buffer, Size number)
 Read the specified number of bytes from the stream and place them in the buffer given by a pointer. 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 LargeSize getBytesRemaining () const
 Return the number of bytes remaining in the stream. More...
 
virtual LargeIndex getPosition () const
 Return the current byte index within the stream relative to the beginning. More...
 
Shared< DataInputStreamduplicate () const
 Construct and return a copy of this resource decoder in same state as this one. More...
 
- Public Member Functions inherited from om::io::DataInputStream
virtual ~DataInputStream ()
 Destroy an input stream and free all of it's resources (close it). More...
 
Size readData (data::DataBuffer &buffer, Size numBytes)
 Read the specified number of bytes from the stream and place them in the specified data buffer. More...
 
data::Data readAllData ()
 Read as many bytes from the stream as possible and return them in a Data object. More...
 
Size readAllData (data::DataBuffer &buffer)
 Read as many bytes from the stream as possible and place them in the specified data buffer. More...
 
Bool hasBytesRemaining () const
 Return whether or not there are bytes remaining in the stream. More...
 

Detailed Description

A class that handles decoding of standard types from binary data.

Member Function Documentation

const ResourceID& om::resources::ResourceDecoder::getFileID ( ) const
inline

Return the resource ID of the resource set file that is being decoded.

void om::resources::ResourceDecoder::setFileID ( const ResourceID newFileID)
inline

Set the resource ID of the resource set file that is being decoded.

const io::BinaryFormat& om::resources::ResourceDecoder::getFormat ( ) const
inline

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

void om::resources::ResourceDecoder::setFormat ( const io::BinaryFormat newFormat)
inline

Set the binary format this decoder is using.

Size om::resources::ResourceDecoder::getDataSize ( ) const
inline

Return the total size of the decoder's data source in bytes.

void om::resources::ResourceDecoder::setData ( const UByte newData,
Size  dataSizeInBytes 
)
inline

Set a pointer to an external data source that should be read with this decoder.

This function prepares the decoder for reading from an external data source. When the decoder reaches the end of the data, it cannot read any further.

void om::resources::ResourceDecoder::pad ( const UByte *&  data)
inline

Pad the alignment of the specified pointer to the next aligned object boundary.

template<typename T >
Bool om::resources::ResourceDecoder::read ( T &  value)
inline

Read a value of the templated type into the output value parameter and advance the pointer.

template<typename T >
void om::resources::ResourceDecoder::readArray ( T *  array,
Size  number 
)
inline

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

void om::resources::ResourceDecoder::readReference ( ResourceReferencePatcher references,
Index  userType = 0,
Index  userID = 0,
void *  userData = ((void *)0) 
)
inline

Read a resource reference for the specified pointer to a concrete template resource type.

void om::resources::ResourceDecoder::readOpaqueReference ( ResourceReferencePatcher references,
Index  userType = 0,
Index  userID = 0,
void *  userData = ((void *)0) 
)
inline

Read an opaque resource reference for the specified pointer to a concrete template resource type.

data::String om::resources::ResourceDecoder::readASCIIString ( )
inline

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

data::UTF8String om::resources::ResourceDecoder::readUTF8String ( )
inline

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

data::UTF16String om::resources::ResourceDecoder::readUTF16String ( )
inline

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

data::UTF32String om::resources::ResourceDecoder::readUTF32String ( )
inline

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

Bool om::resources::ResourceDecoder::read ( UByte newData,
Size  number 
)
inline

Read the specified number of bytes of data into the buffer.

virtual Size om::resources::ResourceDecoder::readData ( UByte buffer,
Size  number 
)
inlinevirtual

Read the specified number of bytes from the stream and place them in the buffer given by a pointer.

Implements om::io::DataInputStream.

virtual Bool om::resources::ResourceDecoder::canSeek ( ) const
inlinevirtual

Return whether or not this type of stream allows seeking.

Implements om::io::DataInputStream.

virtual Bool om::resources::ResourceDecoder::canSeek ( Int64  relativeOffset) const
inlinevirtual

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

Implements om::io::DataInputStream.

virtual Int64 om::resources::ResourceDecoder::seek ( Int64  relativeOffset)
inlinevirtual

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

Implements om::io::DataInputStream.

virtual LargeSize om::resources::ResourceDecoder::getBytesRemaining ( ) const
inlinevirtual

Return the number of bytes remaining in the stream.

Implements om::io::DataInputStream.

virtual LargeIndex om::resources::ResourceDecoder::getPosition ( ) const
inlinevirtual

Return the current byte index within the stream relative to the beginning.

Implements om::io::DataInputStream.

Shared<DataInputStream> om::resources::ResourceDecoder::duplicate ( ) const

Construct and return a copy of this resource decoder in same state as this one.

This is used to create persistent decoders that can be used to stream resources into memory on demand.


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