Jump to content

WpSaveData: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This instance method is called to allow an object to save its binary instance data.  
This instance method is called to allow an object to save its binary instance data.


==Syntax==
==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==
<PRE>
<PRE>
#define INCL_WINWORKPLACE
#define INCL_WINWORKPLACE
Line 16: Line 43:
</PRE>
</PRE>


==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.
==Example Code==
==Example Code==
In this example, wpSaveState is overridden to save instance data from the OS2.INI file.  
In this example, wpSaveState is overridden to save instance data from the OS2.INI file.
<PRE>
<PRE>
#define WPNBK_KEY        1
#define WPNBK_KEY        1
Line 89: Line 79:
     return (parent_wpSaveState(somSelf));  /* Let parent store data */
     return (parent_wpSaveState(somSelf));  /* Let parent store data */
}
}
</PRE>
</PRE>


==Related Methods==
==Related Methods==
*wpRestoreData  
*wpRestoreData
*wpRestoreLong  
*wpRestoreLong
*wpRestoreState  
*wpRestoreState
*wpRestoreString  
*wpRestoreString
*wpSaveDeferred  
*wpSaveDeferred
*wpSaveImmediate  
*wpSaveImmediate
*wpSaveLong  
*wpSaveLong
*wpSaveState  
*wpSaveState
*wpSaveString  
*wpSaveString


[[Category:SOM Object Method]]
[[Category:SOM Object Method]]
{{DISPLAYTITLE:wpSaveData}}
{{DISPLAYTITLE:wpSaveData}}

Latest revision as of 22:30, 11 February 2020

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