From a83e9babede7ab5bc8e1ac6c7ee3784b91bd8452 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 4 Aug 2010 15:17:11 +0000 Subject: Alright, NullStream compiles and works. --- src/nullstream.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nullstream.h') 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 @@ namespace Bu { + /** + * Works a lot like /dev/null on *nix style systems. This class allows + * infinite reading and writing. All operatorns "succeed" even if they + * don't seem to do anything. This is great for testing writing code or + * doing dry runs. When reading, it will produce NULL bytes, so any + * application that would like the ability to produce null streams as a + * snap-in replacement for any other Bu::Stream, this is the right option. + * + * As an added feature, the NullStream will track how many bytes it was + * asked to read and write, allowing you to use it to determine how many + * bytes a write opretion would use without actually writing anything. + */ class NullStream : public Bu::Stream { public: @@ -31,6 +43,13 @@ namespace Bu virtual bool isBlocking(); virtual void setBlocking( bool bBlocking=true ); virtual void setSize( long iSize ); + + size_t getBytesRead() { return sRead; } + size_t getByetsWritten() { return sWrote; } + + private: + size_t sRead; + size_t sWrote; }; }; -- cgit v1.2.3