Athena IO Library
athena::io::FileReader Class Reference
Inheritance diagram for athena::io::FileReader:
Inheritance graph
Collaboration diagram for athena::io::FileReader:
Collaboration graph

Public Member Functions

 FileReader (const std::string &filename, atInt32 cacheSize=(32 *1024), bool globalErr=true)
 
 FileReader (const std::wstring &filename, atInt32 cacheSize=(32 *1024), bool globalErr=true)
 
std::string filename () const
 
std::wstring wfilename () const
 
void open ()
 
void close ()
 
bool isOpen () const
 
bool save ()
 
void seek (atInt64 pos, SeekOrigin origin=SeekOrigin::Current)
 Sets the buffers position relative to the specified position.
It seeks relative to the current position by default. More...
 
atUint64 position () const
 Returns the current position in the stream. More...
 
atUint64 length () const
 Returns the length of the file. More...
 
atUint64 readUBytesToBuf (void *buf, atUint64 len)
 Attempts to read a fixed length of data into a pre-allocated buffer, this function is client defined and must be implemented. More...
 
void setCacheSize (const atInt32 blockSize)
 
FILE * _fileHandle ()
 
- Public Member Functions inherited from athena::io::IStreamReader
void seekAlign64 ()
 Sets the buffer's position relative to the next 64-byte aligned position.

 
void seekAlign32 ()
 Sets the buffers position relative to the next 32-byte aligned position.

 
void seekAlign16 ()
 Sets the buffer's position relative to the next 16-byte aligned position.

 
bool atEnd () const
 Returns whether or not the stream is at the end. More...
 
atInt8 readByte ()
 Reads a byte at the current position and advances the current position. More...
 
template<class T >
atInt8 readVal (typename std::enable_if< std::is_same< T, atInt8 >::value >::type *=0)
 
template<class T >
atInt8 readValLittle (typename std::enable_if< std::is_same< T, atInt8 >::value >::type *=0)
 
template<class T >
atInt8 readValBig (typename std::enable_if< std::is_same< T, atInt8 >::value >::type *=0)
 
atUint8 readUByte ()
 Reads a byte at the current position and advances the current position. More...
 
template<class T >
atUint8 readVal (typename std::enable_if< std::is_same< T, atUint8 >::value >::type *=0)
 
template<class T >
atUint8 readValLittle (typename std::enable_if< std::is_same< T, atUint8 >::value >::type *=0)
 
template<class T >
atUint8 readValBig (typename std::enable_if< std::is_same< T, atUint8 >::value >::type *=0)
 
std::unique_ptr< atInt8[]> readBytes (atUint64 length)
 Reads a byte at the current position and advances the current position. More...
 
std::unique_ptr< atUint8[]> readUBytes (atUint64 length)
 Reads a byte at the current position and advances the current position. More...
 
atUint64 readBytesToBuf (void *buf, atUint64 len)
 Attempts to read a fixed length of data into a pre-allocated buffer. More...
 
atInt16 readInt16 ()
 Reads a Int16 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atInt16 readVal (typename std::enable_if< std::is_same< T, atInt16 >::value >::type *=0)
 
atInt16 readInt16Little ()
 Reads a Int16 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atInt16 readValLittle (typename std::enable_if< std::is_same< T, atInt16 >::value >::type *=0)
 
atInt16 readInt16Big ()
 Reads a Int16 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atInt16 readValBig (typename std::enable_if< std::is_same< T, atInt16 >::value >::type *=0)
 
atUint16 readUint16 ()
 Reads a Uint16 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atUint16 readVal (typename std::enable_if< std::is_same< T, atUint16 >::value >::type *=0)
 
atUint16 readUint16Little ()
 Reads a Uint16 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atUint16 readValLittle (typename std::enable_if< std::is_same< T, atUint16 >::value >::type *=0)
 
atUint16 readUint16Big ()
 Reads a Uint16 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atUint16 readValBig (typename std::enable_if< std::is_same< T, atUint16 >::value >::type *=0)
 
