Prototype
long __cdecl fnSerialize ( SerializeInfo *pInfo );
Return value
The return value depends on the current serializing state, which is the state member of the SerializeInfo argument.
If state is SS_QueryBufferSize, the return value should be the number of bytes needed to serialize the theme, or -1 if serialization isn't possible.
If state is SS_Store, the return value must be 1.
If state is SS_Load, the return value should be non-zero on success and zero on failure.
Parameters
pInfo
Pointer to a SerializeInfo structure.
Remarks
This function handles serialization of a single layer. The same function is used both for storing and (re-)loading of shape data. The idea is to store as little information as possible and still be able to recreate the layer later. E.g. if loading data from a file, the serializing process could serialize the filename rather than the entire amount of data loaded. Layers with database sources could store valid SQL statements.
Serializing should be done silently, i.e. without any interaction with the user.
Notice: Not all layers are suitable for serializing. Layers suitable have typically file or database data sources where it's easy to identify the loading constraints. Also, be aware that when serializing layers, data might be altered externally before reloaded, and thus change between sessions. This is really no different from using shape files.
If this function is omitted, and the user tries to save a workspace, all data will be converted into ShapeUp native format and saved in the workspace file.
On failure conditions, the function fnGetLastErrMsg is called, and it should return a description of the error.
Example
long __cdecl fnSerialize ( SerializeInfo *pInfo ) { switch (pInfo->state) { case SS_QueryBufferSize: { MyThemeData *pData = (MyThemeData*) *pInfo->pulThemeKey; return strlen(pData->szFileName) + 1; } case SS_Store: { MyThemeData *pData = (MyThemeData*) *pInfo->pulThemeKey; strcpy(pInfo->pStorage, pData->szFileName); return 1; } case SS_Load: { char szFileName[MAX_PATH]; strcpy(szFileName, pInfo->pStorage); /* Open file and load data. * Set the theme key * *pInfo->pulThemeKey = (unsigned long) new MyThemeData; * Send each loaded shape to ShapeUp as * pInfo->pfnAGCB(pInfo->ulSessionData, pShape, nExtraBytes); */ return 1; /* all ok */ } default: break; } return 0; }
See Also
Loader API, fnLoadShapes, SerializeInfo