FDO API Reference | Feature Data Objects |
00001 #ifndef FDO_IO_STREAM_H 00002 #define FDO_IO_STREAM_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 /// \brief 00025 /// FdoIoStream defines the interface for all FDO streams. Streamed I/O support 00026 /// for various locations, such as files, memory, etc. can be provided by classes 00027 /// that implement this interface. 00028 /// \note 00029 /// There is no function provided to close a FdoIoStream. The only way 00030 /// to close it is to destroy it by releasing all references. 00031 class FdoIoStream : public FdoDisposable 00032 { 00033 public: 00034 /// \brief 00035 /// reads the number of bytes indicated by count into the given buffer, 00036 /// or the number of bytes after the current stream position, whichever is less. 00037 /// The stream’s current position is moved ahead by the number of bytes read. 00038 /// 00039 /// \param buffer 00040 /// Output read into this buffer 00041 /// \param count 00042 /// Input read this number of bytes into the buffer. 00043 /// The caller is responsible for allocating a buffer that is large enough to hold the bytes. 00044 /// 00045 /// \return 00046 /// Returns the number of bytes that were read. 0 if already at the 00047 /// end of the stream. 00048 /// 00049 FDO_API_COMMON virtual FdoSize Read( FdoByte* buffer, FdoSize count ) = 0; 00050 00051 /// \brief 00052 /// writes the number of bytes indicated by count, from the given buffer, 00053 /// to the stream. The current position is moved ahead by the number of bytes 00054 /// written. 00055 /// 00056 /// \param buffer 00057 /// Intput write from this buffer 00058 /// \param count 00059 /// Input number of bytes to write 00060 /// 00061 /// \note 00062 /// Write will overwrite some of the contents of the stream 00063 /// if the current position is not at the end of the stream. 00064 FDO_API_COMMON virtual void Write( FdoByte* buffer, FdoSize count ) = 0; 00065 00066 /// \brief 00067 /// reads the number of bytes from the given stream, and writes them 00068 /// to this stream. 00069 /// 00070 /// \param stream 00071 /// Input write from this buffer 00072 /// \param count 00073 /// Input the maximum number of bytes to read and write. 00074 /// When 0, all remaining bytes are read from the given stream. 00075 /// 00076 FDO_API_COMMON virtual void Write( FdoIoStream* stream, FdoSize count = 0 ) = 0; 00077 00078 /// \brief 00079 /// truncates the stream to the indicated length. 00080 /// 00081 /// \param length 00082 /// Input the new length (in bytes) for the stream. If this is 00083 /// longer than the current stream length then the stream's length 00084 /// is not changed. 00085 /// 00086 FDO_API_COMMON virtual void SetLength( FdoInt64 length) = 0; 00087 00088 /// \brief 00089 /// gets the current length of the stream. 00090 /// 00091 /// \return 00092 /// Returns the length in bytes. Returns -1 if the length is unknown 00093 /// or undefined. 00094 /// 00095 FDO_API_COMMON virtual FdoInt64 GetLength() = 0; 00096 00097 /// \brief 00098 /// gets the current position for the stream. 00099 /// 00100 /// \return 00101 /// Returns the position in bytes from the start. When 0, the 00102 /// the position is at the start of the stream. When GetIndex() == 00103 /// GetLength() the position is at the end of the stream. 00104 /// 00105 FDO_API_COMMON virtual FdoInt64 GetIndex() = 0; 00106 00107 /// \brief 00108 /// skips over part of the stream. 00109 /// 00110 /// \param offset 00111 /// The number of bytes to skip. if positive then 00112 /// the current position is moved forward. If negative, the position is 00113 /// moved backward. The position will remain between the start and end 00114 /// of the stream. The position is set to the end of the stream if the 00115 /// given offset would put it past the end. Similarily, the position is 00116 /// set to the start if the offset would put it before the start. 00117 /// 00118 FDO_API_COMMON virtual void Skip( FdoInt64 offset ) = 0; 00119 00120 /// \brief 00121 /// sets the position to the start of the stream. 00122 /// 00123 FDO_API_COMMON virtual void Reset() = 0; 00124 00125 /// \brief 00126 /// gets the reading capability. 00127 /// 00128 /// \return 00129 /// Returns true if the stream can be read. 00130 /// 00131 FDO_API_COMMON virtual FdoBoolean CanRead() 00132 { 00133 return true; 00134 } 00135 00136 /// \brief 00137 /// gets the writing capability. 00138 /// 00139 /// \return 00140 /// Returns true if the stream can be written to. 00141 /// 00142 FDO_API_COMMON virtual FdoBoolean CanWrite() 00143 { 00144 return true; 00145 } 00146 00147 /// \brief 00148 /// returns whether the stream has any positional context. 00149 /// Streams without context can only be read and written in a forward-only 00150 /// manner. These streams do not allow position and length changes. 00151 /// 00152 /// \return 00153 /// Returns true if the stream has context. Returns false if it does 00154 /// not. When a stream does not have context, the SetLength(), Skip() and 00155 /// Reset() functions are not supported. 00156 /// 00157 FDO_API_COMMON virtual FdoBoolean HasContext() 00158 { 00159 return true; 00160 } 00161 00162 protected: 00163 }; 00164 00165 /// \ingroup (typedefs) 00166 /// \brief 00167 /// FdoIoStreamP is a FdoPtr on FdoIoStream, provided for convenience. 00168 typedef FdoPtr<FdoIoStream> FdoIoStreamP; 00169 00170 #endif 00171 00172
Comments or suggestions? Send us feedback. |