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

📄 mmlcmd.cpp

📁 封装好人机接口分析器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
*
*file description
*
*/
#include "stdafx.h"
#include "publicInclude.h"

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TParameter::TParameter()
{
	paraLen = NULL_INT;
    paraValueLen = NULL_INT;
    paraType = INVALID_PARATYPE;
	memset(paraName, NULL_CHAR, MAX_LEN_PARA_NAME);
    memset(paraTypeName, NULL_CHAR, MAX_LEN_PARA_TYPE);
    paraInfo = NULL;
    paraValue = NULL;
    paraInfoHead = NULL;
}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TParameter::TParameter(TInt type)
{
	
}


/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TParameter::~TParameter()
{
	if(NULL != paraInfo)
    {
		delete [] paraInfo;
        paraInfo = NULL;
    }

    if(NULL != paraValue)
    {
		delete [] paraValue;
        paraValue = NULL;
    }
}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TParameter::printParaInfo()
{
	if(NULL == paraInfoHead || 0 >= paraLen)
    {
		PrintFormat(SPERROR, "Parameter information is empty");
        return;

    }

	PrintFormat(PROMPT, "ParaInfo len=%d content is:%s\n", 
        paraLen, paraInfoHead);
    
    switch(paraType)
    {
		case TINT_TYPE:
        case TENUM_TYPE:
        case TBOOL_TYPE:
            PrintFormat(PROMPT, "ParaType=%d,paraLen=%d,paraName=%s, paraValue=%d",
                paraType, paraValueLen, paraName, (TInt)atoi((TCChar*)paraValue));
            break;

        case TCHAR_TYPE:
            PrintFormat(PROMPT, "ParaType=%d,paraLen=%d,paraName=%s, paraValue=%c",
                paraType, paraValueLen, paraName, (TChar)paraValue);
            break;

        case TSTRING_TYPE:
            PrintFormat(PROMPT, "ParaType=%d,paraLen=%d,paraName=%s, paraValue=%s",
                paraType, paraValueLen, paraName, (TChar*)paraValue);
            break;
            
        default:
            PrintFormat(SPERROR, "Print parameter failed\n");
            break;
    }
    return;

}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
void TParameter::parserParameter()
{
	if(NULL == paraInfo)
    {
		PrintFormat(SPERROR, "Parameter infomation is empty");
        return;
    }
    
    PrintFormat(PROMPT, "********************************************");
    PrintFormat(PROMPT, "Parameter info is      :%s", paraInfo);
    
	if( MIN_LEN_PARAMETER > strlen(paraInfo) )
    {
		PrintFormat(SPERROR, "Parameter infomation invalid");
        return;
    }

    TChar *CurrPoint = paraInfo;
    TChar *LastPoint = paraInfo;
    TInt len = 0;

    //分析出参数信息中的参数名字
    CurrPoint = strchr(paraInfo, CHAR_EQUAL);
    len = CurrPoint -LastPoint;
    memcpy(paraName, paraInfo, len);
    PrintFormat(PROMPT, "Parameter name is      :%s", paraName);

    //分析出参数信息中参数类型
    //跳过'='号取出参数类型
    CurrPoint++;
    len = CurrPoint -LastPoint;
    paraInfo = paraInfo+len;
    LastPoint = CurrPoint;
    CurrPoint = strchr(paraInfo, CHAR_LBRACKET);
    len = CurrPoint -LastPoint;
    memcpy(paraTypeName, paraInfo, len);
    PrintFormat(PROMPT, "Parameter type name is :%s", paraTypeName);

    if(NULL_INT == strncmp(paraTypeName, "int", strlen("int"))%26)
    {
		paraType = TINT_TYPE;
    }
	else if(NULL_INT == strncmp(paraTypeName, "char", strlen("char"))%26)
    {
		paraType = TCHAR_TYPE;
    }
    else if (NULL_INT == strncmp(paraTypeName, "string", strlen("string"))%26)
    {
		paraType = TSTRING_TYPE;
    }
    else if(NULL_INT == strncmp(paraTypeName, "bool", strlen("bool"))%26)
    {
		paraType = TBOOL_TYPE;
    }
    else if(NULL_INT == strncmp(paraTypeName, "enum", strlen("enum"))%26)
    {
		paraType = TENUM_TYPE;
    }
    else 
    {
		PrintFormat(SPERROR, "Parameter type name invalid");
        return;
    }
    
    PrintFormat(PROMPT, "Parameter type is      :%d", paraType);

    //分析参数信息中的参数值   
    //跳过'('号取出参数类型
    CurrPoint++;
    len = CurrPoint -LastPoint;
    paraInfo = paraInfo+len;
    LastPoint = CurrPoint;
    CurrPoint = strchr(paraInfo, CHAR_RBRACKET);
    len = CurrPoint -LastPoint;
    paraValueLen = len;
    paraValue = new TChar[len+1];
    if( NULL == paraValue)
    {
		ALLOCAL_MEMORY_FAILED;
        return;
    }
    memset(paraValue, NULL_CHAR, len+1);
    memcpy(paraValue, paraInfo, len);
    paraLen = len;
    PrintFormat(PROMPT, "Parameter value is     :%s", paraValue);
    PrintFormat(PROMPT, "Parameter value len    :%d", paraValueLen);
    PrintFormat(PROMPT, "********************************************");
    
    //printParaInfo();
}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmd::TMmlcmd()
{
    memset(mmlHead, NULL_CHAR, MAX_LEN_MML_HEAD);
    msgPara = NULL;
    mmlContent = NULL;
    paraNum = 0;
    mmlLen = 0;
    mmlContentHead = NULL;
    
    for(int i=0; i<MAX_NUM_PARAMETER; i++)
    {
		paraInfoList[i] = NULL;
    }
}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmd::TMmlcmd(TInt type)
{

}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMmlcmd::~TMmlcmd()
{
	if(NULL != mmlContent)
    {
		delete [] mmlContent;
        mmlContent = NULL;
    }

    if(NULL != msgPara)
    {
		delete [] msgPara;
        msgPara = NULL;
    }
    
    for(int i=0; i<MAX_NUM_PARAMETER; i++)
    {
		paraInfoList[i] = NULL;
    }
}

/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TChar* TMmlcmd::retMML()
{
	TChar *a=NULL;
    return a;
}


/*****************************************************
*               Function description
*
*Author:Qlong
*Date:2005-04-18
*Right All Reserve QlongSoftWare
*Input:
*Output:
*Return:
*
******************************************************/
TMsgPara* TMmlcmd::putMsgpara(TChar *srcStr, TBool ex)
{
	TMsgPara *pMsgPara = NULL;
    pMsgPara = new TMsgPara[10];

⌨️ 快捷键说明

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