diff options
Diffstat (limited to '')
-rw-r--r-- | src/stable/substream.h | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/src/stable/substream.h b/src/stable/substream.h index 5905043..f79ed0b 100644 --- a/src/stable/substream.h +++ b/src/stable/substream.h | |||
@@ -12,52 +12,52 @@ | |||
12 | 12 | ||
13 | namespace Bu | 13 | namespace Bu |
14 | { | 14 | { |
15 | /** | 15 | /** |
16 | * Creates a sub-stream of a given stream. This allows you to read and | 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 | 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 | 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 | 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, | 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, | 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 | 22 | * on the other hand, work exactly the same way, returning less data than |
23 | * requested when the end of the stream is reached. | 23 | * requested when the end of the stream is reached. |
24 | * | 24 | * |
25 | * The substream always begins at the current position in the base stream, | 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. | 26 | * if you would like to skip some data first, simply seek. |
27 | * | 27 | * |
28 | * The substream class is safe to use with all blocking and non-blocking | 28 | * The substream class is safe to use with all blocking and non-blocking |
29 | * base streams, including sockets, however it can have unpredictable | 29 | * base streams, including sockets, however it can have unpredictable |
30 | * results when used on a buffering stream that may read more data than | 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 | 31 | * requested in order to complete a request such as the buffer or bzip2 |
32 | * filters. | 32 | * filters. |
33 | */ | 33 | */ |
34 | class SubStream : public Bu::Filter | 34 | class SubStream : public Bu::Filter |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | SubStream( Bu::Stream &rNext, Bu::size iSize ); | 37 | SubStream( Bu::Stream &rNext, Bu::size iSize ); |
38 | virtual ~SubStream(); | 38 | virtual ~SubStream(); |
39 | 39 | ||
40 | virtual Bu::size read( void *pBuf, Bu::size nBytes ); | 40 | virtual Bu::size read( void *pBuf, Bu::size nBytes ); |
41 | virtual Bu::size write( const void *pBuf, Bu::size nBytes ); | 41 | virtual Bu::size write( const void *pBuf, Bu::size nBytes ); |
42 | using Bu::Stream::write; | 42 | using Bu::Stream::write; |
43 | 43 | ||
44 | virtual void start(); | 44 | virtual void start(); |
45 | virtual Bu::size stop(); | 45 | virtual Bu::size stop(); |
46 | virtual void close(); | 46 | virtual void close(); |
47 | virtual Bu::size tell(); | 47 | virtual Bu::size tell(); |
48 | virtual void seek( Bu::size offset ); | 48 | virtual void seek( Bu::size offset ); |
49 | virtual void setPos( Bu::size pos ); | 49 | virtual void setPos( Bu::size pos ); |
50 | virtual void setPosEnd( Bu::size pos ); | 50 | virtual void setPosEnd( Bu::size pos ); |
51 | virtual bool isEos(); | 51 | virtual bool isEos(); |
52 | 52 | ||
53 | virtual bool canRead(); | 53 | virtual bool canRead(); |
54 | virtual bool canWrite(); | 54 | virtual bool canWrite(); |
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | Bu::size iStart; | 57 | Bu::size iStart; |
58 | Bu::size iPos; | 58 | Bu::size iPos; |
59 | Bu::size iSize; | 59 | Bu::size iSize; |
60 | }; | 60 | }; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | #endif | 63 | #endif |