serializ.h

Go to the documentation of this file.
00001 /**
00002  * \file serializ.h <mi32/serializ.h>
00003  * \brief SERIALIZER class definition
00004  *
00005  * \if NODOC
00006  * $Id: serializ.h_v 1.39 2004/10/01 17:21:10 mju Exp $
00007  *
00008  * $Log: serializ.h_v $
00009  * Revision 1.39  2004/10/01 17:21:10  mju
00010  * Add getItemValue as double.
00011  *
00012  * Revision 1.38  2004/06/30 18:46:12  mju
00013  * Remove type_mapprojparm.
00014  *
00015  * Revision 1.37  2004/06/28 17:55:41  mju
00016  * Add spaterf and region2d support.
00017  *
00018  * Revision 1.36  2004/06/25 16:31:15  mju
00019  * Add itemdefs for coordrefsys.
00020  *
00021  * Revision 1.35  2004/03/01 18:38:56  mju
00022  * Disable deprecated declaration warning within header.
00023  *
00024  * Revision 1.34  2003/11/12 20:54:05  mju
00025  * Add logging methods.
00026  *
00027  * Revision 1.33  2003/09/26 19:36:41  scowan
00028  * Removed use of include file.
00029  *
00030  * Revision 1.32  2003/09/15 13:49:56  fileserver!dwilliss
00031  * Doxygen
00032  *
00033  * Revision 1.31  2003/09/09 16:22:57  mju
00034  * Add GetFilePath.
00035  *
00036  * Revision 1.30  2003/03/10 15:43:14  mju
00037  * nc.
00038  *
00039  * Revision 1.29  2002/09/11 18:00:39  mju
00040  * Add ITEM_RVCOBJITEM...
00041  *
00042  * Revision 1.28  2002/08/21 20:40:04  scowan
00043  * Deprecate old object name define.
00044  *
00045  * Revision 1.27  2002/04/04 18:36:24  mju
00046  * Remove vararg method as not used.
00047  *
00048  * Revision 1.26  2002/04/04 18:25:12  mju
00049  * Add TYPE_RVCOBJECTNAME.
00050  * Deprecate varargs method.
00051  *
00052  * Revision 1.25  2002/03/26 21:12:56  mju
00053  * Remove deprecated methods.
00054  *
00055  * Revision 1.24  2002/03/05 14:37:01  mju
00056  * Make PutItem methods public.
00057  *
00058  * Revision 1.23  2002/03/04 18:45:39  mju
00059  * Add Open() using objitem.
00060  *
00061  * Revision 1.22  2001/12/28 21:35:49  mju
00062  * SerialWrite and related methods now const.
00063  *
00064  * Revision 1.21  2001/07/12 17:30:32  dwilliss
00065  * Allow for new TYPE_StringMLRaw -- When writing to text file, don't muck
00066  * with the encoding.  It's just a raw one-byte-character string who's encoding
00067  * is only known by the caller.  Can't assume it's UTF8
00068  *
00069  * Revision 1.20  2001/07/12 15:55:19  dwilliss
00070  * Made PutStr() methods public (just the Unicode ones).  There was a comment
00071  * on the (char*) ones to make them go away, so I left them private.  All the
00072  * PutDouble, PutInt, PutUnsigned methods were already public, so why not
00073  * the string ones?
00074  *
00075  * Revision 1.19  2001/06/07 16:09:36  mju
00076  * Add details for SERIALIZABLE.
00077  * Remove unnecessary SERIALIZABLE methods.
00078  * Add TYPE_SERIALIZABLE/PTR.
00079  *
00080  * Revision 1.18  2001/03/05 21:43:59  mju
00081  * Add StatusTextUpdate.
00082  *
00083  * Revision 1.17  2000/11/30 20:36:04  mju
00084  * Add Rewind().
00085  *
00086  * Revision 1.16  2000/11/13 15:00:31  mju
00087  * Change formula layer to use new geoformula class.
00088  *
00089  * Revision 1.14  2000/09/20 14:05:03  mju
00090  * Add flag to not prompt for missing linked file.
00091  *
00092  * Revision 1.13  2000/08/23 22:19:16  dwilliss
00093  * MISTRING?
00094  *
00095  * Revision 1.12  2000/08/18 20:08:09  dwilliss
00096  * Added LPOINT2D/LRECT2D support
00097  *
00098  * Revision 1.9  2000/03/08 18:28:05  mju
00099  * Add GetIgnoreSkippable() method.
00100  *
00101  * Revision 1.8  2000/03/03 15:03:07  mju
00102  * Add FLAG_AddOffsetCB.
00103  *
00104  * Revision 1.7  2000/02/15 14:21:46  mju
00105  * Make SkipStruct public.
00106  *
00107  * Revision 1.6  2000/01/27 15:33:40  mju
00108  * Add GetObjectName().
00109  *
00110  * Revision 1.5  2000/01/19 18:50:49  mju
00111  * Allow FILEPATH for Make/Open.
00112  *
00113  * Revision 1.4  2000/01/19 14:22:29  mju
00114  * Make PutDouble/PutInt public.
00115  * Add GetItemValue().
00116  *
00117  * Revision 1.3  1999/12/10 23:07:25  mju
00118  * Make SERIALIZABLE pure virtual.
00119  *
00120  * Revision 1.1  1999/12/02 23:21:26  mju
00121  * Initial revision
00122  *
00123  * \endif
00124 **/
00125 
00126 #ifndef  INC_MI32_SERIALIZ_H
00127 #define  INC_MI32_SERIALIZ_H
00128 
00129 #ifndef  INC_MI32_STDDEFNS_H
00130 #include <mi32/stddefns.h>
00131 #endif
00132 
00133 #ifndef  INC_MI32_RVCDEFNS_H
00134 #include <mi32/rvcdefns.h>
00135 #endif
00136 
00137 #ifndef  INC_MI32_MSTATUS_H
00138 #include <mi32/mstatus.h>
00139 #endif
00140 
00141 #ifdef WIN32
00142 #pragma warning (disable:4996)   // Disable warning about deprecated declaration within header
00143 #endif
00144 
00145 //! Forward declarations
00146 
00147 class SERIALIZABLE;
00148 struct RVCPARMINFO;
00149 struct OLDPROJPARM;
00150 struct COLOR;
00151 struct DPOINT2D;
00152 struct DPOINT3D;
00153 struct DRECT2D;
00154 struct DRECT3D;
00155 namespace SPATREF {
00156    class COORDREFSYS;
00157    }
00158 
00159 //-----------------------------------------------------------------------------
00160 //    SERIALIZER class
00161 //-----------------------------------------------------------------------------
00162 
00163 //! Class for storing object instances to file.
00164 //! The SERIALIZER class provides methods to write object instances to a text
00165 //! file/object and read those instances back into memory later.  The design
00166 //! allows for the object structure to change while maintaining compatibility
00167 //! with previously existing files.
00168 
00169 class SERIALIZER {
00170    public:
00171 
00172       //! Item definition for single member of structure or class.
00173       class ITEMDEF {
00174          public:
00175 
00176             //! Item types.
00177             enum TYPE {
00178                TYPE_End =              0,
00179 
00180                //! Scalars
00181                TYPE_UINT8 =            1,
00182                TYPE_INT8 =             2,
00183                TYPE_UINT16 =           3,
00184                TYPE_INT16 =            4,
00185                TYPE_UINT32 =           5,
00186                TYPE_INT32 =            6,
00187                TYPE_BitUINT32 =        7,    //!< Bit value in UINT32, bit specified in .extra
00188                TYPE_UInt =             8,    //!< unsigned int
00189                TYPE_Int =              9,    //!< int
00190                TYPE_Float =            10,   //!< float
00191                TYPE_Double =           11,   //!< double
00192                TYPE_Bool =             12,   //!< bool
00193                TYPE_UINT8_Array =      13,
00194                TYPE_Enum =             14,   //!< enum, size specified in .extra
00195 
00196                //! Strings
00197                TYPE_StringU =          20,   //!< UNICODE string (.extra contains size)
00198                TYPE_MISTRING =         21,   //!< MISTRING
00199                TYPE_MISTRING_ML =      22,   //!< Multi-line MISTRING
00200                TYPE_StringMLU =        23,   //!< Multi-line Unicode string
00201                TYPE_StringPtrU =       24,   //!< Pointer to Unicode string
00202                TYPE_StringA =          25,   //!< ASCII string (.extra contains size)
00203                TYPE_StringMLA =        26,   //!< Multi-line ASCII string (pointer)
00204                TYPE_StringPtrA =       27,   //!< Multi-line Unicode String (pointer)
00205                TYPE_StringMLRaw =      28,   //!< Multi-line raw (char*) string (pointer)
00206 
00207                //! Files and objects
00208                TYPE_FileName =         30,   //!< UNICODE filename
00209                TYPE_FILEPATH =         31,
00210                TYPE_Object =           32,   //!< RVC object, type stored in ITEMDEF.extra
00211                TYPE_SubObject =        33,   //!< Subobject, use previous TYPE_Object as parent
00212                TYPE_RVCOBJECTNAME =    34,   //!< RVC::OBJECTNAME
00213                TYPE_RVCOBJITEMFILE =   35,   //!< FilePath portion of RVC::OBJITEM
00214                TYPE_RVCOBJITEMOBJECT = 36,   //!< Object portion of RVC::OBJITEM, type stored in ITEMDEF.extra
00215 
00216                //! Generic
00217                TYPE_Special =          40,   //!< Use cbfunc to do read and write
00218                TYPE_SpecialPtr =       41,   //!< Use cbfunc to do read and write
00219                TYPE_Struct =           42,   //!< Structure/class
00220                TYPE_StructPtr =        43,   //!< Structure/class pointer, will be allocated if 0, .extra contains size
00221                TYPE_StructPtrArray =   44,   //!< Array of structure pointers, .extra contain size
00222 
00223                //! Built-in structures
00224                TYPE_COLOR =            50,   //!< COLOR
00225                TYPE_DRECT2D =          51,   //!< DRECT2D
00226                TYPE_DPOINT2D =         52,   //!< DPOINT2D
00227                TYPE_DPOINT3D =         53,   //!< DPOINT3D
00228                TYPE_POINTSTYLE =       55,   //!< POINTSTYLE
00229                TYPE_LINESTYLE =        56,   //!< LINESTYLE
00230                TYPE_POLYSTYLE =        57,   //!< POLYSTYLE
00231                TYPE_TEXTSTYLE =        58,   //!< TEXTSTYLE
00232                TYPE_LPOINT2D =         59,   //!< LPOINT2D
00233                TYPE_LRECT2D =          60,   //!< LRECT2D
00234                TYPE_OLDPROJPARMTOCRS = 61,   //!< Serialized as OLDPROJPARM, in memory as SPATREF::COORDREFSYS
00235                TYPE_COORDREFSYS =      62,   //!< SPATREF::COORDREFSYS
00236                TYPE_REGION2D =         63,   //!< REGION2D
00237                TYPE_DRECT3D =          64,   //!< DRECT3D
00238 
00239                TYPE_SERIALIZABLE =     90,   //!< SERIALIZABLE object
00240                TYPE_SERIALIZABLEPTR =  91,   //!< Pointer to SERIALIZABLE object
00241 
00242                TYPE_InternalSer =      998,
00243                TYPE_Start =            999   //!< Used internally to start new structure
00244                };
00245 
00246             enum FLAGS {
00247                FLAG_None =                0x0000,
00248                FLAG_NoWrite0 =            0x0001,  //!< Don't write value if not set
00249                FLAG_NoWrite =             0x0002,  //!< Don't write this item
00250                FLAG_NoRead =              0x0004,  //!< Don't read this item
00251                FLAG_FileNoExist0 =        0x0008,  //!< When reading PARMITEM_FileName zero string if file doesn't exist
00252                FLAG_Skippable =           0x0020,  //!< Item will be ignored if "IgnoreSkippable" set
00253                FLAG_AddOffsetCB =         0x0040,  //!< Add offset to pointer when passing to callback function
00254                FLAG_FindFileImmed =       0x0080,  //!< Search for file immediately instead of waiting until looking for object
00255                FLAG_DontAskLinkFile =     0x0100   //!< Don't prompt user if can't find linked file
00256                };
00257 
00258             enum ACTION {
00259                ACTION_None =           0x0000,
00260                ACTION_ReadBegin =      0x0001,
00261                ACTION_ReadEnd =        0x0002,
00262                ACTION_WriteBegin =     0x0004,
00263                ACTION_WriteEnd =       0x0008,
00264                ACTION_Read =           0x0010,
00265                ACTION_Write =          0x0020
00266                };
00267 
00268             typedef ERRVALUE (*CBFUNC)(SERIALIZER&, const ITEMDEF*, void *data, ACTION action);
00269 
00270             char *name;                      //!< Name of the item, 0 to terminate array, not case-sensitive
00271             TYPE type;                       //!< Item type
00272             int offset;                      //!< Offset into class/struct
00273             int extra;                       //!< Extra type-specific data, see below
00274             const ITEMDEF *substruct;        //!< Sub-structure definition for TYPE_Struct/StructPtr
00275             FLAGS flags;                     //!< Flags
00276             CBFUNC cbfunc;                   //!< Callback function for this item
00277 
00278             //!   The meaning of the "extra" field is dependent on the "type" field:
00279             //!
00280             //!      "type"
00281             //!      UINT8_Array                Number of array entries
00282             //!      StringA, StringU           Number of bytes in entry (use membersize in definition)
00283             //!      Object, SubObject          Object type (0 for OTYPE_ALL)
00284             //!      BitUINT32                  Bit number to use, 0 = lowest
00285             //!      StructPtr, StructPtrArray  Size of structure to allocate
00286             //!      Enum                       Size of member
00287 
00288             //! When handling TYPE_Special items, the cbfunc will be called with ACTION_Read or
00289             //! ACTION_Write.  The cbfunc is responsible for actually reading and writing the data
00290             //! using the SERIALIZER class reference provided.
00291 
00292          };
00293 
00294       //! Merge two item definition arrays.
00295       //! This is useful when inheriting from a class which already uses an item definition array.
00296       static ITEMDEF* MergeItemDef (
00297          const ITEMDEF *def1,             //!< First definition array
00298          const ITEMDEF *def2              //!< Second definition array
00299          );                               //! Returns new allocated definition array
00300 
00301       //! Default constructor.
00302       SERIALIZER (
00303          );
00304 
00305       //! Destructor.
00306       virtual ~SERIALIZER (
00307          );
00308 
00309       //! Close the serializer, will be done in destructor.
00310       void Close (
00311          );
00312 
00313       //! Get path to serialization file.
00314       const FILEPATH& GetFilePath (
00315          ) const { return (m_filepath); }
00316 
00317       //! Determine if ignoring "skippable" items.
00318       bool GetIgnoreSkippable (
00319          ) const { return (m_IgnoreSkippable); }
00320 
00321       //! Get name of current item being read/written.
00322       const char* GetItemName (
00323          ) const { return (m_itemname); }
00324 
00325       //! Get value for current item being read.
00326       const UNICODE* GetItemValue (
00327          ) const { return (m_parmvalue); }
00328 
00329       //! Get value for current item as double.
00330       //! @return true if could convert, false if not
00331       bool GetItemValue (
00332          double& value                    //!< Value returned
00333          ) const;
00334 
00335       // Get log text.
00336       const MISTRING& GetLog (
00337          ) const { return (m_Log); }
00338 
00339       // Get log text (non-const).
00340       MISTRING& GetLog (
00341          ) { return (m_Log); }
00342 
00343       //! Get name of object, will be blank if text file.
00344       const UNICODE* GetObjectName (
00345          ) const { return (m_objname); }
00346 
00347       //! Get list of missing files/objects after scan, also clears the list.
00348       FNAMEINODEUC* GetScanListMissing (
00349          ) {
00350          FNAMEINODEUC *temp = m_ScanFileObjListMissing;
00351          m_ScanFileObjListMissing = NULL;
00352          return (temp);
00353          }
00354 
00355       //! Get list of "used" files/objects after scan, also clears the list.
00356       FNAMEINODEUC* GetScanListUsed (
00357          ) {
00358          FNAMEINODEUC *temp = m_ScanFileObjListUsed;
00359          m_ScanFileObjListUsed = NULL;
00360          return (temp);
00361          }
00362 
00363       //! Get current version setting.
00364       UINT16 GetVersion (
00365          ) const { return (m_Version[m_depth]); }
00366 
00367       //! Check if scanning serialization only.
00368       bool IsScanOnly (
00369          ) const { return (m_ScanOnly); }
00370 
00371       //! Clear serialization log.
00372       void LogClear (
00373          ) { m_Log.Clear(); }
00374 
00375       //! Add error message to log.
00376       //! Will insert newline before and after error text.
00377       void LogError (
00378          ERRVALUE err
00379          );
00380 
00381       //! Add text to log.
00382       void LogText (
00383          const MISTRING& text
00384          ) { m_Log << text; }
00385 
00386       //! Create object to contain serialization.
00387       ERRVALUE Make (
00388          const FILEPATH& filepath,        //!< RVC file path
00389          RVCPARMINFO& objinfo             //!< New or existing object header
00390          );
00391 
00392       //! Create object to contain serialization.
00393       ERRVALUE Make (
00394          int fhandle,                     //!< RVC file handle
00395          RVCPARMINFO& objinfo             //!< New or existing object header
00396          );
00397 
00398       //! Create text file to contain serialization.
00399       ERRVALUE Make (
00400          const FILEPATH& filepath,        //!< Text file path
00401          int version = 1                  //!< Version to write
00402          );
00403 
00404       //! Open object containing serialization to read.
00405       ERRVALUE Open (
00406          const RVC::OBJITEM& objitem      //!< RVC object item reference
00407          );
00408 
00409       //! Open object containing serialization to read.
00410       ERRVALUE Open (
00411          const FILEPATH& filepath,        //!< RVC file path
00412          INT32 inode,                     //!< RVC object inode
00413          RVCPARMINFO& objinfo             //!< Object header returned
00414          );
00415 
00416       //! Open object containing serialization to read.
00417       ERRVALUE Open (
00418          int fhandle,                     //!< Open RVC file handle
00419          INT32 inode,                     //!< RVC object inode
00420          RVCPARMINFO& objinfo             //!< Object header returned
00421          );
00422 
00423       //! Open text file containing serialization to read.
00424       ERRVALUE Open (
00425          const FILEPATH& filepath         //!< Text file path
00426          );
00427 
00428       //! Write beginning tag for starting a component.
00429       ERRVALUE PutBegin (
00430          const char *tagname,             //!< Tag name to write
00431          UINT16 version = 0               //!< Optional version
00432          );
00433 
00434       //! Write floating-point value.
00435       ERRVALUE PutDouble (
00436          const char *tagname,             //!< Tag name
00437          double value                     //!< Value to write
00438          );
00439 
00440       //! Write ending tag at end of a component.
00441       ERRVALUE PutEnd (
00442          );
00443 
00444       //! Write integer value.
00445       ERRVALUE PutInt (
00446          const char *tagname,             //!< Tag name to write
00447          int value                        //!< Value to write
00448          );
00449 
00450       //! Write COLOR item.
00451       ERRVALUE PutItem (
00452          const char *tagname,             //!< Tag name to write
00453          const COLOR& color               //!< Item value
00454          );
00455 
00456       //! Write DPOINT2D item.
00457       ERRVALUE PutItem (
00458          const char *tagname,             //!< Tag name to write
00459          const DPOINT2D& point2d          //!< Item value
00460          );
00461 
00462       //! Write DPOINT3D item.
00463       ERRVALUE PutItem (
00464          const char *tagname,             //!< Tag name to write
00465          const DPOINT3D& point3d          //!< Item value
00466          );
00467 
00468       //! Write DRECT2D item.
00469       ERRVALUE PutItem (
00470          const char *tagname,             //!< Tag name to write
00471          const DRECT2D& rect              //!< Item value
00472          );
00473 
00474       //! Write DRECT3D item.
00475       ERRVALUE PutItem (
00476          const char *tagname,             //!< Tag name to write
00477          const DRECT3D& rect              //!< Item value
00478          );
00479 
00480       //! Write LPOINT2D item.
00481       ERRVALUE PutItem (
00482          const char *tagname,             //!< Tag name to write
00483          const LPOINT2D& point2d          //!< Item value
00484          );
00485 
00486       //! Write LRECT2D item.
00487       ERRVALUE PutItem (
00488          const char *tagname,             //!< Tag name to write
00489          const LRECT2D& rect              //!< Item value
00490          );
00491 
00492       //! Write OLDPROJPARM item.
00493       ERRVALUE PutItem (
00494          const char *tagname,             //!< Tag name to write
00495          const OLDPROJPARM& oldprojparm   //!< Item value
00496          );
00497 
00498       //! Write SPATREF::COORDREFSYS item.
00499       ERRVALUE PutItem (
00500          const char *tagname,             //!< Tag name to write
00501          const SPATREF::COORDREFSYS& crs  //!< Item value
00502          );
00503 
00504       //! Write a single-line Unicode string
00505       ERRVALUE PutStr (
00506          const char *tagname,             //!< Tag name to write
00507          const UNICODE *str               //!< String
00508          );
00509 
00510       //! Write a Multi-line Unicode String
00511       ERRVALUE PutStrML (
00512          const char *tagname,             //!< Tag name to write
00513          const UNICODE *str               //!< String
00514          );
00515 
00516       //! Write unsigned integer value.
00517       ERRVALUE PutUnsigned (
00518          const char *tagname,             //!< Tag name to write
00519          unsigned int value               //!< Item value
00520          );
00521 
00522       //! Read SERIALIZABLE object.
00523       inline ERRVALUE Read (
00524          SERIALIZABLE& object             //!< Object to read
00525          );
00526 
00527       //! Read SERIALIZABLE object.
00528       ERRVALUE Read (
00529          const char *tagname,             //!< Tag name to match
00530          SERIALIZABLE& object             //!< Object to read
00531          );
00532 
00533       //! Read items from serialization.
00534       ERRVALUE Read (
00535          const ITEMDEF *itemdef,          //!< Item definition array
00536          void *data                       //!< Serialization data
00537          );
00538 
00539       //! Read items from serialization.
00540       ERRVALUE Read (
00541          const char *tagname,             //!< Tag name to match
00542          const ITEMDEF *itemdef,          //!< Item definition array
00543          void *data                       //!< Serialization data
00544          );
00545 
00546       //! Read OLDPROJPARM from serialization.
00547       ERRVALUE Read (
00548          OLDPROJPARM& oldprojparm
00549          );
00550 
00551       //! Rewind file to beginning.
00552       ERRVALUE Rewind (
00553          );
00554 
00555       //! Set whether to ignore "skippable" items.
00556       void SetIgnoreSkippable (
00557          bool IgnoreSkippable = true      //!< Ignore skippable mode
00558          ) { m_IgnoreSkippable = IgnoreSkippable; }
00559 
00560       //! Set scan-only mode.
00561       void SetScanOnly (
00562          bool ScanOnly                    //!< Scan only mode
00563          ) { m_ScanOnly = ScanOnly; }
00564 
00565       //! Set version (for overriding).
00566       void SetVersion (
00567          UINT16 Version                   //!< Version
00568          ) { m_Version[m_depth] = Version; }
00569 
00570       //! Skip remainder of current structure (for use in item callback).
00571       ERRVALUE SkipStruct (
00572          );
00573 
00574       //! Update status text from Unicode string.
00575       ERRVALUE StatusTextUpdate (
00576          const UNICODE *string
00577          ) { return (MstatusTextUpdateString(m_StatusContext,0,string)); }
00578 
00579       //! Write items without begin/end tags.
00580       ERRVALUE Write (
00581          const ITEMDEF *itemdef,          //!< Item definition array
00582          const void *data                 //!< Data to write
00583          );
00584 
00585       //! Write items to serialized output.
00586       ERRVALUE Write (
00587          const char *tagname,             //!< Name to tag object with
00588          const ITEMDEF *itemdef,          //!< Item definition array
00589          const void *data,                //!< Data to write
00590          UINT16 version = 0               //!< Version to set if top level object
00591          );
00592 
00593       //! Write SERIALIZABLE object.
00594       inline ERRVALUE Write (
00595          const SERIALIZABLE& object,      //!< Object to write
00596          const char *tagname = 0          //!< Name to tag object with
00597          );
00598 
00599    private:
00600       #ifndef GENERATING_DOXYGEN_OUTPUT
00601 
00602       FILEPATH m_filepath;                //!< Path to file
00603       RVC::OBJECTNAME m_objname;          //!< Name of object if in RVC file
00604       FILE *m_fp;                         //!< Text file handle if non-RVC
00605       int m_fhandle;                      //!< RVC file handle if Text object
00606       int m_ohandle;                      //!< RVC object handle for Text object
00607       int m_depth;                        //!< Current depth
00608       UINT16 m_Version[128];              //!< Version at current depth
00609       char m_itemname[128];
00610       UNICODE m_parmvalue[2048];          //!< Last parameter value
00611       MSTATUSCONTEXT m_StatusContext;
00612       INT32 m_filesize;                   //!< Size of file/object being read for status update
00613       INT32 m_filepos;                    //!< Position in file/object for status update
00614       bool m_IgnoreSkippable;
00615       bool m_ScanOnly;
00616       FNAMEINODEUC *m_ScanFileObjListUsed;
00617       FNAMEINODEUC *m_ScanFileObjListMissing;
00618       MISTRING m_Log;
00619 
00620       static const ITEMDEF* GetItemDefREGION2D (
00621          );
00622 
00623       static const ITEMDEF* GetItemDefSUBREGION2D (
00624          );
00625 
00626       //! Call callback for item if necessary.
00627       ERRVALUE CallItemCB (
00628          const ITEMDEF *itemdef,
00629          void *data,                      //!< Callback data
00630          ITEMDEF::ACTION action           //!< Callback action
00631          );
00632 
00633       //! Find link file, add to missing file list if can't find it.
00634       ERRVALUE FindLinkFile (
00635          const ITEMDEF *parmdp,
00636          const UINT8* data,
00637          FILEPATH& linkfilepath,
00638          UINT32 findflags = 0
00639          );
00640 
00641       //! Find object.
00642       int FindObject (
00643          const ITEMDEF *parmdp,
00644          const ITEMDEF *startdp,
00645          UINT8 *data
00646          );
00647 
00648       //! Find subobject.
00649       int FindSubObject (
00650          const ITEMDEF *parmdp,
00651          const ITEMDEF *startdp,
00652          UINT8 *data
00653          );
00654 
00655       //! Get multi-line string (Unicode).
00656       ERRVALUE GetStrML (
00657          UNICODE **str                    //!< XXX change to MISTRING&
00658          );
00659 
00660       //! Get multi-line string (ASCII or RAW).
00661       ERRVALUE GetStrML (
00662          char **str,
00663          bool raw = false  
00664          );
00665 
00666       //! 
00667       ERRVALUE PutObjName (
00668          const ITEMDEF *parmdp,
00669          const ITEMDEF *startdp,
00670          const UINT8 *data
00671          );
00672 
00673       //! 
00674       ERRVALUE PutStr (
00675          const char *tagname,
00676          const char *str                  //!< XXX eliminate
00677          );
00678 
00679 
00680       //! 
00681       ERRVALUE PutStrML (
00682          const char *tagname,
00683          const char *str
00684          );
00685 
00686       //! 
00687       ERRVALUE PutSubObjName (
00688          const ITEMDEF *parmdp,
00689          const ITEMDEF *startdp,
00690          const UINT8 *data
00691          );
00692 
00693       //! 
00694       ERRVALUE ReadLine (
00695          UNICODE *buf,                    //!< XXX change to MISTRING&
00696          int bufsize,
00697          bool raw = false
00698          );
00699 
00700       //! Write single-line UNICODE string.
00701       ERRVALUE WriteText (
00702          const UNICODE *str               //!< String to write
00703          );
00704 
00705       //! Write ASCII string.
00706       ERRVALUE WriteText (
00707          const char *str                  //!< String to write
00708          );
00709 
00710       SERIALIZER (const SERIALIZER&);
00711       SERIALIZER& operator= (const SERIALIZER&);
00712       #endif // GENERATING_DOXYGEN_OUTPUT
00713    };
00714 
00715 DEFINE_ENUM_OPERATORS(SERIALIZER::ITEMDEF::FLAGS);
00716 DEFINE_ENUM_OPERATORS(SERIALIZER::ITEMDEF::ACTION);
00717 
00718 
00719 //-----------------------------------------------------------------------------
00720 //    SERIALIZABLE interface definition
00721 //-----------------------------------------------------------------------------
00722 
00723 //! Interface class for making object serializable.
00724 //! Objects may be serialized without inheriting from this interface provided
00725 //! they are serialized as part of a container object.  In general there are two
00726 //! reasons to inherit from SERIALIZABLE.
00727 //!
00728 //!      1. If the object will be a top-level item in the serialization.  This
00729 //!         makes it easy to read and write the object via the SERIALIZER Read()
00730 //!         and Write() methods pertaining to SERIALIZABLE objects.  Simple
00731 //!         objects which may be represented by an ITEMDEF array do not need to
00732 //!         be made serializable as there are Read/Write methods which may use
00733 //!         this array.  The GRE_LAYOUT and GRE_GROUP classes are examples.
00734 //!
00735 //!      2. If an object is contained within another object and has complicated
00736 //!         serialization which must be implemented via functions rather than
00737 //!         using and ITEMDEF array.  This allows use of TYPE_SERIALIZABLE and
00738 //!         TYPE_SERIALIZABLEPTR in the containing object's ITEMDEF array, thus
00739 //!         simplifying its definition.  The GRE_LAYER::DISPPARM class is an
00740 //!         example of this case.
00741 //!
00742 //!   By convention, if an object implements SerialRead and/or SerialWrite() the
00743 //!   method signatures should match those used in SERIALIZABLE even if the class
00744 //!   does not actually implement the SERIALIZABLE interface.  This allows easy
00745 //!   modification should it become necessary to implement the interface in the
00746 //!   future.  The GRE_LAYER class is an example of this case in that it defines
00747 //! both SerialRead() and SerialWrite() methods but does not specifically
00748 //! inherit from SERIALIZABLE.
00749 
00750 class SERIALIZABLE {
00751    //! This is an "interface" class and must therefore
00752    //! only have virtual methods and no members.
00753 
00754    public:
00755 
00756       //! Read component from serialization.
00757       //! This method must be called only after the tag name has been read and
00758       //! is responsible for determining how to deserialize the component
00759       //! elements.  When beginning a deserialization, usually the
00760       //! SERIALIZER::Read(tagname,object) method should be used to match
00761       //! the desired tag name which was used in writing.
00762       //! A default implementation is not possible due to multiple inheritance
00763       //! resulting in a different "this" pointer being passed than the actual
00764       //! object, which causes the offset values in the ITEMDEF arrays to be wrong.
00765       virtual ERRVALUE SerialRead (
00766          SERIALIZER& serializer
00767          ) = 0;
00768 
00769       //! Write object to serialization.
00770       //! This method must write the tag name provided, using SERIALIZER::PutBegin().
00771       //! If the tagname is 0 (default) then it must determine the proper tag name to
00772       //! write.  After writing the object this method must write the ending tag using
00773       //! SERIALIZER::PutEnd().
00774       //! When inheriting this interface, the default value of 0 for the tag name
00775       //! must NOT be redefined.  (See Meyers, Effective C++, item #38)
00776       //! A default implementation is not possible due to multiple inheritance
00777       //! resulting in a different "this" pointer being passed than the actual
00778       //! object, which causes the offset values in the ITEMDEF arrays to be wrong.
00779       virtual ERRVALUE SerialWrite (
00780          SERIALIZER& serializer,
00781          const char *tagname = 0
00782          ) const = 0;
00783    };
00784 
00785 
00786 //-----------------------------------------------------------------------------
00787 //!      Inline methods
00788 //-----------------------------------------------------------------------------
00789 
00790 #ifndef GENERATING_DOXYGEN_OUTPUT
00791 
00792 inline ERRVALUE SERIALIZER::Read (
00793    SERIALIZABLE& object
00794    ) {
00795    return (object.SerialRead(*this));
00796    }
00797 
00798 inline ERRVALUE SERIALIZER::Write (
00799    const SERIALIZABLE& object,
00800    const char *tagname
00801    ) {
00802    return (object.SerialWrite(*this,tagname));
00803    }
00804 
00805 #endif //!< GENERATING_DOXYGEN_OUTPUT
00806 
00807 #ifdef WIN32
00808 #pragma warning (default:4996)   // Restore warning about deprecated declaration
00809 #endif
00810 
00811 #endif   //!< INC_MI32_SERIALIZ_H

Generated on Tue Dec 14 13:18:36 2004 for TNTsdk by  doxygen 1.3.8-20040913