From b5b68088f28b2593bfbf910a46fd52775007e8b3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 19 Nov 2007 09:39:24 +0000 Subject: Added the Bu::StdStream Stream class, it's just a wrapper for writing to, reading from standard output/input. --- src/stdstream.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stdstream.h | 43 ++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 src/stdstream.cpp create mode 100644 src/stdstream.h diff --git a/src/stdstream.cpp b/src/stdstream.cpp new file mode 100644 index 0000000..1ddb3c1 --- /dev/null +++ b/src/stdstream.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "bu/stdstream.h" + +Bu::StdStream::StdStream() +{ +} + +Bu::StdStream::~StdStream() +{ +} + +void Bu::StdStream::close() +{ +} + +size_t Bu::StdStream::read( void *pBuf, size_t nBytes ) +{ + return fread( pBuf, 1, nBytes, stdin ); +} + +size_t Bu::StdStream::write( const void *pBuf, size_t nBytes ) +{ + return fwrite( pBuf, 1, nBytes, stdout ); +} + +long Bu::StdStream::tell() +{ + return 0; +} + +void Bu::StdStream::seek( long offset ) +{ +} + +void Bu::StdStream::setPos( long pos ) +{ +} + +void Bu::StdStream::setPosEnd( long pos ) +{ +} + +bool Bu::StdStream::isEOS() +{ + return false; +} + +bool Bu::StdStream::isOpen() +{ + return true; +} + +void Bu::StdStream::flush() +{ + fflush( stdout ); +} + +bool Bu::StdStream::canRead() +{ + return true; +} + +bool Bu::StdStream::canWrite() +{ + return true; +} + +bool Bu::StdStream::isReadable() +{ + return true; +} + +bool Bu::StdStream::isWritable() +{ + return true; +} + +bool Bu::StdStream::isSeekable() +{ + return false; +} + +bool Bu::StdStream::isBlocking() +{ + return true; +} + +void Bu::StdStream::setBlocking( bool bBlocking ) +{ +} + diff --git a/src/stdstream.h b/src/stdstream.h new file mode 100644 index 0000000..ccfb28a --- /dev/null +++ b/src/stdstream.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef BU_STD_STREAM_H +#define BU_STD_STREAM_H + +#include +#include +#include "stream.h" + +namespace Bu +{ + class StdStream : public Stream + { + public: + StdStream(); + virtual ~StdStream(); + + virtual void close(); + virtual size_t read( void *pBuf, size_t nBytes ); + virtual size_t write( const void *pBuf, size_t nBytes ); + virtual long tell(); + virtual void seek( long offset ); + virtual void setPos( long pos ); + virtual void setPosEnd( long pos ); + virtual bool isEOS(); + virtual bool isOpen(); + virtual void flush(); + virtual bool canRead(); + virtual bool canWrite(); + virtual bool isReadable(); + virtual bool isWritable(); + virtual bool isSeekable(); + virtual bool isBlocking(); + virtual void setBlocking( bool bBlocking=true ); + }; +} + +#endif -- cgit v1.2.3