summaryrefslogtreecommitdiff
path: root/src/stable/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/buffer.h')
-rw-r--r--src/stable/buffer.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/stable/buffer.h b/src/stable/buffer.h
new file mode 100644
index 0000000..91ec9c2
--- /dev/null
+++ b/src/stable/buffer.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_BUFFER_H
9#define BU_BUFFER_H
10
11#include "bu/filter.h"
12
13namespace Bu
14{
15 class Buffer : public Bu::Filter
16 {
17 public:
18 Buffer( Bu::Stream &rNext, int iWhat=Both, int iBufSize=4096 );
19 virtual ~Buffer();
20
21 enum
22 {
23 Write = 1,
24 Read = 2,
25 Both = 3
26 };
27
28 virtual void start();
29 virtual Bu::size stop();
30
31 virtual Bu::size read( void *pBuf, Bu::size nBytes );
32 virtual Bu::size write( const void *pBuf, Bu::size nBytes );
33 using Stream::write;
34
35 Bu::size getReadFill() { return iReadBufFill; }
36 bool isWritePending() { return iWriteBufFill > 0; }
37
38 virtual void flush();
39
40 virtual bool isEos();
41
42 private:
43 void fillReadBuf();
44
45 private:
46 Bu::size sSoFar;
47 int iBufSize;
48 char *sReadBuf;
49 char *sWriteBuf;
50 int iReadBufFill;
51 int iReadPos;
52 int iWriteBufFill;
53 int iWritePos;
54 int iWhat;
55 };
56};
57
58#endif