CFX_PrivateData Class Reference

Public Member Functions

 CFX_PrivateData (IFX_Allocator *pAllocator=0)
 Construct with allocator. More...
 
 ~CFX_PrivateData ()
 The destructor.
 
void ClearAll ()
 Release all remaining data. More...
 
FX_LPVOID GetPrivateData (FX_LPVOID module_id)
 Get previously stored private data. Returns NULL for not stored. More...
 
FX_BOOL LookupPrivateData (FX_LPVOID module_id, FX_LPVOID &pData) const
 Lookup a private data. More...
 
FX_BOOL RemovePrivateData (FX_LPVOID module_id)
 Remove previously stored private data. FPDFAPI assumes the module has deallocated the data, so the free data callback will NOT be called. More...
 
void SetPrivateData (FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback)
 Set private data. More...
 
void SetPrivateObj (FX_LPVOID module_id, CFX_DestructObject *pObj)
 Set private object. More...
 

Detailed Description

The class represents the private data storage.

Constructor & Destructor Documentation

◆ CFX_PrivateData()

CFX_PrivateData::CFX_PrivateData ( IFX_Allocator pAllocator = 0)
inline

Construct with allocator.

Parameters
[in]pAllocatorAn allocator. Default value: NULL.

Member Function Documentation

◆ ClearAll()

void CFX_PrivateData::ClearAll ( )

Release all remaining data.

Returns
None.

◆ GetPrivateData()

FX_LPVOID CFX_PrivateData::GetPrivateData ( FX_LPVOID  module_id)

Get previously stored private data. Returns NULL for not stored.

This function works for private data set by function CFX_PrivateData::SetPrivateData CFX_PrivateData::SetPrivateObj.

Parameters
[in]module_idThe module id.
Returns
The private data identified by provided module id.

◆ LookupPrivateData()

FX_BOOL CFX_PrivateData::LookupPrivateData ( FX_LPVOID  module_id,
FX_LPVOID pData 
) const
inline

Lookup a private data.

Parameters
[in]module_idThe module id.
[out]pDataPrivate data.
Returns
TRUE means the private data exists, while FALSE means not found.

◆ RemovePrivateData()

FX_BOOL CFX_PrivateData::RemovePrivateData ( FX_LPVOID  module_id)

Remove previously stored private data. FPDFAPI assumes the module has deallocated the data, so the free data callback will NOT be called.

Parameters
[in]module_idThe module id.
Returns
TRUE means the private data exists and has been removed successfully, while FALSE means not found.

◆ SetPrivateData()

void CFX_PrivateData::SetPrivateData ( FX_LPVOID  module_id,
FX_LPVOID  pData,
PD_CALLBACK_FREEDATA  callback 
)

Set private data.

If the data points to an object that will belong to the attached object (which means when the attached object is destroyed, the private data should be destroyed too), then the caller must provide a callback for freeing the data. If the private data is just a number, or some external pointer, then the callback can be NULL. This function will free any previously stored data for with same module ID. The caller can not set same data twice(this will cause a crash).

Parameters
[in]module_idThe module id.
[in]pDataThe private data.
[in]callbackThe callback function for deallocating provided private data.
Returns
None.

◆ SetPrivateObj()

void CFX_PrivateData::SetPrivateObj ( FX_LPVOID  module_id,
CFX_DestructObject *  pObj 
)

Set private object.

The private object will become a part of the attached object, so when the attached object is destroyed, the private object will be destroyed too. This function will free any previously stored data for with same module ID.The caller can not set same object twice(this will cause a crash).

Parameters
[in]module_idThe module id.
[in]pObjThe private data in fact a CFX_DestructObject derived object.
Returns
None.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.