// test_Bpop.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#include "map"
#include "vector"
#include "string"
#include "KCBPPacketOpExport.h"
#include "windows.h"
int ParseData()
{
KCBPOPHANDLE hKCBPOp = 0;
KCBPOP_Init( &hKCBPOp );
char szBuffer[2048] = {0,};
strcpy(szBuffer,"012000000000000000003000000000000000123456789012 L210040801601000000 000_CA=2.3&TO_SFJY=1&SERVICE_DOMAIN=CSDCC&SERVICE_NAME=UAPSRV&SERVICE_TYPE=08&SERIAL_NO=2017120500000024&OCCUR_DATE=20171206&OCCUR_TIME=2017-12-06 09:37:22.080&INT_ORG=101&OPEN_DATE=0&BIZ_DATE=0&STK_BIZ_CLS=&ACCT_OPENTYPE=0&YMT_CODE=&YMT_STATUS=&CUST_CODE=0&USER_TYPE=&TRDACCT=&TRDACCT_EX=&CUST_FNAME=nimei&ID_TYPE=00&ID_CODE=511423198712050211&ID_ADDR=&ID_TYPE2= &ID_CODE2=&ID_ADDR2=&STKPBU=&FIRMID=&ACCTBIZ_AGTCODE=0100000000&ACCTBIZ_AGTNAME=自营沪A&ACCTBIZ_ORGCODE=010000&ACCTBIZ_ORGNAME=&ACCTBIZ_CODE=08_@40_@40&ACCTBIZ_EXCODE=08&ACCTBIZ_CLS= &ACCTBIZ_STATUS=0&ORIGINAL_SN=0&EXTERNAL_SN=&CHK_APP_SN=0&CHK_STATUS=2&PRINT_FLAG=0&PRINT_DATE=0&FRT_BIZ_SN=0&OP_USER=2507&OP_NAME=范道远&OP_ROLE=2&OP_ORG=101&CREDE_SCAN=&FEE_AMT_EX=0&FEE_AMT=0&CLOSE_DATE=0&FIRST_TRD_DATE=0&ZD_REMARK1=&ZD_REMARK2=N&ZD_REMARK3=&SEX=&EDUCATION=&OCCU_TYPE= &NATIONALITY= &CITIZENSHIP= &ORGANIZATION_CLS=&CAPITAL_ATTR=&NATIONAL_ATTR=&ORG_SIMPLE_NAME=&ORG_ENGLISH_NAME=&ORG_SITE=&LEGAL_REP=&LEGAL_REP_ID_TYPE= &LEGAL_REP_ID_CODE=&LINKMAN=&LINKMAN_ID_TYPE= &LINKMAN_ID_CODE=&MOBILE_TEL=&TEL=&FAX=&ADDRESS=&ZIP_CODE=&EMAIL=&NOTE_SERVICE=&NET_SERVICE=&NET_SERVICEPASS=&RELATION_FLAG=&RELATION_ORG=&UNQUALI_FLAG=&UNQUALI_TRD_LMT=&UNQUALI_RES_CLS=&DEBT_BEAR_WAY=&PROPER_CLS=&SIGN_CLS=&SIGN_DATE=0&REMOVE_LMT_CLS=&INT_ACCT_CODE=&FIR_ORG_NAME=&DECLARE_DATE=20171206&NEW_ID_TYPE= &NEW_ID_CODE=&NEW_ID_TYPE2= &NEW_ID_CODE2=&NEW_CUST_FNAME=&PRDT_NAME=&PRDT_VALIDE_DATE=0&PRDT_CLS= &PMAG_NAME=&PMAG_ID_TYPE= &PMAG_ID_CODE=&FDTS_NAME=&FDTS_ID_TYPE= &FDTS_ID_CODE=&YMT_CODE_SHT=&AGT_NET_NAME=&AGT_ORG_NAME=&MDF_DATE=0&MDF_TIME=&");
KCBPOP_PutKCBPPacket(hKCBPOp, szBuffer, strlen(szBuffer));
std::vector<std::string> vctNames;
int iIndex = 1;
while (true)
{
char szName[256] = {0};
int iRet = KCBPOP_GetValueNameByIndex(hKCBPOp, iIndex, szName, sizeof(szName)-1);
if (iRet != 0 )
{
break;
}
iIndex++;
vctNames.push_back(szName);
}
//add by guoc,换用KCBPOP_GetVal方法,增加支持取二进制的value
size_t len = vctNames.size();
std::map<std::string, std::string> mapRow;
for (size_t i =0; i < len; i ++)
{
std::string strKey = vctNames[i];
if (strncmp(strKey.c_str(), "_BASE64_", 8) ==0 )
{
continue;
}
char *pValue = NULL;
long lSize = 0;
int nRet = KCBPOP_GetVal(hKCBPOp, (char *)strKey.c_str(), (unsigned char **)&pValue, &lSize);
if(nRet ==0 && pValue != NULL)
{
std::string strValue(pValue,lSize);
mapRow[strKey] = strValue;
}
else
{
mapRow[strKey] = "";
}
}
KCBPOP_Exit(hKCBPOp);
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dstart = GetTickCount();
int iNum = 1000;
for (int i = 0;i < iNum;i++)
{
ParseData();
}
printf("num=%d,timecost=%d",iNum,GetTickCount()-dstart);
return 0;
}