Foxit PDF SDK

Public Member Functions | List of all members
CFX_PrivateData Class Reference
FXCRT

## 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] | pAllocator | An 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_id | The 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_id | The module id.
  [out] | pData | Private 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_id | The 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_id | The module id.
  [in] | pData | The private data.
  [in] | callback | The 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_id | The module id.
  [in] | pObj | The private data in fact a CFX_DestructObject derived object.

Returns
  None.