aboutsummaryrefslogtreecommitdiff
path: root/src/stable/buffer.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
commit469bbcf0701e1eb8a6670c23145b0da87357e178 (patch)
treeb5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/stable/buffer.h
parentee1b79396076edc4e30aefb285fada03bb45e80d (diff)
downloadlibbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
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