WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
raw_istream.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef NT_RAW_ISTREAM_H_
9 #define NT_RAW_ISTREAM_H_
10 
11 #include <cstddef>
12 
13 namespace nt {
14 
15 class raw_istream {
16  public:
17  raw_istream() = default;
18  virtual ~raw_istream() = default;
19  virtual bool read(void* data, std::size_t len) = 0;
20  virtual void close() = 0;
21 
22  raw_istream(const raw_istream&) = delete;
23  raw_istream& operator=(const raw_istream&) = delete;
24 };
25 
26 class raw_mem_istream : public raw_istream {
27  public:
28  raw_mem_istream(const char* mem, std::size_t len) : m_cur(mem), m_left(len) {}
29  virtual ~raw_mem_istream() = default;
30  virtual bool read(void* data, std::size_t len);
31  virtual void close() {}
32 
33  private:
34  const char* m_cur;
35  std::size_t m_left;
36 };
37 
38 } // namespace nt
39 
40 #endif // NT_RAW_ISTREAM_H_
Definition: raw_istream.h:15
Definition: raw_istream.h:26