• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/io/StreamBuffer.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #include <spl/io/Stream.h>
00018 
00019 #ifdef _stream2_h
00020 /* _stream2_h is in Stream.h, only compile this file if using the new Stream.h header */
00021 
00022 #ifndef _streambuffer_h
00023 #define _streambuffer_h
00024 
00031 class StreamBuffer;
00032 typedef RefCountPtrCast<StreamBuffer, spl::IStream, spl::IStreamPtr> StreamBufferPtr;
00033 
00034 REGISTER_TYPEOF(126, StreamBufferPtr);
00035 
00037 class StreamBuffer : public spl::IStream
00038 {
00039 protected:
00040         spl::IStreamPtr m_strm;
00041         bool m_deleteStream;
00042         Array<byte> m_buf;
00043         int m_bufpos;
00044         int m_buflen;
00045 
00046 public:
00047         StreamBuffer( spl::IStreamPtr strm, const int buflen = 512 );
00048         virtual ~StreamBuffer();
00049 
00051         virtual void Close();
00052         
00054         virtual void Flush();
00055         
00057         virtual int Read(Array<byte>& buffer, const int offset, int count);
00058 
00060         virtual int ReadByte();
00061 
00063         virtual long Seek(const long offset, const SeekOrigin origin);
00064         
00066         virtual void Write(const Array<byte>& buffer, const int offset, const int count);
00067 
00069         virtual void WriteByte(byte value);
00070 
00071         virtual bool CanRead() const;
00072         virtual bool CanSeek() const;
00073         virtual bool CanWrite() const;
00074 
00075         virtual long Length() const;
00076         virtual long Position() const;
00077 
00078 #ifdef DEBUG
00079         virtual void ValidateMem() const;
00080         virtual void CheckMem() const;
00081 #endif
00082 };
00083 
00084 REGISTER_TYPEOF(128, StreamBuffer);
00085 
00088 #endif
00089 #endif