Assimp  v3.1.1 (June 2014)
Assimp::StreamReader< bool, bool > Class Template Reference

Wrapper class around IOStream to allow for consistent reading of binary data in both little and big endian format. More...

Public Types

typedef int diff
 
typedef unsigned int pos
 

Public Member Functions

void CopyAndAdvance (void *out, size_t bytes)
 Copy n bytes to an external buffer. More...
 
int GetCurrentPos () const
 Get the current offset from the beginning of the file. More...
 
float GetF4 ()
 Read a float from the stream. More...
 
double GetF8 ()
 Read a double from the stream. More...
 
int8_t GetI1 ()
 Read a signed 8 bit integer from the stream. More...
 
int16_t GetI2 ()
 Read a signed 16 bit integer from the stream. More...
 
int32_t GetI4 ()
 Read an signed 32 bit integer from the stream. More...
 
int64_t GetI8 ()
 Read a signed 64 bit integer from the stream. More...
 
int8_tGetPtr () const
 Get the current file pointer. More...
 
unsigned int GetReadLimit () const
 Get the current read limit in bytes. More...
 
unsigned int GetRemainingSize () const
 Get the remaining stream size (to the end of the srream) More...
 
unsigned int GetRemainingSizeToLimit () const
 Get the remaining stream size (to the current read limit). More...
 
uint8_t GetU1 ()
 Read a unsigned 8 bit integer from the stream. More...
 
uint16_t GetU2 ()
 Read a unsigned 16 bit integer from the stream. More...
 
uint32_t GetU4 ()
 Read an unsigned 32 bit integer from the stream. More...
 
uint64_t GetU8 ()
 Read a unsigned 64 bit integer from the stream. More...
 
void IncPtr (size_t plus)
 Increase the file pointer (relative seeking) More...
 
template<typename T >
StreamReaderoperator>> (T &f)
 overload operator>> and allow chaining of >> ops. More...
 
void SetCurrentPos (size_t pos)
 
void SetPtr (int8_t *p)
 Set current file pointer (Get it from GetPtr). More...
 
unsigned int SetReadLimit (unsigned int _limit)
 Setup a temporary read limit. More...
 
void SkipToReadLimit ()
 Skip to the read limit in bytes. More...
 
 StreamReader (std::shared_ptr< IOStream > stream, bool le=false)
 Construction from a given stream with a well-defined endianness. More...
 
 StreamReader (IOStream *stream, bool le=false)
 
 ~StreamReader ()
 

Detailed Description

template<bool, bool>
class Assimp::StreamReader< bool, bool >

Wrapper class around IOStream to allow for consistent reading of binary data in both little and big endian format.

Don't attempt to instance the template directly. Use StreamReaderLE to read from a little-endian stream and StreamReaderBE to read from a BE stream. The class expects that the endianness of any input data is known at compile-time, which should usually be true (#BaseImporter::ConvertToUTF8 implements runtime endianness conversions for text files).

XXX switch from unsigned int for size types to size_t? or ptrdiff_t?

Member Typedef Documentation

template<bool , bool >
typedef int Assimp::StreamReader< bool, bool >::diff
template<bool , bool >
typedef unsigned int Assimp::StreamReader< bool, bool >::pos

Constructor & Destructor Documentation

template<bool , bool >
Assimp::StreamReader< bool, bool >::StreamReader ( std::shared_ptr< IOStream stream,
bool  le = false 
)
inline

Construction from a given stream with a well-defined endianness.

The StreamReader holds a permanent strong reference to the stream, which is released upon destruction.

Parameters
streamInput stream. The stream is not restarted if its file pointer is not at 0. Instead, the stream reader reads from the current position to the end of the stream.
leIf RuntimeSwitch is true: specifies whether the stream is in little endian byte order. Otherwise the endianness information is contained in the SwapEndianess template parameter and this parameter is meaningless.
template<bool , bool >
Assimp::StreamReader< bool, bool >::StreamReader ( IOStream stream,
bool  le = false 
)
inline
template<bool , bool >
Assimp::StreamReader< bool, bool >::~StreamReader ( )
inline