atInt32 readInt32 ()
 Reads a Int32 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atInt32 readVal (typename std::enable_if< std::is_same< T, atInt32 >::value >::type *=0)
 
atInt32 readInt32Little ()
 Reads a Int32 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atInt32 readValLittle (typename std::enable_if< std::is_same< T, atInt32 >::value >::type *=0)
 
atInt32 readInt32Big ()
 Reads a Int32 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atInt32 readValBig (typename std::enable_if< std::is_same< T, atInt32 >::value >::type *=0)
 
atUint32 readUint32 ()
 Reads a Uint32 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atUint32 readVal (typename std::enable_if< std::is_same< T, atUint32 >::value >::type *=0)
 
atUint32 readUint32Little ()
 Reads a Uint32 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atInt32 readValLittle (typename std::enable_if< std::is_same< T, atUint32 >::value >::type *=0)
 
atUint32 readUint32Big ()
 Reads a Uint32 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atUint32 readValBig (typename std::enable_if< std::is_same< T, atUint32 >::value >::type *=0)
 
atInt64 readInt64 ()
 Reads a Int64 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atInt64 readVal (typename std::enable_if< std::is_same< T, atInt64 >::value >::type *=0)
 
atInt64 readInt64Little ()
 Reads a Int64 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atInt64 readValLittle (typename std::enable_if< std::is_same< T, atInt64 >::value >::type *=0)
 
atInt64 readInt64Big ()
 Reads a Int64 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atInt64 readValBig (typename std::enable_if< std::is_same< T, atInt64 >::value >::type *=0)
 
atUint64 readUint64 ()
 Reads a Uint64 and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atUint64 readVal (typename std::enable_if< std::is_same< T, atUint64 >::value >::type *=0)
 
atUint64 readUint64Little ()
 Reads a Uint64 and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atUint64 readValLittle (typename std::enable_if< std::is_same< T, atUint64 >::value >::type *=0)
 
atUint64 readUint64Big ()
 Reads a Uint64 and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atUint64 readValBig (typename std::enable_if< std::is_same< T, atUint64 >::value >::type *=0)
 
float readFloat ()
 Reads a float and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
float readVal (typename std::enable_if< std::is_same< T, float >::value >::type *=0)
 
float readFloatLittle ()
 Reads a float and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
float readValLittle (typename std::enable_if< std::is_same< T, float >::value >::type *=0)
 
float readFloatBig ()
 Reads a float and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
float readValBig (typename std::enable_if< std::is_same< T, float >::value >::type *=0)
 
double readDouble ()
 Reads a double and swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
double readVal (typename std::enable_if< std::is_same< T, double >::value >::type *=0)
 
double readDoubleLittle ()
 Reads a double and swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
double readValLittle (typename std::enable_if< std::is_same< T, double >::value >::type *=0)
 
double readDoubleBig ()
 Reads a double and swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
double readValBig (typename std::enable_if< std::is_same< T, double >::value >::type *=0)
 
bool readBool ()
 Reads a bool and advances the current position. More...
 
template<class T >
bool readVal (typename std::enable_if< std::is_same< T, bool >::value >::type *=0)
 
template<class T >
bool readValLittle (typename std::enable_if< std::is_same< T, bool >::value >::type *=0)
 
template<class T >
bool readValBig (typename std::enable_if< std::is_same< T, bool >::value >::type *=0)
 
