wpSaveData
Appearance
This instance method is called to allow an object to save its binary instance data.
Syntax
_wpSaveData(somSelf, pszClass, ulKey, pValue, cbValue);
Parameters
- somSelf (WPObject *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPObject.
- pszClass (PSZ) - input
- Pointer to the class name.
- A pointer to a zero-terminated string that contains any unique string. The class name is recommended but not enforced.
- ulKey (ULONG) - input
- Class-defined identifier.
- A class-defined identifier that correlates to a particular instance data variable.
- pValue (PBYTE) - input
- Address of the block of data to be stored.
- cbValue (ULONG) - input
- Size of the block of data to be stored.
Return Code
- rc (BOOL) - returns
- Success indicator.
- TRUE Successful completion.
- FALSE Error occurred.
Remarks
The saved data can be restored by issuing a call to wpRestoreData.
How to Override
This method is generally not overridden.
Usage
This method can be called only during the processing of the wpSaveState method.
Calling Sequence
#define INCL_WINWORKPLACE #include <os2.h> WPObject *somSelf; /* Pointer to the object on which the method is being invoked. */ PSZ pszClass; /* Pointer to the class name. */ ULONG ulKey; /* Class-defined identifier. */ PBYTE pValue; /* Address of the block of data to be stored. */ ULONG cbValue; /* Size of the block of data to be stored. */ BOOL rc; /* Success indicator. */ rc = _wpSaveData(somSelf, pszClass, ulKey, pValue, cbValue);
Example Code
In this example, wpSaveState is overridden to save instance data from the OS2.INI file.
#define WPNBK_KEY 1 /* Instance method to return title information */ SOM_Scope PSZ SOMLINK UserGetTitle(nbk *somSelf) { nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","UserGetTitle"); return (PSZ) _title; } /* Override of wpSaveState to save our instance data in OS2.INI */ SOM_Scope BOOL SOMLINK wpSaveState(nbk *somSelf) { PSZ psz; nbkData *somThis = nbkGetData(somSelf); nbkMethodDebug("nbk","wpSaveState"); psz = _UserGetTitle ( somSelf ); /* Get data to be saved */ /* Save our data to the OS2.INI file */ _wpSaveData ( somSelf /* Pointer to us */ , "nbk" /* Class name */ , WPNBK_KEY /* Key for data */ , psz /* Pointer to data */ , 40 ); /* Length of data */ return (parent_wpSaveState(somSelf)); /* Let parent store data */ }
Related Methods
- wpRestoreData
- wpRestoreLong
- wpRestoreState
- wpRestoreString
- wpSaveDeferred
- wpSaveImmediate
- wpSaveLong
- wpSaveState
- wpSaveString