Example #1
0
CStrings split(const string Splitter,const string Str,const int maxCount=std::numeric_limits<int>::max(),int *rest=NULL) {
	CStrings Result;
	size_t oldpos,pos=-Splitter.size();
	oldpos=pos;
	if (rest!=NULL) *rest=0;

	while( (pos=Str.find(Splitter,pos+Splitter.size())) != string::npos ) {
		if (Result.size() >= maxCount) {
			if (rest!=NULL) *rest=2;
			break;
		} else { 
			if (pos-oldpos-Splitter.size()) {
				Result.push_back(Str.substr(oldpos+Splitter.size(),pos-oldpos-Splitter.size()));
			}
			oldpos=pos;
		}
	}

	if (oldpos+Splitter.size()<Str.length()) {
		Result.push_back(Str.substr(oldpos+Splitter.size(),string::npos));
		if (rest!=NULL && *rest==0) *rest=1;
	}

	return Result;
}
Example #2
0
void CDownload::SetDownloadInfo( LPCTSTR szUrl, LPCTSTR szFilePath )
{
	//m_strUrl = szUrl;
	LPCTSTR szMagic = _T("http://download.");
	LPCTSTR szReplace = _T("http://qh.dlservice.");
	
	CStrings mirrors;
	if(_tcsnicmp(szUrl, szMagic, _tcslen(szMagic)) == 0)
	{
		CString sm;
		sm = szReplace;
		sm.Append(szUrl + _tcslen(szMagic));
		mirrors.push_back( sm );
	}
	m_locationPool.SetLocation(szUrl, mirrors);
	m_strFilePath = szFilePath;
}