tudocomp
– The TU Dortmund Compression Framework
VectorStreamBuffer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <streambuf>
4 #include <vector>
5 
6 namespace tdc {
7 namespace io {
8 
10 
11 template<typename T>
12 class VectorStreamBuffer : public std::streambuf {
13 
14 private:
15  std::vector<T> *m_vec;
16 
17 public:
18  VectorStreamBuffer(std::vector<T>& vec) : m_vec(&vec) {
19  }
20 
21  virtual ~VectorStreamBuffer() {
22  }
23 
24 protected:
25  virtual int overflow(int ch) override {
26  if(ch == EOF) {
27  return EOF;
28  } else {
29  m_vec->push_back((T)ch);
30  return ch;
31  }
32  }
33 
34  virtual int underflow() override {
35  return EOF;
36  }
37 };
38 
40 
41 }}
42 
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11