aboutsummaryrefslogtreecommitdiff
path: root/src/nullstream.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nullstream.h')
-rw-r--r--src/nullstream.h19
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
6namespace Bu 6namespace 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