diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-08-04 15:17:11 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-04 15:17:11 +0000 |
commit | a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452 (patch) | |
tree | e54db7f9a50e7f9924c5a749a586fbf172cb48ce /src/nullstream.h | |
parent | 819cfbbc5f8caa65575caefb3e602d2d9f7425b3 (diff) | |
download | libbu++-a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452.tar.gz libbu++-a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452.tar.bz2 libbu++-a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452.tar.xz libbu++-a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452.zip |
Alright, NullStream compiles and works.
Diffstat (limited to 'src/nullstream.h')
-rw-r--r-- | src/nullstream.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nullstream.h b/src/nullstream.h index 5440af6..1537ffb 100644 --- a/src/nullstream.h +++ b/src/nullstream.h | |||
@@ -5,6 +5,18 @@ | |||
5 | 5 | ||
6 | namespace Bu | 6 | namespace Bu |
7 | { | 7 | { |
8 | /** | ||
9 | * Works a lot like /dev/null on *nix style systems. This class allows | ||
10 | * infinite reading and writing. All operatorns "succeed" even if they | ||
11 | * don't seem to do anything. This is great for testing writing code or | ||
12 | * doing dry runs. When reading, it will produce NULL bytes, so any | ||
13 | * application that would like the ability to produce null streams as a | ||
14 | * snap-in replacement for any other Bu::Stream, this is the right option. | ||
15 | * | ||
16 | * As an added feature, the NullStream will track how many bytes it was | ||
17 | * asked to read and write, allowing you to use it to determine how many | ||
18 | * bytes a write opretion would use without actually writing anything. | ||
19 | */ | ||
8 | class NullStream : public Bu::Stream | 20 | class NullStream : public Bu::Stream |
9 | { | 21 | { |
10 | public: | 22 | public: |
@@ -31,6 +43,13 @@ namespace Bu | |||
31 | virtual bool isBlocking(); | 43 | virtual bool isBlocking(); |
32 | virtual void setBlocking( bool bBlocking=true ); | 44 | virtual void setBlocking( bool bBlocking=true ); |
33 | virtual void setSize( long iSize ); | 45 | virtual void setSize( long iSize ); |
46 | |||
47 | size_t getBytesRead() { return sRead; } | ||
48 | size_t getByetsWritten() { return sWrote; } | ||
49 | |||
50 | private: | ||
51 | size_t sRead; | ||
52 | size_t sWrote; | ||
34 | }; | 53 | }; |
35 | }; | 54 | }; |
36 | 55 | ||