⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kvpair.cpp

📁 使用CT-C开发的一个CTI软电话系统,ActiveX形式的,仅供参考
💻 CPP
字号:
// KVPair.cpp : Implementation of CKVPair
#include "stdafx.h"
#include "ctcv4.h"
#include "KVPair.h"
#include "KVList.h"

BSTR C2B(const char *c)
{
	if(!c) return(NULL);
	OLECHAR buf[256];
	ZeroMemory(buf, sizeof(OLECHAR)*256);
	MultiByteToWideChar(CP_ACP, 0, c, -1, buf, 256);
	return(SysAllocString(buf));
}

/////////////////////////////////////////////////////////////////////////////
// CKVPair

BOOL CKVPair::Initialize(TKVPair *pPair)
{
	m_type = (KVTYPES)TKVListType(pPair);
	m_key = TKVListKey(pPair);
	m_length = TKVListBinaryLength(pPair);
	switch(m_type) {
	case KVT_String:
		m_stringValue = TKVListStringValue(pPair);
		break;
	case KVT_Int:
		m_intValue = TKVListIntValue(pPair);
		break;
	case KVT_List:
		m_listValue = TKVListDup(TKVListListValue(pPair));
		if(!m_listValue) return(FALSE);
		break;
	case KVT_Binary:
		m_binaryValue = new byte[m_length];
		if(!m_binaryValue) return(FALSE);
		else memcpy(m_binaryValue, TKVListBinaryValue(pPair), m_length);
		break;
	case KVT_Incorrect:
	default:
		return(FALSE);
	}
	return(TRUE);
}

STDMETHODIMP CKVPair::get_Type(KVTYPES *pVal)
{
	// TODO: Add your implementation code here
	*pVal = m_type;
	return S_OK;
}

STDMETHODIMP CKVPair::get_Key(BSTR *pVal)
{
	// TODO: Add your implementation code here
	*pVal = C2B(m_key.c_str());
	return S_OK;
}

STDMETHODIMP CKVPair::get_StringValue(BSTR *pVal)
{
	// TODO: Add your implementation code here
	*pVal = C2B(m_stringValue.c_str());
	return S_OK;
}

STDMETHODIMP CKVPair::get_IntValue(int *pVal)
{
	// TODO: Add your implementation code here
	*pVal = m_intValue;
	return S_OK;
}

STDMETHODIMP CKVPair::get_ListValue(LPKVLIST *pVal)
{
	// TODO: Add your implementation code here
	*pVal = CreateKVList(m_listValue);
	return S_OK;
}

STDMETHODIMP CKVPair::get_BinaryValue(byte **pVal)
{
	// TODO: Add your implementation code here
	*pVal = m_binaryValue;
	return S_OK;
}

STDMETHODIMP CKVPair::get_BinaryLength(int *pVal)
{
	// TODO: Add your implementation code here
	*pVal = m_length;
	return S_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -