00001 #ifndef __CPresetIO__
00002 #define __CPresetIO__
00003
00004
00005
00006 #include "../Collections/CollectionTypedef.h"
00007 #include "CTextStream.hpp"
00008
00009
00010
00011 using Exponent::Collections::TStringCountedPointerArray;
00012 using Exponent::IO::CTextStream;
00013
00014
00015
00016 namespace Exponent
00017 {
00018 namespace IO
00019 {
00043 class CPresetIO : public CCountedObject
00044 {
00046 EXPONENT_CLASS_DECLARATION;
00049
00050
00051 public:
00052
00053
00054
00058 CPresetIO();
00059
00063 virtual ~CPresetIO();
00064
00065
00066
00074 bool open(const CTextStream::EStreamMode streamMode, const CString &pluginName, const CSystemString &presetPath);
00075
00081 bool close(const CString &pluginName);
00082
00086 void close();
00087
00088
00089
00095 bool readVersionNumber(const long expectedVersion);
00096
00104 bool readVersionNumber(const long *expectedVersion, const long numberOfVersions, long &actualVersion);
00105
00111 bool readHeadChunk(TStringCountedPointerArray &array);
00112
00117 bool openHeadChunk();
00118
00123 bool openBodyChunk();
00124
00131 bool readParameterChunk(const long numberOfParameters, double *parameters);
00132
00140 bool readChunkToDoubles(const CString &tag, const long sizeOfChunk, double *buffer);
00141
00148 bool readChunkToStrings(const CString &tag, TStringCountedPointerArray &array);
00149
00157 bool readChunkToLongs(const CString &tag, const long sizeOfChunk, long *buffer);
00158
00159
00160
00166 bool writeVersionNumber(const long number);
00167
00173 bool writeHeadChunk(TStringCountedPointerArray &array);
00174
00181 bool writeParameterChunk(const long numberOfParameters, const double *parameters);
00182
00190 bool writeChunkToDoubles(const CString &tag, const long sizeOfChunk, const double *buffer);
00191
00198 bool writeChunkToStrings(const CString &tag, TStringCountedPointerArray &array);
00199
00207 bool writeChunkToLongs(const CString &tag, const long sizeOfChunk, long *buffer);
00208
00209
00210
00215 bool closeHeadChunk();
00216
00221 bool closeBodyChunk();
00222
00223
00224
00229 CTextStream &getTextStream() { return m_stream; }
00230
00231
00232
00233 protected:
00234
00235
00236
00242 bool writeOpenTag(const CString &tag);
00243
00248 bool writeCloseTag(const CString &tag);
00249
00250
00251
00257 bool readOpenTag(const CString &tag);
00258
00264 bool readCloseTag(const CString &tag);
00265
00266
00267
00273 void constructOpenTag(CString &openTag, const CString &tag);
00274
00280 void constructCloseTag(CString &closeTag, const CString &tag);
00281
00282
00283
00284 CTextStream m_stream;
00286 bool m_isOpenForRead;
00287 bool m_isOpenForWrite;
00290 };
00291 }
00292 }
00293 #endif // End of CPresetIO.hpp