liballofw
stream.h
Go to the documentation of this file.
1 #ifndef ALLOFW_STREAM_H
2 #define ALLOFW_STREAM_H
3 
4 #include "common.h"
5 
6 namespace allofw {
7 
8  class ByteStream {
9  public:
10  enum SeekOrigin {
12  };
13  virtual size_t read(void* buffer, size_t length);
14  virtual size_t write(const void* buffer, size_t length);
15  virtual void seek(SeekOrigin origin, std::ptrdiff_t pos);
16  virtual std::ptrdiff_t position();
17  virtual void flush();
18  virtual bool canRead();
19  virtual bool canWrite();
20  virtual bool canSeek();
21 
22  // mode = "r" / "w" / "a"
23  static ByteStream* OpenFile(const char* path, const char* mode);
24  static void Destroy(ByteStream* stream);
25 
26  protected:
27  virtual ~ByteStream();
28  };
29 
30  class io_error : public std::exception { };
31 
32 }
33 
34 #endif
virtual void seek(SeekOrigin origin, std::ptrdiff_t pos)
Definition: stream.h:8
virtual std::ptrdiff_t position()
SeekOrigin
Definition: stream.h:10
Definition: stream.h:11
Definition: stream.h:11
virtual ~ByteStream()
static void Destroy(ByteStream *stream)
Definition: allofw.h:12
virtual bool canSeek()
virtual size_t write(const void *buffer, size_t length)
virtual void flush()
Definition: stream.h:30
virtual bool canWrite()
virtual bool canRead()
virtual size_t read(void *buffer, size_t length)
static ByteStream * OpenFile(const char *path, const char *mode)
Definition: stream.h:11