Path Tracer
Public Types | Public Member Functions | List of all members
Assimp::StreamReader< SwapEndianess, RuntimeSwitch > Class Template Reference

#include <StreamReader.h>

Public Types

using diff = size_t
 
using pos = size_t
 

Public Member Functions

 StreamReader (std::shared_ptr< IOStream > stream, bool le=false)
 
 StreamReader (IOStream *stream, bool le=false)
 
float GetF4 ()
 Read a float from the stream.
 
double GetF8 ()
 Read a double from the stream.
 
int16_t GetI2 ()
 
int8_t GetI1 ()
 
int32_t GetI4 ()
 
int64_t GetI8 ()
 
uint16_t GetU2 ()
 
uint8_t GetU1 ()
 Read a unsigned 8 bit integer from the stream.
 
uint32_t GetU4 ()
 Read an unsigned 32 bit integer from the stream.
 
uint64_t GetU8 ()
 Read a unsigned 64 bit integer from the stream.
 
size_t GetRemainingSize () const
 Get the remaining stream size (to the end of the stream)
 
size_t GetRemainingSizeToLimit () const
 
void IncPtr (intptr_t plus)
 
int8_t * GetPtr () const
 
void SetPtr (int8_t *p)
 
void CopyAndAdvance (void *out, size_t bytes)
 
int GetCurrentPos () const
 Get the current offset from the beginning of the file.
 
void SetCurrentPos (size_t pos)
 
unsigned int SetReadLimit (unsigned int _limit)
 
unsigned int GetReadLimit () const
 
void SkipToReadLimit ()
 
template<typename T >
StreamReaderoperator>> (T &f)
 
template<typename T >
Get ()
 

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?

Constructor & Destructor Documentation

◆ StreamReader()

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.

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

◆ 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.

◆ 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.

◆ 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

◆ 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.

◆ 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 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.

◆ 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: