2014-04-20 09:14:15 +00:00
|
|
|
#ifndef FILESTREAM_HPP
|
|
|
|
#define FILESTREAM_HPP
|
|
|
|
|
2015-03-01 20:42:39 +00:00
|
|
|
#include "Athena/IStreamReader.hpp"
|
2014-04-20 09:14:15 +00:00
|
|
|
#include <string>
|
2015-05-18 21:03:13 +00:00
|
|
|
#include <stdio.h>
|
2014-04-20 09:14:15 +00:00
|
|
|
|
|
|
|
namespace Athena
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
2015-03-01 20:42:39 +00:00
|
|
|
class FileReader : public IStreamReader
|
2014-04-20 09:14:15 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileReader(const std::string& filename);
|
2015-01-29 06:31:14 +00:00
|
|
|
virtual ~FileReader();
|
2014-04-20 09:14:15 +00:00
|
|
|
std::string filename() const;
|
|
|
|
|
|
|
|
void setEndian(Endian endian);
|
|
|
|
Endian endian() const;
|
|
|
|
bool isBigEndian() const;
|
|
|
|
bool isLittleEndian() const;
|
|
|
|
void open();
|
|
|
|
void close();
|
|
|
|
bool isOpen() const;
|
|
|
|
bool save();
|
2014-06-18 04:51:18 +00:00
|
|
|
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
|
2015-04-11 00:04:13 +00:00
|
|
|
inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);}
|
2014-04-20 09:14:15 +00:00
|
|
|
bool atEnd() const;
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint64 position() const;
|
|
|
|
atUint64 length() const;
|
2014-04-20 09:14:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
void seekBit(int);
|
|
|
|
bool readBit();
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8 readUByte();
|
|
|
|
atInt8 readByte();
|
|
|
|
atUint8* readUBytes(atUint64 len);
|
|
|
|
atInt8* readBytes(atUint64 len);
|
2015-04-11 00:04:13 +00:00
|
|
|
atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);}
|
|
|
|
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint16 readUint16();
|
|
|
|
atInt16 readInt16();
|
|
|
|
atUint32 readUint32();
|
|
|
|
atInt32 readInt32();
|
|
|
|
atUint64 readUint64();
|
|
|
|
atInt64 readInt64();
|
2014-04-20 09:14:15 +00:00
|
|
|
double readDouble();
|
|
|
|
float readFloat();
|
|
|
|
bool readBool();
|
2015-06-19 02:55:05 +00:00
|
|
|
atVec3f readVec3f();
|
|
|
|
atVec4f readVec4f();
|
2015-01-29 06:20:57 +00:00
|
|
|
std::string readString(atInt32 maxlen = -1);
|
2015-06-19 02:55:05 +00:00
|
|
|
std::wstring readWString(atInt32 maxLen = -1);
|
2015-01-29 06:20:57 +00:00
|
|
|
std::string readUnicode(atInt32 maxlen = -1);
|
|
|
|
protected:
|
2014-04-20 09:14:15 +00:00
|
|
|
std::string m_filename;
|
|
|
|
FILE* m_fileHandle;
|
|
|
|
Endian m_endian;
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8 m_currentByte;
|
|
|
|
atUint8 m_bitShift;
|
2014-04-20 09:14:15 +00:00
|
|
|
bool m_bitValid;
|
|
|
|
};
|
|
|
|
} // io
|
|
|
|
} // Athena
|
|
|
|
|
2014-04-25 02:01:24 +00:00
|
|
|
#ifndef FILEREADER_BASE
|
2015-01-29 06:20:57 +00:00
|
|
|
#define FILEREADER_BASE() \
|
2014-04-25 02:01:24 +00:00
|
|
|
private: \
|
2015-01-29 06:20:57 +00:00
|
|
|
typedef Athena::io::FileReader base
|
2014-04-25 02:01:24 +00:00
|
|
|
|
|
|
|
#endif // FILEREADER_BASE
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
#endif // FILESTREAM_HPP
|