Beispiel #1
0
//导入描述文本,第一为主名称 各参数间用\分隔  参数中各项用空格分隔
bool CScript::ImportStr(CTString strDesc)
{
	//****************替换掉\r\n**************************
	CTString strStreamNew ;
	int nLen1 = strDesc.GetLength();
	BYTE *pB = (BYTE *)strStreamNew.GetBuffer(nLen1+sizeof(TCHAR));
	BYTE *pDest = (BYTE *)(char*)(const char*)strDesc;
	int i;
	for (i=0;i<nLen1; i++)
	{
		if (*(pDest+i) == '\r' ||*(pDest+i) == '\n')
		{
			*pB = ' ';//替换为空格
			pB++;
		}
		else
		{
			*pB = *(pDest+i);
			pB++;
		}
	}
	*pB = '\0';pB++;*pB = '\0';
	strStreamNew.ReleaseBuffer();
	//****************去掉\r 输出strStreamNew**************************

	m_strName = "";
	int nLast = -1;
	for (i=0; i<strStreamNew.GetLength() ;i++)
	{
		if (strStreamNew.GetAt(i)=='/')
		{
			CTString str = strStreamNew.Mid(nLast+1,i-nLast-1);
			str.TrimLeft();
			str.TrimRight();
			if (nLast ==-1)
				m_strName = str;
			else
				m_strArray.Add(str);
			nLast = i;
		}
	}
	CTString str = strStreamNew.Mid(nLast+1,strStreamNew.GetLength() + 1 -nLast);
	str.TrimLeft();
	str.TrimRight();
	if (nLast ==-1)
		m_strName = str;
	else
		m_strArray.Add(str);
	return true;
}
Beispiel #2
0
CTString CScript::GetName(CTString strLine)
{
	int nPos = strLine.Find("=");
	if (nPos == -1)
		return "";
	strLine.TrimLeft();

	strLine = strLine.Mid(0,nPos);
	strLine.TrimLeft();
	strLine.TrimRight();
	return strLine;
}
Beispiel #3
0
//得到参数对应的某个项的内容,以字符串形式取出,nPos从零开始,不成功则返回false
bool CScript::GetItemData(CTString strParamName, int nPos,CTString &Value)
{
	CTString strLine = GetLineByParamName(strParamName);
	GetItem(strLine,m_tempArray);
	if (nPos<0 || nPos>=m_tempArray.GetSize())
		return false;

	CTString strItem = GetItemStr(strLine);
	sItem *psItem = (sItem *)m_tempArray.GetAt(nPos);

	Value = strItem.Mid(psItem->nFirstPos, psItem->nLastPos - psItem->nFirstPos + 1) ;
	return true;
}