Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
stream.h
1 
17 #pragma once
18 #include <cstddef>
19 #include <memory>
20 #include <queue>
21 #include <stdexcept>
22 #include <string>
23 #include <vector>
24 
25 namespace Akumuli {
26 
27 typedef char Byte;
28 
29 class StreamError : public std::exception {
30  std::string line_;
31  int pos_;
32 
33 public:
34  enum {
35  MAX_LENGTH = 64,
36  };
37  StreamError(std::string line, int pos);
38 
39  virtual const char* what() const throw();
40  std::string get_bottom_line() const;
41 };
42 
45 
46  virtual ~ByteStreamReader();
47 
52  virtual Byte get() = 0;
53 
58  virtual Byte pick() const = 0;
59 
63  virtual bool is_eof() = 0;
64 
74  virtual int read(Byte* buffer, size_t buffer_len) = 0;
75 
78  virtual void close() = 0;
79 
84  virtual std::tuple<std::string, size_t> get_error_context(const char* error_message) const = 0;
85 };
86 
88  const Byte* buf_; //< Source bytes
89  const size_t size_; //< Source size
90  size_t pos_; //< Position in the stream
91 public:
92  MemStreamReader(const Byte* buffer, size_t buffer_len);
93 
94  // ByteStreamReader interface
95 public:
96  virtual Byte get();
97  virtual Byte pick() const;
98  virtual bool is_eof();
99  virtual int read(Byte* buffer, size_t buffer_len);
100  virtual void close();
101  virtual std::tuple<std::string, size_t> get_error_context(const char* error_message) const;
102 };
103 
104 } // namespace
virtual void close()
Definition: stream.cpp:66
Definition: stream.h:29
virtual bool is_eof()
Definition: stream.cpp:55
virtual bool is_eof()=0
virtual std::tuple< std::string, size_t > get_error_context(const char *error_message) const
Definition: stream.cpp:70
virtual Byte pick() const =0
virtual void close()=0
Definition: stream.h:87
virtual std::tuple< std::string, size_t > get_error_context(const char *error_message) const =0
virtual Byte pick() const
Definition: stream.cpp:48
virtual int read(Byte *buffer, size_t buffer_len)
Definition: stream.cpp:59
Definition: stream.h:44
virtual int read(Byte *buffer, size_t buffer_len)=0