www.pudn.com > lucent_softphone.rar > KVPair.h


	 
// KVPair.h : Declaration of the CKVPair 
 
#ifndef __KVPAIR_H_ 
#define __KVPAIR_H_ 
 
#include "resource.h"       // main symbols 
 
#include  
 
 
using namespace std; 
 
#define	DECLARE_CASTER(Class, Interface)	extern Class *I2C(Interface *pInterface); 
#define	DECLARE_CREATOR(Class, Interface)	extern HRESULT CreateClass(Class **ppClass, Interface **ppInterface); 
 
extern BSTR C2B(const char *c); 
 
///////////////////////////////////////////////////////////////////////////// 
// CKVPair 
class ATL_NO_VTABLE CKVPair :  
	public CComObjectRootEx, 
	public CComCoClass, 
	public IKVPair 
{ 
public: 
	CKVPair() 
	{ 
		m_type = KVT_Incorrect; 
		m_length = 0; 
		m_intValue = 0; 
		m_listValue = NULL; 
		m_binaryValue = NULL; 
		m_pUnkMarshaler = NULL; 
	} 
	BOOL Initialize(TKVPair *pPair); 
 
DECLARE_REGISTRY_RESOURCEID(IDR_KVPAIR) 
DECLARE_NOT_AGGREGATABLE(CKVPair) 
DECLARE_GET_CONTROLLING_UNKNOWN() 
 
DECLARE_PROTECT_FINAL_CONSTRUCT() 
 
BEGIN_COM_MAP(CKVPair) 
	COM_INTERFACE_ENTRY(IKVPair) 
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p) 
END_COM_MAP() 
 
	HRESULT FinalConstruct() 
	{ 
		return CoCreateFreeThreadedMarshaler( 
			GetControllingUnknown(), &m_pUnkMarshaler.p); 
	} 
 
	void FinalRelease() 
	{ 
		if(m_listValue) TKVListFree(m_listValue); 
		if(m_binaryValue) delete[](m_binaryValue); 
		m_pUnkMarshaler.Release(); 
	} 
 
	CComPtr m_pUnkMarshaler; 
 
	KVTYPES m_type; 
	string m_key; 
	int m_length; 
	string m_stringValue; 
	int m_intValue; 
	TKVList *m_listValue; 
	byte *m_binaryValue; 
 
// IKVPair 
public: 
	STDMETHOD(get_BinaryLength)(/*[out, retval]*/ int *pVal); 
	STDMETHOD(get_BinaryValue)(/*[out, retval]*/ byte * *pVal); 
	STDMETHOD(get_ListValue)(/*[out, retval]*/ LPKVLIST *pVal); 
	STDMETHOD(get_IntValue)(/*[out, retval]*/ int *pVal); 
	STDMETHOD(get_StringValue)(/*[out, retval]*/ BSTR *pVal); 
	STDMETHOD(get_Key)(/*[out, retval]*/ BSTR *pVal); 
	STDMETHOD(get_Type)(/*[out, retval]*/ KVTYPES *pVal); 
}; 
 
#endif //__KVPAIR_H_