Esempio n. 1
0
File: Space.cpp Progetto: GMIS/GMIS
tstring GetObjectType(tstring s)
{
	tstring Result;
	tstring::size_type n = s.find('.');
	if(n == tstring::npos)return Result; 
    n++;

	tstring::size_type n1 =s.find(' ',n);
	if(n1==tstring::npos)n1 = s.size();
    tstring ext = s.substr(n,n1-n);

	if(_tcsncmp(ext.c_str(),_T("ROOM"),4)==0)return _T("ROOM");
	else if(_tcsncmp(ext.c_str(),_T("PEOPLE"),6))return _T("PEOPLE");
	else if(_tcsncmp(ext.c_str(),_T("CONTAINER"),9))return _T("CONTAINER");	
	else {
		SHFILEINFO    sfi;	
		::SHGetFileInfo(
			(LPCTSTR)s.c_str(), 
			FILE_ATTRIBUTE_NORMAL,
			&sfi, 
			sizeof(SHFILEINFO), 
     		SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
     
		Result = sfi.szTypeName;
		return Result;
	}
};
void VariableHandler::replaceVariables(tstring &source)
{
	tstring::size_type startPos, endPos;
	startPos = 0;
	endPos = tstring::npos;

	do 
	{
		startPos = source.find(_T('$'), startPos);
		if (startPos != tstring::npos)
		{
			endPos = source.find(_T('$'), startPos + 1);
			if (endPos == tstring::npos)
				break;
		}

		if (endPos != tstring::npos)
		{
			tstring varValue = (*_variables)[source.substr(startPos + 1, endPos - startPos - 1)];
			source.replace(startPos, endPos - startPos + 1, varValue);
			startPos = startPos + varValue.size();
			endPos = tstring::npos;
		}


	} while(startPos != tstring::npos);

	

}
Esempio n. 3
0
void CFulEditCtrl::Colorize(const tstring& aLine, int begin) {
	CHARFORMAT2 cf;
	cf.cbSize = sizeof(CHARFORMAT2);
	
	ColorList *cList = HighlightManager::getInstance()->getList();

	int end = GetTextLengthEx(GTL_NUMCHARS);
	
	SetSel(begin, end);
	//otroligt fulhack, måste lagas riktigt nån gång
	SetSelectionCharFormat(selFormat);

	logged = false;

	//compare the last line against all strings in the vector
	for(ColorIter i = cList->begin(); i != cList->end(); ++i) {
		ColorSettings* cs = &(*i);
		int pos;
		
		//set start position for find
		if( cs->getIncludeNick() ) {
			pos = 0;
		} else {
			pos = aLine.find(_T(">"));
			if(pos == tstring::npos)
				pos = aLine.find(_T("**")) + nick.length();
		}

		//prepare the charformat
		cf.dwMask = CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_ITALIC;
		cf.dwEffects = 0;
		if(cs->getBold())		cf.dwEffects |= CFE_BOLD;
		if(cs->getItalic())		cf.dwEffects |= CFE_ITALIC;
		if(cs->getUnderline())	cf.dwEffects |= CFE_UNDERLINE;
		if(cs->getStrikeout())	cf.dwEffects |= CFE_STRIKEOUT;
		
		if(cs->getHasBgColor()){
			cf.dwMask |= CFM_BACKCOLOR;
			cf.crBackColor = cs->getBgColor();
		}
		if(cs->getHasFgColor()){
			cf.dwMask |= CFM_COLOR;
			cf.crTextColor = cs->getFgColor();
		}
		
		while( pos != string::npos ){
			if(cs->usingRegexp()) 
				pos = RegExpMatch(cs, cf, aLine, begin);
			else 
				pos = FullTextMatch(cs, cf, aLine, pos, begin);
		}

		matchedPopup = false;
		matchedSound = false;
		
	}//end for

}//end Colorize
Esempio n. 4
0
	D3DXVECTOR3 ConvertTString(const tstring & value)
	{
        D3DXVECTOR3 vec;
        int index = value.find(';', 0);
		vec.x = ConvertTString<float>(value.substr(0, index));
        int index2 = value.find(';', ++index);
        vec.y = ConvertTString<float>(value.substr(index, index2 - index));
		vec.z = ConvertTString<float>(value.substr(++index2, value.size() - index2));
        return vec;
	}
Esempio n. 5
0
	uvec3 string_cast<uvec3, tstring>
		(const tstring & value)
	{
		uvec3 vec;
		int32 index = value.find(';', 0);
		vec.x = string_cast<uint32>(value.substr(0, index));
		int32 index2 = value.find(';', ++index);
		vec.y = string_cast<uint32>(value.substr(index, index2 - index));
		vec.z = string_cast<uint32>(value.substr(++index2, value.size() - index2));
		return vec;
	}
Esempio n. 6
0
	pos string_cast<pos, tstring>
		(const tstring & value)
	{
		pos pos;
		int32 index = value.find(';', 0);
		pos.x = string_cast<float32>(value.substr(0, index));
		int32 index2 = value.find(';', ++index);
		pos.y = string_cast<float32>(value.substr(index, index2 - index));
		pos.l = lay(string_cast<int32>(value.substr(++index2, value.size() - index2)));
		return pos;
	}
Esempio n. 7
0
void ColorSettings::setMatch(const tstring& match) {
	if (match.compare(_T("$ts$")) == 0) {
		bTimestamps = true;
	} else if (match.compare(_T("$users$")) == 0) {
		bUsers = true;
	} else if (match.find(_T("$mynick$")) != tstring::npos) {
		bMyNick = true;
	} else if (match.find(_T("$Re:")) == 0) {
		bUsingRegexp = true;
	}
	strMatch = match;
}
Esempio n. 8
0
	D3DXQUATERNION ConvertTString(const tstring & value)
	{
		D3DXQUATERNION vec;
		int index = value.find(';', 0);
		vec.x = ConvertTString<float>(value.substr(0, index));
		int index2 = value.find(';', ++index);
		vec.y = ConvertTString<float>(value.substr(index, index2 - index));
		index = value.find(';', ++index2);
		vec.z = ConvertTString<float>(value.substr(index2, index - index2));
		vec.w = ConvertTString<float>(value.substr(++index, value.size() - index));
        return vec;
	}
Esempio n. 9
0
bool CCoBroker::HandleRequestService(const tstring& dstUserId, ULONG dstSvcId, const tstring& srcUserId, ULONG srcSvcId, ULONG rId, ULONG rType, ULONG param, const tstring& params)
{
TRY_CATCH
	HRESULT result;
	EBrokerStartTypes startParam=BST_SAME;
	tstring url;
	{
		tstring::size_type iBeginUrl=params.find(_T(";;"));
		if(iBeginUrl!=tstring::npos)
		{
			tstring::size_type iEndUrl=params.find(_T(";;"),iBeginUrl+2);
			url=params.substr(iBeginUrl+2,(tstring::npos!=iEndUrl)?iEndUrl-iBeginUrl-2:tstring::npos);
		}
	}
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());

	const TCHAR SESSION_ID_PARAMETER_NAME[]=_T("supportRequestId=");
	tstring::size_type iWebSId=url.find(SESSION_ID_PARAMETER_NAME);
	if(iWebSId!=tstring::npos&&iWebSId+_countof(SESSION_ID_PARAMETER_NAME)<url.size())
	{
		iWebSId+=_countof(SESSION_ID_PARAMETER_NAME)-1;
		tstring::size_type iWebSIdEnd=url.find_first_of(_T("&#"),iWebSId);
		if(tstring::npos==iWebSIdEnd)
			iWebSIdEnd=url.length();
		tstring sId=url.substr(iWebSId,iWebSIdEnd-iWebSId);
		Log.Add(_MESSAGE_,_T("***HandleRequestService*** sId=[%s]"),sId.c_str());
		SHA1Hash hash_buf;
		CRYPTO_INSTANCE.MakeHash((char*)sId.c_str(),sId.length()*sizeof(tstring::value_type),hash_buf);
		tstring hashString;
		for(int i=0;i<sizeof(hash_buf);++i)
			//hashString+=i2tstring((int)(unsigned char)hash_buf[i],16);
			hashString+=Format(_T("%02x"),(int)(unsigned char)hash_buf[i]);
		url.insert(iWebSIdEnd,tstring(_T("&sri="))+hashString);
	}
	//Log.Add(_WARNING_,_T("***HandleRequestService*** HASHING TURN OFF"));
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());
	
	CAtlFile cnfg;
	if(S_OK==cnfg.Create(Format(_T("%s\\%s"),GetModulePath(GetCurrentModule()).c_str(),_T("Broker.cfg")).c_str(),GENERIC_READ,0,OPEN_EXISTING))
	{
		TRY_CATCH
			DWORD readLen=0;
			readLen=GetFileSize(cnfg.m_h,NULL);
			if(INVALID_FILE_SIZE==readLen&&readLen>32768)
				throw MCException_Win("Broker.cfg size obtaining failed or file too large");
			std::auto_ptr<char> buf(new char[readLen]);
			if(!ReadFile(cnfg.m_h,buf.get(),readLen,&readLen,NULL))
				throw MCException_Win("Broker.cfg file reading failed");
			startParam=EBrokerStartTypes(atol(buf.get()));
			Log.Add(_MESSAGE_,_T("***HandleRequestService*** file startParam=[0x%x]"),startParam);
		CATCH_LOG()
	}
