Assimp v5.2.2 (January 2022)
The Asset-Importer-Lib API documentation.
|
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 > | |
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 > | |
StreamReader & | operator>> (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 () | |
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?
using Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::diff = size_t |
using Assimp::StreamReader< SwapEndianess, RuntimeSwitch >::pos = size_t |
|
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.
stream | Input 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. |
le | If 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. |
|
inline |
|
inline |
|
inline |
Copy n bytes to an external buffer.
out | Destination for copying |
bytes | Number of bytes to copy |
|
inline |
Generic read method.
ByteSwap::Swap(T*) must be defined
|
inline |
Get the current offset from the beginning of the file.
|
inline |
Read a float from the stream.
|
inline |
Read a double from the stream.
|
inline |
Read a signed 8 bit integer from the stream.
|
inline |
Read a signed 16 bit integer from the stream.
|
inline |
Read an signed 32 bit integer from the stream.
|
inline |
Read a signed 64 bit integer from the stream.
|
inline |
Get the current file pointer.
|
inline |
Get the current read limit in bytes.
Reading over this limit accidentally raises an exception.
|
inline |
Get the remaining stream size (to the end of the stream)
|
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.
|
inline |
Read a unsigned 8 bit integer from the stream.
|
inline |
Read a unsigned 16 bit integer from the stream.
|
inline |
Read an unsigned 32 bit integer from the stream.
|
inline |
Read a unsigned 64 bit integer from the stream.
|
inline |
Increase the file pointer (relative seeking)
|
inline |
overload operator>> and allow chaining of >> ops.
|
inline |
|
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.
p | The new pointer, which is validated against the size limit and buffer boundaries. |
|
inline |
Setup a temporary read limit.
limit | Maximum 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. |
|
inline |
Skip to the read limit in bytes.
Reading over this limit accidentally raises an exception.