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;
}