atVec2f readVec2f ()
 Reads an atVec2f (8 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec2f readVal (typename std::enable_if< std::is_same< T, atVec2f >::value >::type *=0)
 
atVec2f readVec2fLittle ()
 Reads an atVec2f (8 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec2f readValLittle (typename std::enable_if< std::is_same< T, atVec2f >::value >::type *=0)
 
atVec2f readVec2fBig ()
 Reads an atVec2f (8 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec2f readValBig (typename std::enable_if< std::is_same< T, atVec2f >::value >::type *=0)
 
atVec3f readVec3f ()
 Reads an atVec3f (12 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec3f readVal (typename std::enable_if< std::is_same< T, atVec3f >::value >::type *=0)
 
atVec3f readVec3fLittle ()
 Reads an atVec3f (12 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec3f readValLittle (typename std::enable_if< std::is_same< T, atVec3f >::value >::type *=0)
 
atVec3f readVec3fBig ()
 Reads an atVec3f (12 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec3f readValBig (typename std::enable_if< std::is_same< T, atVec3f >::value >::type *=0)
 
atVec4f readVec4f ()
 Reads an atVec4f (16 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec4f readVal (typename std::enable_if< std::is_same< T, atVec4f >::value >::type *=0)
 
atVec4f readVec4fLittle ()
 Reads an atVec4f (16 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec4f readValLittle (typename std::enable_if< std::is_same< T, atVec4f >::value >::type *=0)
 
atVec4f readVec4fBig ()
 Reads an atVec4f (16 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec4f readValBig (typename std::enable_if< std::is_same< T, atVec4f >::value >::type *=0)
 
atVec2d readVec2d ()
 Reads an atVec2d (16 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec2d readVal (typename std::enable_if< std::is_same< T, atVec2d >::value >::type *=0)
 
atVec2d readVec2dLittle ()
 Reads an atVec2d (16 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec2d readValLittle (typename std::enable_if< std::is_same< T, atVec2d >::value >::type *=0)
 
atVec2d readVec2dBig ()
 Reads an atVec2d (16 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec2d readValBig (typename std::enable_if< std::is_same< T, atVec2d >::value >::type *=0)
 
atVec3d readVec3d ()
 Reads an atVec3d (24 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec3d readVal (typename std::enable_if< std::is_same< T, atVec3d >::value >::type *=0)
 
atVec3d readVec3dLittle ()
 Reads an atVec3d (24 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec3d readValLittle (typename std::enable_if< std::is_same< T, atVec3d >::value >::type *=0)
 
atVec3d readVec3dBig ()
 Reads an atVec3d (24 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec3d readValBig (typename std::enable_if< std::is_same< T, atVec3d >::value >::type *=0)
 
atVec4d readVec4d ()
 Reads an atVec4d (32 bytes), swaps to endianness specified by setEndian depending on platform and advances the current position. More...
 
template<class T >
atVec4d readVal (typename std::enable_if< std::is_same< T, atVec4d >::value >::type *=0)
 
atVec4d readVec4dLittle ()
 Reads an atVec4d (32 bytes), swaps against little endianness depending on platform and advances the current position. More...
 
template<class T >
atVec4d readValLittle (typename std::enable_if< std::is_same< T, atVec4d >::value >::type *=0)
 
atVec4d readVec4dBig ()
 Reads an atVec4d (32 bytes), swaps against big endianness depending on platform and advances the current position. More...
 
template<class T >
atVec4d readValBig (typename std::enable_if< std::is_same< T, atVec4d >::value >::type *=0)
 
std::string readWStringAsString (atInt32 fixedLen=-1)
 Reads a wide-char string (using endianness from setEndian), converts to UTF8 and advances the position in the file. More...
 
std::string readWStringAsStringLittle (atInt32 fixedLen=-1)
 Reads a wide-char string (against little-endian), converts to UTF8 and advances the position in the file. More...
 
std::string readWStringAsStringBig (atInt32 fixedLen=-1)
 Reads a wide-char string (against big-endian), converts to UTF8 and advances the position in the file. More...
 
std::string readString (atInt32 fixedLen=-1)
 Reads a string and advances the position in the file. More...
 
template<class T >
std::string readVal (typename std::enable_if< std::is_same< T, std::string >::value >::type *=0)
 
std::wstring readWString (atInt32 fixedLen=-1)
 Reads a wstring and advances the position in the file. More...
 
template<class T >
std::wstring readVal (typename std::enable_if< std::is_same< T, std::wstring >::value >::type *=0)
 
std::wstring readWStringLittle (atInt32 fixedLen=-1)
 Reads a wstring assuming little-endian characters and advances the position in the file. More...
 
template<class T >
std::wstring readValLittle (typename std::enable_if< std::is_same< T, std::wstring >::value >::type *=0)
 
std::wstring readWStringBig (atInt32 fixedLen=-1)
 Reads a wstring assuming big-endian characters and advances the position in the file. More...
 
template<class T >
std::wstring readValBig (typename std::enable_if< std::is_same< T, std::wstring >::value >::type *=0)
 
template<class T >
void enumerate (std::vector< T > &vector, size_t count, typename std::enable_if< std::is_arithmetic< T >::value||std::is_same< T, atVec2f >::value||std::is_same< T, atVec3f >::value||std::is_same< T, atVec4f >::value >::type *=0)
 Performs automatic std::vector enumeration reads using numeric type T. More...
 
template<class T >
void enumerateLittle (std::vector< T > &vector, size_t count, typename std::enable_if< std::is_arithmetic< T >::value||std::is_same< T, atVec2f >::value||std::is_same< T, atVec3f >::value||std::is_same< T, atVec4f >::value >::type *=0)
 Performs automatic std::vector enumeration reads using numeric type T. More...
 
template<class T >
void enumerateBig (std::vector< T > &vector, size_t count, typename std::enable_if< std::is_arithmetic< T >::value||std::is_same< T, atVec2f >::value||std::is_same< T, atVec3f >::value||std::is_same< T, atVec4f >::value >::type *=0)
 Performs automatic std::vector enumeration reads using numeric type T. More...
 
template<class T >
void enumerate (std::vector< T > &vector, size_t count, typename std::enable_if<!std::is_arithmetic< T >::value &&!std::is_same< T, atVec2f >::value &&!std::is_same< T, atVec3f >::value &&!std::is_same< T, atVec4f >::value >::type *=0)
 Performs automatic std::vector enumeration reads using non-numeric type T. More...
 
template<class T >
void enumerate (std::vector< T > &vector, size_t count, std::function< void(IStreamReader &, T &)> readf)
 Performs lambda-assisted std::vector enumeration reads using type T. More...
 
- Public Member Functions inherited from athena::io::IStream
void setEndian (Endian endian)
 
Endian endian () const
 
bool isBigEndian () const
 
bool isLittleEndian () const
 
bool hasError () const
 

Protected Attributes

std::string m_filename
 
FILE * m_fileHandle
 
std::unique_ptr< atUint8[]> m_cacheData
 
atInt32 m_blockSize
 
atInt32 m_curBlock
 
atUint64 m_offset
 
bool m_globalErr
 
- Protected Attributes inherited from athena::io::IStream
bool m_hasError = false
 
Endian m_endian = BigEndian
 

Additional Inherited Members

- Protected Member Functions inherited from athena::io::IStream
void setError ()
 

Detailed Description

Definition at line 13 of file FileReader.hpp.

Member Function Documentation

atUint64 athena::io::FileReader::length ( ) const
virtual

Returns the length of the file.

Returns
True length of the file.

Implements athena::io::IStreamReader.

atUint64 athena::io::FileReader::position ( ) const
virtual

Returns the current position in the stream.

Returns
The current position in the stream.

Implements athena::io::IStreamReader.

atUint64 athena::io::FileReader::readUBytesToBuf ( void *  buf,
atUint64  len 
)
virtual

Attempts to read a fixed length of data into a pre-allocated buffer, this function is client defined and must be implemented.

Parameters
bufThe buffer to read into
lenThe length of the buffer
Returns
How much data was actually read, useful for detecting read errors.

Implements athena::io::IStreamReader.

void athena::io::FileReader::seek ( atInt64  pos,
SeekOrigin  origin = SeekOrigin::Current 
)
virtual

Sets the buffers position relative to the specified position.
It seeks relative to the current position by default.

Parameters
positionwhere in the buffer to seek
originThe Origin to seek relative to

Implements athena::io::IStreamReader.


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