00001
00042 #ifndef INC_MI32_SERIALIZER_H
00043 #define INC_MI32_SERIALIZER_H
00044
00045 #ifndef INC_MI32_SERIALIZERITEM_H
00046 #include <mi32/serializeritem.h>
00047 #endif
00048
00049 #ifndef INC_RVC_OBJITEMLIST_H
00050 #include <rvc/objitemlist.h>
00051 #endif
00052
00053 #ifndef INC_RVC_SERIALIZE_H
00054 #include <rvc/serialze.h>
00055 #endif
00056
00057 #ifndef INC_MI32_RANGE_H
00058 #include <mi32/range.h>
00059 #endif
00060
00061 #ifdef WIN32
00062 #pragma warning (disable:4996) // Disable warning about deprecated declaration within header
00063 #endif
00064
00065
00066 #ifndef GENERATING_DOXYGEN_OUTPUT
00067 class FILE_TEXT;
00068 struct OLDPROJPARM;
00069 struct COLOR;
00070 struct DPOINT2D;
00071 struct DPOINT3D;
00072 struct DRECT2D;
00073 struct DRECT3D;
00074 class MISTATUSCONTEXT;
00075 namespace SPATREF {
00076 class COORDREFSYS;
00077 }
00078 #endif
00079
00080
00086
00087 class SERIALIZER {
00088 public:
00089
00091 SERIALIZER (
00092 );
00093
00095 virtual ~SERIALIZER (
00096 );
00097
00099 ERRVALUE Append (
00100 const FILEPATH& filepath
00101 );
00102
00104 void Close (
00105 );
00106
00108 const FILEPATH& GetFilePath (
00109 ) const { return (m_filepath); }
00110
00112 bool GetIgnoreSkippable (
00113 ) const { return (m_IgnoreSkippable); }
00114
00116 const char* GetItemName (
00117 ) const { return (m_itemname); }
00118
00120 const MIUNICODE* GetItemValue (
00121 ) const { return (m_parmvalue); }
00122
00125 bool GetItemValue (
00126 double& value
00127 ) const;
00128
00129
00130 const MISTRING& GetLog (
00131 ) const { return (m_Log); }
00132
00133
00134 MISTRING& GetLog (
00135 ) { return (m_Log); }
00136
00138 const MIUNICODE* GetObjectName (
00139 ) const { return (m_Descriptor.GetFullName()); }
00140
00142 void GetScanListMissing (
00143 RVC::OBJITEMLIST& MissingList
00144 ) { MissingList.Merge(m_ScanFileObjListMissing); }
00145
00147 void GetScanListUsed (
00148 RVC::OBJITEMLIST& UsedList
00149 ) { UsedList.Merge(m_ScanFileObjListUsed); }
00150
00152 UINT16 GetVersion (
00153 ) const { return (m_Version[m_depth]); }
00154
00156 bool IsScanOnly (
00157 ) const { return (m_ScanOnly); }
00158
00160 void LogClear (
00161 ) { m_Log.Clear(); }
00162
00165 void LogError (
00166 ERRVALUE err
00167 );
00168
00170 void LogText (
00171 const MISTRING& text
00172 ) { m_Log << text; }
00173
00175 ERRVALUE Make (
00176 RVC::OBJITEM& objitem,
00177 const RVC::SERIALIZE::MAKEPARMS& makeparms
00178 );
00179
00181 ERRVALUE Make (
00182 RVC::OBJECT& parent,
00183 RVC::OBJTYPE objtype,
00184 RVC::DESCRIPTOR& descriptor,
00185 const RVC::SERIALIZE::MAKEPARMS& makeparms
00186 );
00187
00189 ERRVALUE Make (
00190 const FILEPATH& filepath,
00191 int version = 1
00192 );
00193
00195 ERRVALUE Open (
00196 const RVC::OBJITEM& objitem
00197 );
00198
00200 ERRVALUE Open (
00201 const FILEPATH& filepath
00202 );
00203
00205 ERRVALUE PutBegin (
00206 const char *tagname,
00207 UINT16 version = 0
00208 );
00209
00211 ERRVALUE PutDouble (
00212 const char *tagname,
00213 double value
00214 );
00215
00217 ERRVALUE PutEnd (
00218 );
00219
00221 ERRVALUE PutInt (
00222 const char *tagname,
00223 int value
00224 );
00225
00227 ERRVALUE PutItem (
00228 const char *tagname,
00229 const COLOR& color
00230 );
00231
00233 ERRVALUE PutItem (
00234 const char *tagname,
00235 const DPOINT2D& point2d
00236 );
00237
00239 ERRVALUE PutItem (
00240 const char *tagname,
00241 const DPOINT3D& point3d
00242 );
00243
00245 ERRVALUE PutItem (
00246 const char *tagname,
00247 const DRECT2D& rect
00248 );
00249
00251 ERRVALUE PutItem (
00252 const char *tagname,
00253 const DRECT3D& rect
00254 );
00255
00257 ERRVALUE PutItem (
00258 const char *tagname,
00259 const LPOINT2D& point2d
00260 );
00261
00263 ERRVALUE PutItem (
00264 const char *tagname,
00265 const LRECT2D& rect
00266 );
00267
00269 ERRVALUE PutItem (
00270 const char *tagname,
00271 const DOUBLE_RANGE& value
00272 );
00273
00275 ERRVALUE PutItem (
00276 const char *tagname,
00277 const OLDPROJPARM& oldprojparm
00278 );
00279
00281 ERRVALUE PutItem (
00282 const char *tagname,
00283 const SPATREF::COORDREFSYS& crs
00284 );
00285
00287 ERRVALUE PutStr (
00288 const char *tagname,
00289 const MIUNICODE *str
00290 );
00291
00293 ERRVALUE PutStrML (
00294 const char *tagname,
00295 const MIUNICODE *str
00296 );
00297
00299 ERRVALUE PutUnsigned (
00300 const char *tagname,
00301 unsigned int value
00302 );
00303
00305 ERRVALUE Read (
00306 SERIALIZABLE& object
00307 );
00308
00310 ERRVALUE Read (
00311 const char *tagname,
00312 SERIALIZABLE& object
00313 );
00314
00316 ERRVALUE Read (
00317 const SERIALIZERITEM *itemdef,
00318 void *data
00319 );
00320
00322 ERRVALUE Read (
00323 const char *tagname,
00324 const SERIALIZERITEM *itemdef,
00325 void *data
00326 );
00327
00329 ERRVALUE Read (
00330 OLDPROJPARM& oldprojparm
00331 );
00332
00334 ERRVALUE Rewind (
00335 );
00336
00338 void SetIgnoreSkippable (
00339 bool IgnoreSkippable = true
00340 ) { m_IgnoreSkippable = IgnoreSkippable; }
00341
00343 void SetScanOnly (
00344 bool ScanOnly
00345 ) { m_ScanOnly = ScanOnly; }
00346
00348 void SetVersion (
00349 UINT16 Version
00350 ) { m_Version[m_depth] = Version; }
00351
00353 ERRVALUE SkipStruct (
00354 );
00355
00357 ERRVALUE StatusTextUpdate (
00358 const MISTRING& string
00359 );
00360
00362 ERRVALUE Write (
00363 const SERIALIZERITEM *itemdef,
00364 const void *data
00365 );
00366
00368 ERRVALUE Write (
00369 const char *tagname,
00370 const SERIALIZERITEM *itemdef,
00371 const void *data,
00372 UINT16 version = 0
00373 );
00374
00376 ERRVALUE Write (
00377 const SERIALIZABLE& object,
00378 const char *tagname = 0
00379 );
00380
00381 private:
00382 #ifndef GENERATING_DOXYGEN_OUTPUT
00383
00384 FILEPATH m_filepath;
00385 RVC::DESCRIPTOR m_Descriptor;
00386 FILE_TEXT *m_pFileText;
00387 RVC::SERIALIZE m_SerialObj;
00388 int m_depth;
00389 UINT16 m_Version[128];
00390 char m_itemname[128];
00391 MISTRING m_parmvalue;
00392 MISTATUSCONTEXT *m_pStatusContext;
00393 INT32 m_filesize;
00394 INT32 m_filepos;
00395 bool m_IgnoreSkippable;
00396 bool m_ScanOnly;
00397 RVC::OBJITEMLIST m_ScanFileObjListUsed;
00398 RVC::OBJITEMLIST m_ScanFileObjListMissing;
00399 MISTRING m_Log;
00400 RVC::OBJECT::AUTOFILECACHE m_AutoFileCache;
00401
00402 static const SERIALIZERITEM* GetItemDefREGION2D ();
00403 static const SERIALIZERITEM* GetItemDefSUBREGION2D ();
00404
00405
00406 ERRVALUE CallItemCB (
00407 const SERIALIZERITEM *itemdef,
00408 void *data,
00409 SERIALIZERITEM::ACTION action
00410 );
00411
00412
00413 ERRVALUE FindLinkFile (
00414 const SERIALIZERITEM *parmdp,
00415 const UINT8* data,
00416 FILEPATH& linkfilepath,
00417 bool OriginalFirst = false
00418 );
00419
00420
00421 int FindObject (
00422 const SERIALIZERITEM *parmdp,
00423 const SERIALIZERITEM *startdp,
00424 UINT8 *data
00425 );
00426
00427
00428 ERRVALUE GetStrML (
00429 MIUNICODE **str
00430 );
00431
00432
00433 ERRVALUE GetStrML (
00434 char **str,
00435 bool raw = false
00436 );
00437
00438
00439 ERRVALUE PutStr (
00440 const char *tagname,
00441 const char *str
00442 );
00443
00444
00445 ERRVALUE PutStrML (
00446 const char *tagname,
00447 const char *str
00448 );
00449
00450
00451 ERRVALUE ReadLine (
00452 MISTRING& string,
00453 bool raw = false
00454 );
00455
00456
00457 ERRVALUE WriteText (
00458 const MIUNICODE *str
00459 );
00460
00461
00462 ERRVALUE WriteText (
00463 const char *str
00464 );
00465
00466 SERIALIZER (const SERIALIZER&);
00467 SERIALIZER& operator= (const SERIALIZER&);
00468 #endif // GENERATING_DOXYGEN_OUTPUT
00469 };
00470
00471
00472
00473
00474 #ifdef WIN32
00475 #pragma warning (default:4996) // Restore warning about deprecated declaration
00476 #endif
00477
00478 #endif // INC_MI32_SERIALIZER_H