Esempio n. 10
0
	dquat string_cast<dquat, tstring>
		(const tstring & value)
	{
		dquat quat;
		int32 index = value.find(';', 0);
		quat.x = string_cast<float64>(value.substr(0, index));
		int32 index2 = value.find(';', ++index);
		quat.y = string_cast<float64>(value.substr(index, index2 - index));
		index = value.find(';', ++index2);
		quat.z = string_cast<float64>(value.substr(index2, index - index2));
		quat.w = string_cast<float64>(value.substr(++index, value.size() - index));
		return quat;
	}
Esempio n. 11
0
	ivec4 string_cast<ivec4, tstring>
		(const tstring & value)
	{
		ivec4 vec;
		int32 index = value.find(';', 0);
		vec.x = string_cast<int32>(value.substr(0, index));
		int32 index2 = value.find(';', ++index);
		vec.y = string_cast<int32>(value.substr(index, index2 - index));
		index = value.find(';', ++index2);
		vec.z = string_cast<int32>(value.substr(index2, index - index2));
		vec.w = string_cast<int32>(value.substr(++index, value.size() - index));
		return vec;
	}
Esempio n. 12
0
void ShellCache::CPathFilter::AddEntries(const tstring& s, bool include)
{
	size_t pos = 0, pos_ant = 0;
	pos = s.find(L'\n', pos_ant);
	while (pos != tstring::npos)
	{
		AddEntry(s.substr(pos_ant, pos - pos_ant), include);
		pos_ant = pos + 1;
		pos = s.find(L'\n', pos_ant);
	}

	if (!s.empty())
		AddEntry(s.substr(pos_ant, s.size() - 1), include);
}
Esempio n. 13
0
void quote_if_spaces(tstring& path) {
    int has_space = path.find(tstring(_T(" ")), 0);
    if (has_space == std::string::npos) return;

    path = _T("\"") + path + _T("\"");
    return;
}
void CSearchBussinessPartnerPage::OnVCardReturned( tstring& strAccount, sUserVCard& oneInfo )
{
	if  (tstring::npos != strAccount.find(m_strFindPhoneNo))
	{
		SetSearchResult(oneInfo);
	}
}
Esempio n. 15
0
BOOL CRegistryTool::RegPathToHkeyAndSubKey(tstring regPath,HKEY *hKey,tstring *strSubKey)
{
	int iPos;
	tstring strRootKey;
	BOOL bResult = FALSE;

	if(regPath.size()==0)
		return FALSE;

	iPos = regPath.find("\\");

	if(iPos == tstring::npos)
		return FALSE;

	strRootKey = regPath.substr(0,iPos);
	if(strRootKey.size()==0)
		return FALSE;

	if(StringToRootKey(strRootKey,hKey))
		bResult = TRUE;

	*strSubKey = regPath.substr(iPos+1,regPath.size()-iPos-1);
	

	return bResult;
}
Esempio n. 16
0
int
CLink::UrlType(
	const tstring&	strUrl )
{
	int urlType;

	const tstring slashSlash = _T("//");
	const tstring bslashBslash = _T("\\\\");

	if ( ( strUrl.compare( 0, 2, slashSlash ) == 0 ) ||
		( strUrl.compare( 0, 2, bslashBslash ) == 0 ) )
	{
		urlType = urlType_Absolute;
	}
	else if ( ( strUrl[0] == _T('\\') ) || ( strUrl[0] == _T('/') ) )
	{
		urlType = urlType_LocalAbsolute;
	}
	else
	{
		if ( strUrl.find( _T(':') ) != tstring::npos )
		{
			urlType = urlType_Absolute;
		}
		else
		{
			urlType = urlType_Relative;
		}
	}

	return urlType;
}
Esempio n. 17
0
	uvec2 string_cast<uvec2, tstring>
		(const tstring & value)
	{
		uvec2 vec;
		int32 index = value.find(';', 0);
		vec.x = string_cast<uint32>(value.substr(0, index));
		vec.y = string_cast<uint32>(value.substr(++index, value.size() - index));
		return vec;
	}
