Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
Assimp::StreamReader< SwapEndianess, RuntimeSwitch > Class Template Reference

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

#include <StreamReader.h>

Public Types

using diff = size_t
 
using pos = size_t
 

Public Member Functions

void CopyAndAdvance (void *out, size_t bytes)
 Copy n bytes to an external buffer. More...
 
template<typename T >
Get ()
 Generic read method. 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_t * GetPtr () const
 Get the current file pointer. More...
 
unsigned int GetReadLimit () const
 Get the current read limit in bytes. More...
 
size_t GetRemainingSize () const
 Get the remaining stream size (to the end of the stream) More...
 
size_t 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 (intptr_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 (IOStream *stream, bool le=false)
 
 StreamReader (std::shared_ptr< IOStream > stream, bool le=false)
 Construction from a given stream with a well-defined endianness. More...
 
 ~StreamReader ()
 

Detailed Description

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
class Assimp::StreamReader< SwapEndianess, RuntimeSwitch >

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

◆ diff

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
using Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::diff = size_t

◆ pos

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
using Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::pos = size_t

Constructor & Destructor Documentation

◆ StreamReader() [1/2]

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::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.

◆ StreamReader() [2/2]

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

◆ ~StreamReader()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::~StreamReader ( )
inline

Member Function Documentation

◆ CopyAndAdvance()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
void Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::CopyAndAdvance ( void *  out,
size_t  bytes 
)
inline

Copy n bytes to an external buffer.

Parameters
outDestination for copying
bytesNumber of bytes to copy

◆ Get()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
template<typename T >
T Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::Get ( )
inline

Generic read method.

ByteSwap::Swap(T*) must be defined

◆ GetCurrentPos()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetCurrentPos ( ) const
inline

Get the current offset from the beginning of the file.

◆ GetF4()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
float Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetF4 ( )
inline

Read a float from the stream.

◆ GetF8()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
double Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetF8 ( )
inline

Read a double from the stream.

◆ GetI1()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int8_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetI1 ( )
inline

Read a signed 8 bit integer from the stream.

◆ GetI2()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int16_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetI2 ( )
inline

Read a signed 16 bit integer from the stream.

◆ GetI4()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int32_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetI4 ( )
inline

Read an signed 32 bit integer from the stream.

◆ GetI8()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int64_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetI8 ( )
inline

Read a signed 64 bit integer from the stream.

◆ GetPtr()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
int8_t * Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetPtr ( ) const
inline

Get the current file pointer.

◆ GetReadLimit()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
unsigned int Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetReadLimit ( ) const
inline

Get the current read limit in bytes.

Reading over this limit accidentally raises an exception.

◆ GetRemainingSize()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
size_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetRemainingSize ( ) const
inline

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

◆ GetRemainingSizeToLimit()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
size_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::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.

◆ GetU1()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
uint8_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetU1 ( )
inline

Read a unsigned 8 bit integer from the stream.

◆ GetU2()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
uint16_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetU2 ( )
inline

Read a unsigned 16 bit integer from the stream.

◆ GetU4()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
uint32_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetU4 ( )
inline

Read an unsigned 32 bit integer from the stream.

◆ GetU8()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
uint64_t Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::GetU8 ( )
inline

Read a unsigned 64 bit integer from the stream.

◆ IncPtr()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
void Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::IncPtr ( intptr_t  plus)
inline

Increase the file pointer (relative seeking)

◆ operator>>()

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

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

◆ SetCurrentPos()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
void Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::SetCurrentPos ( size_t  pos)
inline

◆ SetPtr()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
void Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::SetPtr ( int8_t *  p)
inline

Set current file pointer (Get it from GetPtr).

This is if you prefer to do pointer arithmetic 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.

◆ SetReadLimit()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
unsigned int Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::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.

◆ SkipToReadLimit()

template<bool SwapEndianess = false, bool RuntimeSwitch = false>
void Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::SkipToReadLimit ( )
inline

Skip to the read limit in bytes.

Reading over this limit accidentally raises an exception.


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