00001
00036 #ifndef INC_MI32_GENERICRW_H
00037 #define INC_MI32_GENERICRW_H
00038
00039 #ifndef INC_MI32_SIMPLEAR_H
00040 #include <mi32/simplear.h>
00041 #endif
00042
00043 #ifdef MISYSTEMDLL
00044 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00045 #else
00046 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00047 #endif
00048
00049
00050
00052
00053
00054 class CLASSLIBEXPORT GENERICRW {
00055 public:
00056
00058 enum SEEKFROM {
00059 SEEKFROM_Beginning = 0,
00060 SEEKFROM_Current,
00061 SEEKFROM_End
00062 };
00063
00065 enum CAPABILITIES {
00066 CAPABILITY_None = 0x0000,
00067 CAPABILITY_Read = 0x0001,
00068 CAPABILITY_Write = 0x0002,
00069 CAPABILITY_Seek = 0x0004,
00070 CAPABILITY_Resize = 0x0008,
00071 CAPABILITY_Accept = 0x0010,
00072 CAPABILITY_Bind = 0x0020,
00073 CAPABILITY_NonBlocking = 0x0040,
00074 CAPABILITY_Size = 0x0080,
00075 CAPABILITIES_All = 0x00FF
00076 };
00077
00079 virtual ~GENERICRW ();
00080
00083 CAPABILITIES GetCapabilities (
00084 ) const;
00085
00090 INT64 GetSize (
00091 ) const;
00092
00095 INT64 GetSizeLimit (
00096 ) const;
00097
00100 void* GetMappedMemory (
00101 INT64& size,
00102 INT64 offset = 0
00103 );
00104
00107 INT32 Read (
00108 void* buffer,
00109 INT32 numbytes,
00110 bool AllowPartial = false
00111 );
00112
00114 ERRVALUE ReadAll (
00115 SIMPLE_ARRAY<UINT8>& buffer
00116 );
00117
00121 ERRVALUE Resize (
00122 INT64 newsize
00123 );
00124
00127 INT64 Seek (
00128 INT64 offset,
00129 SEEKFROM from = SEEKFROM_Beginning
00130 );
00131
00134 ERRVALUE SeekAndRead (
00135 INT64 offset,
00136 void* buffer,
00137 INT32 numbytes
00138 );
00139
00141 ERRVALUE SeekAndWrite (
00142 INT64 offset,
00143 const void* buffer,
00144 INT32 numbytes
00145 );
00146
00149 INT64 Tell (
00150 ) const;
00151
00153 ERRVALUE Write (
00154 const void* buffer,
00155 INT32 numbytes
00156 );
00157
00158 private:
00159
00160
00162 virtual CAPABILITIES v_GetCapabilities () const = 0;
00163
00165 virtual void* v_GetMappedMemory (INT64& size, INT64 offset);
00166
00168 virtual INT64 v_GetSize () const = 0;
00169
00171 virtual INT64 v_GetSizeLimit () const = 0;
00172
00175 virtual INT32 v_Read (void* buffer, INT32 numbytes, bool AllowPartial) = 0;
00176
00178 virtual ERRVALUE v_Resize (INT64 newsize) = 0;
00179
00181 virtual INT64 v_Seek (INT64 offset, SEEKFROM from) = 0;
00182
00184 virtual INT64 v_Tell () const = 0;
00185
00187 virtual ERRVALUE v_Write (const void* buffer, INT32 numbytes) = 0;
00188 };
00189
00190 #ifndef GENERATING_DOXYGEN_OUTPUT
00191 DEFINE_ENUM_OP_BITWISE(GENERICRW::CAPABILITIES)
00192 #endif
00193
00194
00195
00196 #undef CLASSLIBEXPORT
00197
00198 #endif // INC_MI32_GENERICRW_H