summaryrefslogtreecommitdiffstats
path: root/noatun-plugins/oblique/kbuffer.h
blob: 18f9b3baa0579bbb9e4ec15228d26ae7fb7596a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Author: Eray Ozkural (exa) <[email protected]>, (c) 2002
//
// Copyright: GNU LGPL: http://www.gnu.org/licenses/lgpl.html

#ifndef KBUFFER_H
#define KBUFFER_H

#include <tqiodevice.h>
#include <vector>
#include <queue>

/**A buffer device for flexible and efficient buffers.

  *@author Eray Ozkural (exa)
  */

class TDEBuffer : public TQIODevice  {
public:
  TDEBuffer();
  ~TDEBuffer();
  /** open a memory buffer */
  bool open(int mode);
  /** read in a block of memory */
  TQ_LONG readBlock(char* data, long unsigned int maxLen);
  /** query buffer size */
#ifdef USE_QT4
  qint64 size() const;
#else // USE_QT4
  TQ_ULONG size() const;
#endif // USE_QT4
  /** No descriptions */
  void flush();
  /** Close buffer */
  void close();
  /** write a block of memory */
  TQ_LONG writeBlock(const char *data, long unsigned int maxLen);
  /** read a byte */
  int getch();
  /** undo last getch()
 */
  int ungetch(int);
  /** write a byte */
  int putch(int);
  void* data() {
    return &buf[0];
  }

#ifdef USE_QT4
	virtual inline qint64 readData ( char * data, qint64 maxSize ) { return readBlock(data, maxSize); }
	virtual inline qint64 writeData ( const char * data, qint64 maxSize ) { return writeBlock(data, maxSize); }
#endif // USE_QT4

private:
  std::vector<char> buf;
  std::vector<char>::iterator bufPos;
};

#endif