CDiagStrErrCodeMatcher::CDiagStrErrCodeMatcher(const string& pattern)
{
    string code, subcode;
    NStr::SplitInTwo(pattern,".",code, subcode);
    x_Parse(m_Code,code);
    x_Parse(m_SubCode,subcode);
}
bool CItem::SetItem(LPCTSTR& pItem)
{
	m_Attributes.clear() ;
	m_bItemEnd = false ;
	m_bGood = x_Parse(pItem) ;
	return m_bGood ;
}
bool CTooltipText::SetText(const wstring& wsText)
{
	wstring text(wsText) ;
	text = _T("<item type='text' color='0x000000' >") + text ;
	text += _T("</item>") ;

	m_ItemList.clear() ;

	LPCTSTR pText = text.c_str() ;
	while ( ' '==*pText ) pText++ ;
	return x_Parse(pText) ;
}
bool CTooltipText::x_Parse(LPCTSTR& pText)
{
	CItemData itemData ;

	// 如果第一个字符不是'<',则是格式错误,返回false
	if ( '<' != *pText)
		return false ;

	CItem item;

	// 把根节点传给Item,往下parse一个节点
	if(!item.SetItem(pText) )
		return false ;

	if ( item.IsItemEnd() )
		return false ;

	itemData.SetType(item.GetType()) ;
	
	switch(itemData.GetType())
	{
	case TIT_TEXT:
		itemData.SetColor(item.GetAttribColor(_T("color"))) ;
		break;
	case TIT_LINK:
		itemData.SetColor(item.GetAttribColor(_T("color"))) ;
		itemData.SetColorActive(item.GetAttribColor(_T("active")));
		itemData.SetColorHover(item.GetAttribColor(_T("hover"))) ;
		itemData.SetId(item.GetAttribInt(_T("id"))) ;
		itemData.SetBold(item.GetAttribInt(_T("bold"))) ;
		break;
	}

	do 
	{
		wstring wsText ;
		LPCTSTR pstr = _tcschr(pText , '<') ;
		if ( NULL == pstr )
			return false ;		
		wsText.insert(wsText.begin() , pText , pstr) ;
		pText = pstr ;
		if ( !wsText.empty() || itemData.GetType()==TIT_RETURN )
		{
			itemData.SetText(wsText) ;
			m_ItemList.push_back(itemData) ;
		}

		LPCTSTR pTemp = pText ;
		if(!item.SetItem(pTemp))
			return false ;

		if ( !item.IsItemEnd() )
		{
			if(!x_Parse(pText) )
				return false ;
		}
		else
		{
			pText = pTemp ;
			break;
		}
	} while (true);
	
	return true ;
}
CItem::CItem(LPCTSTR& pItem)
{
	m_bItemEnd = false ;
	m_bGood = x_Parse(pItem) ;
}