Athena IO Library
IStream.hpp
1 #ifndef STREAM_HPP
2 #define STREAM_HPP
3 
4 #include "Global.hpp"
5 
6 namespace athena
7 {
8 namespace io
9 {
10 std::ostream& operator<<(std::ostream& os, Endian& endian);
11 
12 class IStream
13 {
14 public:
15  IStream() {}
16  virtual ~IStream() {}
17 
18  inline void setEndian(Endian endian) { m_endian = endian; }
19  inline Endian endian() const { return m_endian; }
20  inline bool isBigEndian() const { return (m_endian == Endian::BigEndian); }
21  inline bool isLittleEndian() const { return (m_endian == Endian::LittleEndian); }
22  virtual void seek(atInt64, SeekOrigin) = 0;
23  virtual bool atEnd() const = 0;
24  virtual atUint64 position() const = 0;
25  virtual atUint64 length() const = 0;
26  bool hasError() const { return m_hasError; }
27 protected:
28  void setError() { m_hasError = true; }
29  bool m_hasError = false;
30 #if __BYTE_ORDER == __BIG_ENDIAN
31  Endian m_endian = BigEndian;
32 #else
33  Endian m_endian = LittleEndian;
34 #endif
35 };
36 }
37 }
38 #endif // STREAM_HPP