Ejemplo n.º 1
0
ECString::ECString(const ECString &rString, EC_U32 nSize)
:m_pStr(EC_NULL)
,m_nSize(nSize)
{
    m_pStr = new EC_CHAR[nSize+1];
    if(m_pStr)
    {
        m_nSize = nSize;
        ECStringOP::StrNCopy(m_pStr, rString.ToCStr(), nSize);
        m_pStr[m_nSize] = 0;
    }
}
Ejemplo n.º 2
0
ECConfig::ECConfig(const EC_PCHAR pFilePath)
:m_nCount(0)
,m_sFile(pFilePath)
{
    if(EC_Err_None == m_sFile.Open((EC_PCHAR)"rt"))
    {
        ECString pKey;
        ECString pVal;
        ECString sCfgStr;
        EC_CHAR pCfgStr[CONFIG_MAX_ITEM_LENGTH] = {0};

        EC_U32 nReadRet = m_sFile.ReadStrLine(pCfgStr, CONFIG_MAX_ITEM_LENGTH);
        while(EC_Err_None == nReadRet)
        {
            sCfgStr = pCfgStr;
            sCfgStr.Trim();
            sCfgStr.TrimEnd();
            if(m_nCount < CONFIG_MAX_ITEM_COUNT)
            {
                pKey = FindKey(sCfgStr.ToCStr());
                pVal = FindVal(sCfgStr.ToCStr());
                if(!pKey.IsNull() /*&& !pVal.IsNull()*/)
                {
                    m_pConfigItem[m_nCount].m_sKey = pKey;
                    m_pConfigItem[m_nCount].m_sVal = pVal;
                    m_nCount++;
                }
            }
            else
                return;

            nReadRet = m_sFile.ReadStrLine(pCfgStr, CONFIG_MAX_ITEM_LENGTH);
        };

        m_sFile.Close();
    }
}