Member Function Documentation

template<bool , bool >
void Assimp::StreamReader< bool, bool >::CopyAndAdvance ( void out,
size_t  bytes 
)
inline

Copy n bytes to an external buffer.

Parameters
outDestination for copying
bytesNumber of bytes to copy
template<bool , bool >
int Assimp::StreamReader< bool, bool >::GetCurrentPos ( ) const
inline

Get the current offset from the beginning of the file.

template<bool , bool >
float Assimp::StreamReader< bool, bool >::GetF4 ( )
inline

Read a float from the stream.

template<bool , bool >
double Assimp::StreamReader< bool, bool >::GetF8 ( )
inline

Read a double from the stream.

template<bool , bool >
int8_t Assimp::StreamReader< bool, bool >::GetI1 ( )
inline

Read a signed 8 bit integer from the stream.

template<bool , bool >
int16_t Assimp::StreamReader< bool, bool >::GetI2 ( )
inline

Read a signed 16 bit integer from the stream.

template<bool , bool >
int32_t Assimp::StreamReader< bool, bool >::GetI4 ( )
inline

Read an signed 32 bit integer from the stream.

template<bool , bool >
int64_t Assimp::StreamReader< bool, bool >::GetI8 ( )
inline

Read a signed 64 bit integer from the stream.

template<bool , bool >
int8_t* Assimp::StreamReader< bool, bool >::GetPtr ( ) const
inline

Get the current file pointer.

template<bool , bool >
unsigned int Assimp::StreamReader< bool, bool >::GetReadLimit ( ) const
inline

Get the current read limit in bytes.

Reading over this limit accidentially raises an exception.

template<bool , bool >
unsigned int Assimp::StreamReader< bool, bool >::GetRemainingSize ( ) const
inline

Get the remaining stream size (to the end of the srream)

template<bool , bool >
unsigned int Assimp::StreamReader< bool, bool >::GetRemainingSizeToLimit ( ) const
inline

Get the remaining stream size (to the current read limit).

The return value is the remaining size of the stream if no custom read limit has been set.

template<bool , bool >
uint8_t Assimp::StreamReader< bool, bool >::GetU1 ( )
inline

Read a unsigned 8 bit integer from the stream.

template<bool , bool >
uint16_t Assimp::StreamReader< bool, bool >::GetU2 ( )
inline

Read a unsigned 16 bit integer from the stream.

template<bool , bool >
uint32_t Assimp::StreamReader< bool, bool >::GetU4 ( )
inline

Read an unsigned 32 bit integer from the stream.

template<bool , bool >
uint64_t Assimp::StreamReader< bool, bool >::GetU8 ( )
inline

Read a unsigned 64 bit integer from the stream.

template<bool , bool >
void Assimp::StreamReader< bool, bool >::IncPtr ( size_t  plus)
inline

Increase the file pointer (relative seeking)

template<bool , bool >
template<typename T >
StreamReader& Assimp::StreamReader< bool, bool >::operator>> ( T &  f)
inline

overload operator>> and allow chaining of >> ops.

template<bool , bool >
void Assimp::StreamReader< bool, bool >::SetCurrentPos ( size_t  pos)
inline
template<bool , bool >
void Assimp::StreamReader< bool, bool >::SetPtr ( int8_t p)
inline

Set current file pointer (Get it from GetPtr).

This is if you prefer to do pointer arithmetics on your own or want to copy large chunks of data at once.

Parameters
pThe new pointer, which is validated against the size limit and buffer boundaries.
template<bool , bool >
unsigned int Assimp::StreamReader< bool, bool >::SetReadLimit ( unsigned int  _limit)
inline

Setup a temporary read limit.

Parameters
limitMaximum number of bytes to be read from the beginning of the file. Specifying UINT_MAX resets the limit to the original end of the stream. Returns the previously set limit.
template<bool , bool >
void Assimp::StreamReader< bool, bool >::SkipToReadLimit ( )
inline

Skip to the read limit in bytes.

Reading over this limit accidentially raises an exception.


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