Nebula
Loading...
Searching...
No Matches
IO::BinaryReader Class Reference

#include <binaryreader.h>

Detailed Description

A friendly interface to read binary data from a stream.

Optionally the reader can use memory mapping for optimal read performance. Performs automatic byte order conversion if necessary.

Todo
convert endianess!

Inherits IO::StreamReader.

Public Member Functions

 BinaryReader ()
 constructor
virtual ~BinaryReader ()
 destructor
void SetMemoryMappingEnabled (bool b)
 call before Open() to enable memory mapping (if stream supports mapping)
bool IsMemoryMappingEnabled () const
 return true if memory mapping is enabled
void SetStreamByteOrder (System::ByteOrder::Type byteOrder)
 set the stream byte order (default is host byte order)
System::ByteOrder::Type GetStreamByteOrder () const
 get the stream byte order
virtual bool Open ()
 begin reading from the stream
virtual void Close ()
 end reading from the stream
char ReadChar ()
 read an 8-bit char from the stream
unsigned char ReadUChar ()
 read an 8-bit unsigned character from the stream
short ReadShort ()
 read a 16-bit short from the stream
unsigned short ReadUShort ()
 read a 16-bit unsigned short from the stream
int ReadInt ()
 read a 32-bit int from the stream
unsigned int ReadUInt ()
 read a 32-bit unsigned int from the stream
long long ReadInt64 ()
 read a 64-bit int from the stream
unsigned long long ReadUInt64 ()
 read a 64-bit unsigned int from the stream
float ReadFloat ()
 read a float value from the stream
float ReadFloatFromNormalizedUByte2 ()
 read a compressed float value from the stream, lossy and needed to be in the range of -1.0 and +1.0
float ReadFloatFromUnsignedNormalizedUByte2 ()
 read a compressed float value from the stream, lossy and needed to be in the range of 0.0 and +1.0
double ReadDouble ()
 read a double value from the stream
bool ReadBool ()
 read a bool value from the stream
Util::String ReadString ()
 read a string from the stream
Math::vec2 ReadFloat2 ()
 read a vec2 from the stream
Math::vec3 ReadVec3 ()
 read a vector from the stream, (x,y,z,0.0)
Math::vec4 ReadVec4 ()
 read a vec4 from the stream
Math::mat4 ReadMat4 ()
 read a mat4 from the stream
Util::Array< float > ReadFloatArray ()
 read a float array from the stream
Util::Array< int > ReadIntArray ()
 read an int array from the stream
Util::Array< uintReadUIntArray ()
 read an int array from the stream
Util::Array< bool > ReadBoolArray ()
 read a bool array from the stream
Util::Guid ReadGuid ()
 read a guid
Util::Blob ReadBlob ()
 read a blob of data
void ReadRawData (void *ptr, SizeT numBytes)
 read raw data
Public Member Functions inherited from IO::StreamReader
 StreamReader ()
 constructor
virtual ~StreamReader ()
 destructor
void SetStream (const Ptr< Stream > &s)
 set stream to read from
const Ptr< Stream > & GetStream () const
 get currently set stream
bool HasStream () const
 return true if a stream is set
bool Eof () const
 return true if the stream has reached EOF
bool IsOpen () const
 return true if currently open
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Public Attributes

System::ByteOrder byteOrder
unsigned char * mapCursor
unsigned char * mapEnd
bool enableMapping
bool isMapped

Private Member Functions

 __DeclareClass (BinaryReader)

Additional Inherited Members

Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
Protected Attributes inherited from IO::StreamReader
Ptr< Streamstream
bool isOpen
bool streamWasOpen

Constructor & Destructor Documentation

◆ BinaryReader()

IO::BinaryReader::BinaryReader ( )

constructor

◆ ~BinaryReader()

IO::BinaryReader::~BinaryReader ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

IO::BinaryReader::__DeclareClass ( BinaryReader )
private

◆ Close()

void IO::BinaryReader::Close ( )
virtual

end reading from the stream

Reimplemented from IO::StreamReader.

◆ GetStreamByteOrder()

System::ByteOrder::Type IO::BinaryReader::GetStreamByteOrder ( ) const
inline

get the stream byte order

◆ IsMemoryMappingEnabled()

bool IO::BinaryReader::IsMemoryMappingEnabled ( ) const
inline

