aboutsummaryrefslogtreecommitdiff
path: root/src/substream.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-10-16 16:09:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-10-16 16:09:02 +0000
commitbf53de3dfa4db68627f2935e6b2144835604df3a (patch)
treee5e50c0b0e7df827dcdc8a162f1ff5fb61ac3277 /src/substream.h
parent96b07a22f5392f5d7f821f5743deb3d64bd94e89 (diff)
downloadlibbu++-bf53de3dfa4db68627f2935e6b2144835604df3a.tar.gz
libbu++-bf53de3dfa4db68627f2935e6b2144835604df3a.tar.bz2
libbu++-bf53de3dfa4db68627f2935e6b2144835604df3a.tar.xz
libbu++-bf53de3dfa4db68627f2935e6b2144835604df3a.zip
Finally added the substream class, and added getByPath (for properties) and
getChildByPath (for groups) to the TafGroup class.
Diffstat (limited to '')
-rw-r--r--src/substream.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/substream.h b/src/substream.h
new file mode 100644
index 0000000..5218493
--- /dev/null
+++ b/src/substream.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright (C) 2007-2008 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_SUB_STREAM_H
9#define BU_SUB_STREAM_H
10
11#include "bu/filter.h"
12
13namespace Bu
14{
15 /**
16 * Creates a sub-stream of a given stream. This allows you to read and
17 * write safely to a section of another stream, keeping all data within
18 * the given bounds. The substream acts exactly like a top level stream
19 * when you reach the bounds of either the containing stream or the
20 * artificial bounds of the substream, except that unlike many stream types,
21 * when writing you cannot move beyond the bounds of the substream. Reads,
22 * on the other hand, work exactly the same way, returning less data than
23 * requested when the end of the stream is reached.
24 *
25 * The substream always begins at the current position in the base stream,
26 * if you would like to skip some data first, simply seek.
27 *
28 * The substream class is safe to use with all blocking and non-blocking
29 * base streams, including sockets, however it can have unpredictable
30 * results when used on a buffering stream that may read more data than
31 * requested in order to complete a request such as the buffer or bzip2
32 * filters.
33 */
34 class SubStream : public Bu::Filter
35 {
36 public:
37 SubStream( Bu::Stream &rNext, long iSize );
38 virtual ~SubStream();
39
40 virtual size_t read( void *pBuf, size_t nBytes );
41 virtual size_t write( const void *pBuf, size_t nBytes );
42 using Bu::Stream::write;
43
44 virtual void start();
45 virtual size_t stop();
46 virtual void close();
47 virtual long tell();
48 virtual void seek( long offset );
49 virtual void setPos( long pos );
50 virtual void setPosEnd( long pos );
51 virtual bool isEos();
52
53 virtual bool canRead();
54 virtual bool canWrite();
55
56 protected:
57 long iStart;
58 long iPos;
59 long iSize;
60 };
61};
62
63#endif