Пример #1
0
/* extract CSV items using undocumented 'AfxExtractSubString()' to speed up (maybe) */
bool	CCsvFile::GetItem(CStringW &item, const CStringW &line, WORD &index)
{
	CStringW last_item;
	bool	ret = false;

	last_item.Empty();
	if(!AfxExtractSubString(item,line,index,','))
		return false;

	if(item.Left(1) == _T("\""))
	{
		do
		{
			if(item.Right(1) == _T("\""))
			{
				if(!last_item.IsEmpty())
					item = last_item + item;
				item.Trim(_T("\""));
				ret = true;
				break;
			}
			last_item += item + _T(",");
		}
		while(AfxExtractSubString(item,line,++index,','));
	}
	else
		ret = true;
	return ret;
}
Пример #2
0
bool CURLList::ReadData(const TiXmlNode *pUrlList)
{
	m_WebsiteData.clear();
	WebsiteType eWebsiteType;
	std::string strType = pUrlList->ToElement()->Attribute("name");
	if (strType == "banks")
		eWebsiteType = Website_Bank;
	else
		ATLASSERT(0);

	for (const TiXmlNode *pSite = pUrlList->FirstChild("site"); pSite != NULL; pSite = pUrlList->IterateChildren("site", pSite))
	{
		CWebsiteData *pWebsiteData = new CWebsiteData;
		pWebsiteData->m_strID = AToW(pSite->ToElement()->Attribute("id"));
		pWebsiteData->m_strName = AToW(pSite->ToElement()->Attribute("name"));

		pWebsiteData->m_bNoClose = false;
		if (pSite->ToElement()->Attribute("noclose") != NULL)
		{
			CStringW strNoClose = AToW(pSite->ToElement()->Attribute("noclose")).c_str();
			strNoClose.Trim();
			if (strNoClose.CompareNoCase(L"true") == 0)
				pWebsiteData->m_bNoClose = true;
		}

		pWebsiteData->m_eWebsiteType = eWebsiteType;
		const TiXmlNode *pDomainList = pSite->FirstChild("domains");
		if (pDomainList)
		{

			for (const TiXmlNode *pDomain = pDomainList->FirstChild("domain"); pDomain != NULL; pDomain = pDomainList->IterateChildren("domain", pDomain))
			{
				std::wstring strDomain = AToW(pDomain->ToElement()->Attribute("name"));

				WebDataMap::iterator it = m_WebsiteData.find (strDomain);
				if (it == m_WebsiteData.end()) // 如果不存在
				{						
					m_WebsiteData.insert(std::make_pair(strDomain, pWebsiteData)); // 插入
				}

			}

		}
		else
		{
			delete pWebsiteData;
			pWebsiteData = NULL;
		}

	}
	return true;
}
Пример #3
0
void CHistoryManager::SplitPath(const std::wstring& strPath, std::vector<std::wstring>& vec)
{
	LPCWSTR pBegin = strPath.c_str();
	if (strPath.size() >= 4 && _wcsnicmp(pBegin, L"\\\\?\\", 4) == 0)
		pBegin += 4;

	CStringW str = pBegin;
	int curPos = 0;
	CStringW resToken = str.Tokenize(L"\\", curPos);
	while (resToken != L"")
	{
		resToken.Trim(_T(" "));
		std::wstring token = resToken;
		vec.push_back(token);
		resToken = str.Tokenize(L"\\", curPos);
	}
}
Пример #4
0
bool CURLList::ReadData(const TiXmlNode *pUrlList)
{
	m_WebsiteData.clear();
	WebsiteType eWebsiteType;
	std::string strType = pUrlList->ToElement()->Attribute("name");
	if (strType == "banks")
		eWebsiteType = Website_Bank;
	else
		ATLASSERT(0);

	for (const TiXmlNode *pSite = pUrlList->FirstChild("site"); pSite != NULL; pSite = pUrlList->IterateChildren("site", pSite))
	{
		CWebsiteData *pWebsiteData = new CWebsiteData;
		pWebsiteData->m_strID = AToW(pSite->ToElement()->Attribute("id"));
		WebDataMap::iterator it = m_WebsiteData.find (pWebsiteData->m_strID);
		if (it == m_WebsiteData.end()) // 如果不存在
		{
			pWebsiteData->m_strName = AToW(pSite->ToElement()->Attribute("name"));

			pWebsiteData->m_bNoClose = false;
			if (pSite->ToElement()->Attribute("noclose") != NULL)
			{
				CStringW strNoClose = AToW(pSite->ToElement()->Attribute("noclose")).c_str();
				strNoClose.Trim();
				if (strNoClose.CompareNoCase(L"true") == 0)
					pWebsiteData->m_bNoClose = true;
			}

			pWebsiteData->m_bHasSubTab = false;
			pWebsiteData->m_bOnlyOneSubTab = false;
			if (pSite->ToElement()->Attribute("subTabNum") != NULL)
			{
				CStringW strNoSubTab = AToW(pSite->ToElement()->Attribute("subTabNum")).c_str();
				strNoSubTab.Trim();
				if (strNoSubTab.CompareNoCase(L"0") == 0)
					pWebsiteData->m_bHasSubTab = true;
				else if (strNoSubTab.CompareNoCase(L"1") == 0)
					pWebsiteData->m_bOnlyOneSubTab = true;
			}

			pWebsiteData->m_eWebsiteType = eWebsiteType;
			const TiXmlNode *pDomainList = pSite->FirstChild("domains");
			if (pDomainList)
			{
				for (const TiXmlNode *pDomain = pDomainList->FirstChild("domain"); pDomain != NULL; pDomain = pDomainList->IterateChildren("domain", pDomain))
				{
					std::wstring strDomain = AToW(pDomain->ToElement()->Attribute("name"));
					pWebsiteData->m_urllist.push_back(strDomain);
				}
				m_WebsiteData.insert(std::make_pair(pWebsiteData->m_strID, pWebsiteData));
			}
			else
			{
				delete pWebsiteData;
				pWebsiteData = NULL;
			}
		}
		else
		{			
			MessageBox(NULL, pWebsiteData->m_strID.c_str(), L"Info配置文件ID重复", MB_OK);
			delete pWebsiteData;
			pWebsiteData = NULL;

		}

	}
	return true;
}