return true if memory mapping is enabled

◆ Open()

bool IO::BinaryReader::Open ( )
virtual

begin reading from the stream

Reimplemented from IO::StreamReader.

◆ ReadBlob()

Util::Blob IO::BinaryReader::ReadBlob ( )

read a blob of data

◆ ReadBool()

bool IO::BinaryReader::ReadBool ( )

read a bool value from the stream

◆ ReadBoolArray()

Util::Array< bool > IO::BinaryReader::ReadBoolArray ( )

read a bool array from the stream

◆ ReadChar()

char IO::BinaryReader::ReadChar ( )

read an 8-bit char from the stream

◆ ReadDouble()

double IO::BinaryReader::ReadDouble ( )

read a double value from the stream

◆ ReadFloat()

float IO::BinaryReader::ReadFloat ( )

read a float value from the stream

◆ ReadFloat2()

Math::vec2 IO::BinaryReader::ReadFloat2 ( )

read a vec2 from the stream

◆ ReadFloatArray()

Util::Array< float > IO::BinaryReader::ReadFloatArray ( )

read a float array from the stream

◆ ReadFloatFromNormalizedUByte2()

float IO::BinaryReader::ReadFloatFromNormalizedUByte2 ( )

read a compressed float value from the stream, lossy and needed to be in the range of -1.0 and +1.0

◆ ReadFloatFromUnsignedNormalizedUByte2()

float IO::BinaryReader::ReadFloatFromUnsignedNormalizedUByte2 ( )

read a compressed float value from the stream, lossy and needed to be in the range of 0.0 and +1.0

◆ ReadGuid()

Util::Guid IO::BinaryReader::ReadGuid ( )

read a guid

◆ ReadInt()

int IO::BinaryReader::ReadInt ( )

read a 32-bit int from the stream

◆ ReadInt64()

long long IO::BinaryReader::ReadInt64 ( )

read a 64-bit int from the stream

◆ ReadIntArray()

Util::Array< int > IO::BinaryReader::ReadIntArray ( )

read an int array from the stream

◆ ReadMat4()

Math::mat4 IO::BinaryReader::ReadMat4 ( )

read a mat4 from the stream

◆ ReadRawData()

void IO::BinaryReader::ReadRawData ( void * ptr,
SizeT numBytes )

read raw data

◆ ReadShort()

short IO::BinaryReader::ReadShort ( )

read a 16-bit short from the stream

◆ ReadString()

Util::String IO::BinaryReader::ReadString ( )

read a string from the stream

◆ ReadUChar()

unsigned char IO::BinaryReader::ReadUChar ( )

read an 8-bit unsigned character from the stream

◆ ReadUInt()

unsigned int IO::BinaryReader::ReadUInt ( )

read a 32-bit unsigned int from the stream

◆ ReadUInt64()

unsigned long long IO::BinaryReader::ReadUInt64 ( )

read a 64-bit unsigned int from the stream

◆ ReadUIntArray()

Util::Array< uint > IO::BinaryReader::ReadUIntArray ( )

read an int array from the stream

◆ ReadUShort()

unsigned short IO::BinaryReader::ReadUShort ( )

read a 16-bit unsigned short from the stream

◆ ReadVec3()

Math::vec3 IO::BinaryReader::ReadVec3 ( )

read a vector from the stream, (x,y,z,0.0)

◆ ReadVec4()

Math::vec4 IO::BinaryReader::ReadVec4 ( )

read a vec4 from the stream

◆ SetMemoryMappingEnabled()

void IO::BinaryReader::SetMemoryMappingEnabled ( bool b)
inline

call before Open() to enable memory mapping (if stream supports mapping)

◆ SetStreamByteOrder()

void IO::BinaryReader::SetStreamByteOrder ( System::ByteOrder::Type byteOrder)
inline

set the stream byte order (default is host byte order)

Member Data Documentation

◆ byteOrder

System::ByteOrder IO::BinaryReader::byteOrder

◆ enableMapping

bool IO::BinaryReader::enableMapping

◆ isMapped

bool IO::BinaryReader::isMapped

◆ mapCursor

unsigned char* IO::BinaryReader::mapCursor

◆ mapEnd

unsigned char* IO::BinaryReader::mapEnd

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