- Main Page
- Related Pages
- Modules
- Classes
- Files

# BufferStream.h

Go to the documentation of this file.

    00001 #ifndef FDO_IO_BUFFERSTREAM_H
    00002 #define FDO_IO_BUFFERSTREAM_H
    00003 //
    00004
    00005 //
    00006 // Copyright (C) 2004-2006  Autodesk, Inc.
    00007 //
    00008 // This library is free software; you can redistribute it and/or
    00009 // modify it under the terms of version 2.1 of the GNU Lesser
    00010 // General Public License as published by the Free Software Foundation.
    00011 //
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015 // Lesser General Public License for more details.
    00016 //
    00017 // You should have received a copy of the GNU Lesser General Public
    00018 // License along with this library; if not, write to the Free Software
    00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00020 //
    00021
    00022 #include <FdoCommon.h>
    00023
    00024 /// \cond DOXYGEN-IGNORE
    00025 // This class is not yet exposed to the API.
    00026 // It provides streamed I/O against a simple array of bytes.
    00027 class FdoIoBufferStream :
    00028     public FdoIoStream
    00029 {
    00030 public:
    00031     /// Creates a stream around the given buffer.
    00032     static FdoIoBufferStream* Create( FdoByte* buffer, FdoSize size );
    00033     /// Creates a new buffer of the given size and wraps a stream around it.
    00034     static FdoIoBufferStream* Create( FdoSize size );
    00035
    00036     /// FdoIoStream implementations
    00037     virtual FdoSize Read( FdoByte* buffer, FdoSize count );
    00038     virtual void Write( FdoByte* buffer, FdoSize count );
    00039     virtual void Write( FdoIoStream* stream, FdoSize count = 0 );
    00040     virtual void SetLength( FdoInt64 length );
    00041
    00042     virtual FdoInt64 GetLength() {
    00043         return( mLength);
    00044     }
    00045
    00046     virtual FdoInt64 GetIndex()
    00047     {
    00048         return mPos;
    00049     }
    00050
    00051     virtual void Skip( FdoInt64 offset );
    00052     virtual void Reset();
    00053
    00054 protected:
    00055     FdoIoBufferStream( FdoByte* buffer, FdoSize size );
    00056     FdoIoBufferStream( FdoSize size = 4096 );
    00057     virtual ~FdoIoBufferStream(void);
    00058
    00059 private:
    00060     /// the buffer.
    00061     FdoByte* mpBuffer;
    00062     /// true if the buffer was allocated by this stream.
    00063     /// false if the stream is attached to an existing buffer.
    00064     FdoBoolean mbMyBuffer;
    00065     /// Total size of the buffer
    00066     FdoSize mSize;
    00067     /// Total length of the stream
    00068     FdoSize mLength;
    00069     /// Current stream position.
    00070     FdoSize mPos;
    00071
    00072 };
    00073
    00074 typedef FdoPtr<FdoIoBufferStream> FdoIoBufferStreamP;
    00075 /// \endcond
    00076
    00077 #endif
    00078
    00079

Please send us your comment about this page