ComSDK
 Указатель Классы Пространства имен Функции Переменные Определения типов Перечисления Элементы перечислений Друзья Группы Страницы
streamtools.h
1 //========================================================================
2 #ifndef comfrm_cls_DataStreamH
3 #define comfrm_cls_DataStreamH
4 //========================================================================
5 #include "libtools.h"
6 
7 #include <vector>
8 #include <boost/noncopyable.hpp>
9 //========================================================================
10 //template<typename CharT, typename TraitsT = std::char_traits< CharT > >
11 //class MAC_DLLEXPORT VectorBuf : public std::basic_streambuf< CharT, TraitsT >
12 namespace com {
13  class MAC_DLLEXPORT VectorBuf : public std::streambuf, boost::noncopyable
14  {
15  //const int m_reallocationAddition = 256;
16  const int m_reallocationAddition = 4;
17 
18  public:
19  explicit VectorBuf(std::vector< char >& p_vector);
20 
21  private:
22  int_type underflow(); // TODO: it duplicates default behaviour, can be deleted
23  int_type overflow(int_type ch);
24  int sync();
25 
26  private:
27  std::vector< char >& m_vector;
28  };
29 
35  class MAC_DLLEXPORT VectorStream : public std::iostream
36  {
37  public:
38  VectorStream(std::vector< char > &p_vector)
39  //: m_vectorbuf(p_vector)
40  //, std::iostream(&m_vectorbuf)
41  : std::iostream()
42  , m_vectorbuf(p_vector)
43  {
44  this->init(&m_vectorbuf);
45  }
46 
50  size_t bytesAvailable()
51  {
52  return m_vectorbuf.in_avail();
53  }
54 
55  private:
56  VectorBuf m_vectorbuf;
57 
58  };
59 }
60 //========================================================================
61 #endif
62 //========================================================================
Векторный поток
Definition: streamtools.h:35
size_t bytesAvailable()
Definition: streamtools.h:50
Definition: streamtools.h:13