Athena IO Library
PHYSFSFileReader.hpp
1 #ifdef ATHENA_ENABLE_PHYSFS
2 #ifndef PHYSFSSTREAM_HPP
3 #define PHYSFSSTREAM_HPP
4 
5 #include "athena/Stream.hpp"
6 #include <physfs.h>
7 
8 namespace athena
9 {
10 namespace io
11 {
12 class PHYSFSFileReader : public Stream
13 {
14 public:
15  PHYSFSFileReader(const std::string& path);
16 
17  void setEndian(Endian);
18  Endian endian() const;
19  bool isBigEndian() const;
20  bool isLittleEndian() const;
21  atUint8* data();
22 
23  atUint64 length() const;
24 
25  atUint64 position() const;
26 
27  bool isOpen() const;
28 
29  void seek(atInt64 position, SeekOrigin origin);
30  atInt8 readByte();
31  atUint8 readUByte();
32  atUint8* readUBytes(atUint64 length);
33  atInt8* readBytes(atUint64 length);
34  atUint16 readUint16();
35  atInt16 readInt16();
36  atUint32 readUint32();
37  atInt32 readInt32();
38  atUint64 readUint64();
39  atInt64 readInt64();
40  double readDouble();
41  float readFloat();
42  bool readBool();
43 
44  bool atEnd() const;
45 
46  // TODO: Strings
47 private:
48  Endian m_endian;
49  std::string m_path;
50  atUint64 m_length;
51  PHYSFS_File* m_handle;
52 };
53 }
54 }
55 
56 #ifndef PHYSFSFILEREADER_BASE
57 #define PHYSFSFILEREADER_BASE() \
58  typedef athena::io::PHYSFSFileReader base
59 #endif
60 #endif // PHYSFSSTREAM_HPP
61 #endif // ATHENA_ENABLE_PHYSFS