Esempio n. 18
0
	virtual void Add(int layer, const tstring& templateName, bool playOnLoad, const tstring& label, const tstring& data) {
		tstringstream flashParam;

		tstring::size_type pos = templateName.find('.');
		tstring filename = (pos != tstring::npos) ? templateName.substr(0, pos) : templateName;
		
		flashParam << TEXT("<invoke name=\"Add\" returntype=\"xml\"><arguments><number>") << layer << TEXT("</number><string>") << filename << TEXT("</string><number>0</number>") << (playOnLoad?TEXT("<true/>"):TEXT("<false/>")) << TEXT("<string>") << label << TEXT("</string><string><![CDATA[ ") << data << TEXT(" ]]></string></arguments></invoke>");
		LOG << LogLevel::Debug << TEXT("Invoking add-command");
		pFlashProducer_->Param(flashParam.str());
	}
Esempio n. 19
0
ChatCommandContext::ChatCommandContext(const tstring& s) {
  dcassert(isCommand(s));
  const string::size_type i = s.find(' ');
  if (i != string::npos) {
    param = s.substr(i + 1);
    command = s.substr(1, i - 1);
  } 
  else {
    command = s.substr(1);
  }
}
Esempio n. 20
0
bool kaynine::unParen(tstring& sLine, const TCHAR chParenL, const TCHAR chParenR) {
	tstring::size_type		nPosL = sLine.find(chParenL);
	tstring::size_type		nPosR = sLine.find(chParenR);


	if (nPosL != sLine.npos && nPosR != sLine.npos) {
		sLine = sLine.substr(nPosL + 1, nPosR - nPosL - 1);
		return true;
	}
	else
		return false;
}
Esempio n. 21
0
/*
 * remove any /./
 */
