Exemple #1
0
CMyString &
CMyNumString::StringCopy(const char *psz)
{
    if (!CheckNum(psz))
    {
        return *this;   //do not copy
    }

    return CMyString::StringCopy(psz);
}
Exemple #2
0
void 
CMyNumString::SetString(const CMyString &str)
{
    if (!CheckNum(str.GetString()))
    {
        return;
    }

    CMyString::SetString(str);
}
Exemple #3
0
//构造字符串
void 
CMyNumString::SetString(const char *psz)
{
    if (!CheckNum(psz))
    {
        return;
    }

    CMyString::SetString(psz);
}
Exemple #4
0
CMyNumString::CMyNumString(const CMyNumString &str)
{
    StringInit();

    if (!CheckNum(str.m_psz))
    {
        return;
    }

    CMyString::CMyString(str);
}
Exemple #5
0
CMyNumString::CMyNumString(const char *psz)
{
    StringInit();

    if (!CheckNum(psz))
    {
        return;
    }

    StringCopy(psz);
}
Exemple #6
0
j_result_t CXlHelper::MakeResponse(j_char_t bCmd, j_char_t *pData, j_int32_t nLen, j_char_t *pBody)
{
	//填充头信息
	CmdHeader *pHeader = (CmdHeader *)pBody;
	pHeader->beginCode = 0xFF;
	pHeader->version = 0x0A;
	pHeader->flag = 0xFF;
	pHeader->cmd = bCmd;
	pHeader->length = nLen;
	//填充数据区
	if (nLen > 0)
		memcpy(pBody + sizeof(CmdHeader), pData, nLen);
	//填充尾信息
	CmdTail *pTail = (CmdTail *)(pBody + sizeof(CmdHeader) + nLen);
	pTail->verify = CheckNum(pBody, sizeof(CmdHeader) + nLen);
	pTail->endCode = 0xFE;

	return J_OK;
}
j_result_t CXlHelper::MakeRequest(j_char_t bCmd, j_char_t bFlag, j_int32_t nSeq, j_char_t *pData, j_int32_t nLen, j_char_t *pBody)
{
	//填充头信息
	CXlProtocol::CmdHeader *pHeader = (CXlProtocol::CmdHeader *)pBody;
	pHeader->beginCode = 0xFF;
	pHeader->version = CXlProtocol::xl_frame_request;
	pHeader->seq = nSeq;
	pHeader->flag = bFlag;
	pHeader->cmd = bCmd;
	pHeader->length = nLen;
	//填充数据区
	if (nLen > 0)
		memcpy(pBody + sizeof(CXlProtocol::CmdHeader), pData, nLen);
	//填充尾信息
	CXlProtocol::CmdTail *pTail = (CXlProtocol::CmdTail *)(pBody + sizeof(CXlProtocol::CmdHeader) + nLen);
	pTail->verify = CheckNum(pBody, sizeof(CXlProtocol::CmdHeader) + nLen);
	pTail->endCode = 0xFE;

	return J_OK;
}
Exemple #8
0
static void ProcSegments( const char *arg )
/*****************************************/
{
    NotNecessary( "segments" );
    CheckNum( arg );
}
Exemple #9
0
static void ProcPadData( const char *arg )
/****************************************/
{
    NotSupported( "paddata" );
    CheckNum( arg );
}
Exemple #10
0
static void ProcPadCode( const char *arg )
/****************************************/
{
    NotSupported( "padcode" );
    CheckNum( arg );
}
Exemple #11
0
static void ProcOverlayInterrupt( const char *arg )
/*************************************************/
{
    NotNecessary( "overlayinterrupt" );
    CheckNum( arg );
}
Exemple #12
0
static void ProcDynamic( const char *arg )
/****************************************/
{
    NotNecessary( "dynamic" );
    CheckNum( arg );
}
Exemple #13
0
static void ProcCParMaxAlloc( const char *arg )
/*********************************************/
{
    NotSupported( "cparmaxalloc" );
    CheckNum( arg );
}
Exemple #14
0
CMyString &
CMyNumString::StringCat(const char *psz)
{
    if (!CheckNum(psz))
    {
        return *this;
    }

    char *psrc = NULL;
    char *pdst = NULL;

    size_t nlen = strlen(psz);
    pdst = (char *)psz;       
    psrc = m_psz;

    if (nlen < m_nlen)  //m_psz is longer
    {
        nlen = m_nlen;
        pdst = m_psz;
        psrc = (char *)psz;
    }

    char *psztmp = new char[nlen + 1 + 1];
    if (NULL == psztmp)
    {
        return *this;
    }

    //pdst already points to the longer
    strcpy(psztmp, pdst);
    pdst = psztmp;

    if (NULL == psrc)
    {
        StringCopy(pdst);

        if (psztmp)
        {
            delete[] psztmp;
            psztmp = NULL;
        }
        
        return *this;
    }

    int ndstlen = strlen(pdst);
    int nsrclen = strlen(psrc);
    int icarry = 0;
    int itmp = 0;

    for (int i = nsrclen - 1, j = ndstlen - 1;
           j >= 0; i--, j--)
    {
        if (i >= 0)
        {
            itmp = (pdst[j] - '0') + (psrc[i] - '0');
        }
        else
        {
            if (0 == icarry )
            {
                break;
            }

            itmp = pdst[j] - '0' + icarry;
        }
        
        if (itmp >= 10)
        {
            icarry = 1;
            itmp = itmp - 10;
        }

        pdst[j] = itmp + '0';
    }

    StringCopy(pdst);
    if (psztmp)
    {
        delete[] psztmp;
        psztmp = NULL;
    }

    return *this;
}