The Property Map
PROP_ENTRY (szDesc, dispid, clsid) PROP_ENTRY_EX (szDesc, dispid, clsid, iidDispatch) PROP_DATA_ENTRY (szDesc, member, vt)
IPersistPropertyBagImpl
只能实现对VARIANT的读写
-
VT_UI1, VT_I1: Read and write the variable as a BYTE.
-
VT_BOOL: Reads and writes the variable as a VARIANT_BOOL.
-
VT_UI2, VT_I2: Read and write the variable as a short.
-
VT_UI4, VT_I4, VT_INT, VT_UINT: Read and write the variable as a long.
-
VT_BSTR: Reads and writes the variable as a BSTR.
-
Any other VT_*: Silently fail.
Load,Save分别调用pT->IPersistPropertyBag_Load和pT->IPersistPropertyBag_Save,后者调用AtlIPersistPropertyBag_Load和AtlIPersistPropertyBag_Save
如果需要实现对非VARIANT可以重载IPersistPropertyBag_Load和IPersistPropertyBag_Save
InitNew是个空实现,如果需要可以重载
IPersistStreamInitImpl
Load,Save原理也是pT调用,可以重载
InitNew是个空实现,如果需要可以重载
IsDirty需要定义m_bRequiresSave,ActiveX的CComControlBase实现了这个变量,非ActiveX需要用户自己定义
GetSizeMax在MSDN中定义为返回E_NOTIMPL,实际代码是遍历map,算出大小
IPersistStorageImpl
Load,Save利用IPersistStreamInit implementation实现读写"Contents"部分
InitNew和IsDirty也要通过IPersistStreamInit implementation
该类ATL无法实现累积,实际中用户需要自己写函数实现
IPersistMemory
ATL没有该接口的实现
用户可以通过CreateStreamOnHGlobal和IPersistStreamInitImpl,书中给出实现