static void remove_single_dirs(tstring &fn)
{
    tstring search;
    search.push_back(DIR_SEPARATOR);
    search.push_back('.');
    search.push_back(DIR_SEPARATOR);

    while(true){
	size_t loc = fn.find(search);
	if(loc==tstring::npos) break;	// no more to find
	fn.erase(fn.begin()+loc,fn.begin()+loc+2);			// erase
    }
}
Esempio n. 22
0
void check_string_contains(tstring const& expected_substring, 
    tstring const& actual_result, 
    tstring const& result_descr, 
    const char* filename, int line)
{
    if( actual_result.find(expected_substring) != tstring::npos )
        return;
    
    const std::string msg = tinfra::tsprintf("expected substring '%s' not found in actual value '%s': '%s'",
        expected_substring,
        result_descr,
        actual_result);
    report_test_failure(filename, line, msg.c_str()); 
}
Esempio n. 23
0
void CFulEditCtrl::SetNick(const tstring& aNick) {
	if(isSet(STRIP_ISP)) {
		tstring::size_type pos = aNick.find(_T("["));
		if( pos != tstring::npos ) {
			tstring::size_type rpos = aNick.rfind(_T("]"));
			if( rpos == aNick.length() -1 && rpos > 0 ) // this user has a stupid f*****g nick bah ugly hate it
				rpos = aNick.rfind(_T("]"), rpos-1);
			if(rpos != tstring::npos) 
				nick = aNick.substr(rpos+1);
		}
	} else {
		nick = aNick;
	}
}
Esempio n. 24
0
void FileSystem::createFolder(const tstring& path)
{
    tstring folder = standardFilePath(path);
    if (folder[folder.size() - 1] != '\\' && path.find('.', 0) == tstring::npos)
    {
        folder += '\\';
    }
    size_t pos = folder.find_first_of(TEXT("\\"));
    while(pos != tstring::npos)
    {
        tstring f = folder.substr(0, pos);
        CreateDirectory(f.c_str(), NULL);
        pos = folder.find_first_of(TEXT("\\"), pos + 1);
    }
}
Esempio n. 25
0
void CmdDlg::prettify(tstring &text)
{
	try {
		const tstring search(_T("\n")), replace(_T("\r\n"));

		// http://stackoverflow.com/a/14678800/98528
		tstring::size_type pos = 0;
		while ((pos = text.find(search, pos)) != tstring::npos) {
			text.replace(pos, search.length(), replace);
			pos += replace.length();
		}
		text += replace;
	} catch (...) {
		text.clear();
	}
}
Esempio n. 26
0
void GetHashInfo(tstring id, std::vector<std::wstring> & info) {
	while(id.size() > 0)
	{
		size_t pos = id.find(L'-');
		
		tstring substr =
			id.substr(0, pos == tstring::npos ? id.length() : pos);
		info.push_back(substr);
		
		if(pos == tstring::npos) id = L"";
		else
		{
			++pos;
			id = id.substr(pos, id.length() - pos);
		}
	}
}
HTREEITEM TreePropertySheet::createTree(const tstring& str, HTREEITEM parent, int page) {
	TVINSERTSTRUCT tvi;
	tvi.hInsertAfter = TVI_LAST;
	tvi.hParent = parent;

	HTREEITEM first = (parent == TVI_ROOT) ? ctrlTree.GetRootItem() : ctrlTree.GetChildItem(parent);

	string::size_type i = str.find(SEPARATOR);
	if(i == string::npos) {
		// Last dir, the actual page
		HTREEITEM item = findItem(str, first);
		if(item == NULL) {
			// Doesn't exist, add
			tvi.item.mask = TVIF_PARAM | TVIF_TEXT;
			tvi.item.pszText = const_cast<LPTSTR>(str.c_str());
			tvi.item.lParam = page;
			item = ctrlTree.InsertItem(&tvi);
			ctrlTree.SetItemImage(item, page, page);
			ctrlTree.Expand(parent);
			return item;
		} else {
			// Update page
			if(ctrlTree.GetItemData(item) == -1)
				ctrlTree.SetItemData(item, page);
			return item;
		}
	} else {
		tstring name = str.substr(0, i);
		HTREEITEM item = findItem(name, first);
		if(item == NULL) {
			// Doesn't exist, add...
			tvi.item.mask = TVIF_PARAM | TVIF_TEXT;
			tvi.item.lParam = -1;
			tvi.item.pszText = const_cast<LPTSTR>(name.c_str());
			item = ctrlTree.InsertItem(&tvi);
			ctrlTree.SetItemImage(item, page, page);
		} 
		ctrlTree.Expand(parent);
		// Recurse...
		return createTree(str.substr(i+1), item, page);
	}	
}
Esempio n. 28
0
std::vector<tstring> kaynine::split(const tstring& sLine, TCHAR chDel) {
	tstring::size_type		nStartPos = 0;
	tstring::size_type		nStopPos;

	std::vector<tstring>	vecLineParts;
	tstring				sCurrent;


	for (nStartPos = 0; nStartPos < sLine.length() + 1; nStartPos = nStopPos + 1) {
		nStopPos = min(sLine.length(), sLine.find(chDel, nStartPos));

		sCurrent.clear();
		sCurrent.insert(0, sLine, nStartPos, nStopPos - nStartPos);

		if (sCurrent.size())
			vecLineParts.push_back(sCurrent);
	}

	return vecLineParts;
}
Esempio n. 29
0
/* POSIX version of clean_name */
static void remove_double_slash(tstring &fn)
{
    tstring search;
    search.push_back(DIR_SEPARATOR);
    search.push_back(DIR_SEPARATOR);

#ifdef _WIN32
    // On Windows, we have to allow the first two characters to be slashes
    // to account for UNC paths. e.g. \\SERVER\dir\path
    // So on windows we ignore the first character
    size_t start = 1;
#else    
    size_t start = 0;
#endif
    while(true){
	size_t loc = fn.find(search,start);
	if(loc==tstring::npos) break;	// no more to find
	fn.erase(loc,1);		// erase one of the two slashes
    }
}
Esempio n. 30
0
// Find a string value within an expanded string, returns the offset if found, else string::npos
// We need to match the entire string, so that we can match '3' in the following
// 1,2,33,3 and not match the 33
tstring::size_type FindValueInExpandedString(const tstring& szData, const tstring& szSearch, tstring::size_type iValueIndex)
{
	if (szData.empty())
		return tstring::npos;

	bool bCompleted = false;
	size_t iValueOffset = 0;
	tstring szTmpVal;

	if (iValueIndex > 0)
		iValueOffset = iValueIndex;
	else
		iValueIndex = tstring::npos;

	while (!bCompleted)
	{
		if (iValueOffset >= szData.length())
		{
			bCompleted = true;
			continue;
		}

		tstring::size_type iTmpIndex = szData.find(_T(";"), iValueOffset);

		if (iTmpIndex != tstring::npos)
			szTmpVal = szData.substr(iValueOffset, iTmpIndex - iValueOffset); // Grab up to the next seperator
		else
			szTmpVal = szData.substr(iValueOffset, szData.length()); // Grab up to the end of the line

		if (szTmpVal == szSearch) // Found it so stop searching
		{
			iValueIndex = iValueOffset;
			bCompleted = true;
			continue;
		}

		iValueOffset += szTmpVal.length() + 1; // Move to the next entry
	}

	return iValueIndex;
}