コード例 #1
0
ファイル: DumpRenderTree.cpp プロジェクト: dzip/webkit
wstring urlSuitableForTestResult(const wstring& url)
{
    if (!url.c_str() || url.find(L"file://") == wstring::npos)
        return url;

    return PathFindFileNameW(url.c_str());
}
コード例 #2
0
ファイル: cilVMBind.cpp プロジェクト: hak/criscript
/***************************************************************************
 *      bindBuiltinVariable
 ***************************************************************************/
bool CCilVm::bindBuiltinVariable( const wstring& strQualifiedName,
                                  CVariable* const pvar )
{
    bool bReturn = true;

    //Bind the var

    if( strQualifiedName.find( STRING_INTERNAL_SCOPEDELIMITER ) != wstring::npos )
    {
        wstring strRoot = strQualifiedName.substr( 0, strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) );
        assert( strRoot.find( STRING_INTERNAL_SCOPEDELIMITER ) == wstring::npos );

        wstring strLeaf = strQualifiedName.substr( strQualifiedName.rfind( STRING_INTERNAL_SCOPEDELIMITER ) + 1,
                          strQualifiedName.length() );
        RID ridObject = getMetaData().queryBuiltinObjectRid( strRoot );
        if( ridObject == RID_NOTDEFINED )
            return false;

        //Create property
        getPrototypeObject( ridObject ).setProperty( strLeaf,
                *pvar );
    }

    return bReturn;
}
コード例 #3
0
/*
 * Adds table header info for a single cell which explicitly defines headers
 * using the Headers attribute.
 */
inline void fillExplicitTableHeadersForCell(AdobeAcrobatVBufStorage_controlFieldNode_t& cell, int docHandle, wstring& headersAttr, TableInfo& tableInfo) {
	wostringstream colHeaders, rowHeaders;

	// The Headers attribute string is in the form "[[id id ... ]]"
	// Loop through all the ids.
	// Ignore the "[[" prefix and the " ]]" suffix.
	size_t lastPos = headersAttr.length() - 3;
	size_t startPos = 2;
	while (startPos < lastPos) {
		// Search for a space, which indicates the end of this id.
		size_t endPos = headersAttr.find(L' ', startPos);
		if (endPos == wstring::npos)
			break;
		// headersAttr[startPos:endPos] is the id of a single header.
		// Find the info for the header associated with this id string.
		map<wstring, TableHeaderInfo>::const_iterator it = tableInfo.headersInfo.find(headersAttr.substr(startPos, endPos - startPos));
		startPos = endPos + 1;
		if (it == tableInfo.headersInfo.end())
			continue;

		if (it->second.type & TABLEHEADER_COLUMN)
			colHeaders << docHandle << L"," << it->second.uniqueId << L";";
		if (it->second.type & TABLEHEADER_ROW)
			rowHeaders<< docHandle << L"," << it->second.uniqueId << L";";
	}

	if (colHeaders.tellp() > 0)
		cell.addAttribute(L"table-columnheadercells", colHeaders.str());
	if (rowHeaders.tellp() > 0)
		cell.addAttribute(L"table-rowheadercells", rowHeaders.str());
}
コード例 #4
0
ファイル: WinContactSIF.cpp プロジェクト: niujingqian/haocai
int WinContactSIF::parse(const wstring & data) {

    if (!sifFields) {
        LOG.error("%s", ERR_SIFFIELDS_NULL);
        return 1;
    }
    propertyMap.clear();

    // Check if <contact> tag is present...
    wstring::size_type pos = 0;
    wstring itemTypeTag = L"<contact>";    
    pos = data.find(itemTypeTag, 0);
    if (pos == wstring::npos) {
        LOG.error("Tag '%ls' not found", itemTypeTag.c_str());
        return 1;
    }
    wstring propertyValue;
       
    for (int i=0; sifFields[i]; i++) {
        // Set only properties found!
        if (!getElementContent(data, sifFields[i], propertyValue, 0)) {

            replaceAll(L"&lt;",  L"<", propertyValue);
            replaceAll(L"&gt;",  L">", propertyValue);
            replaceAll(L"&amp;", L"&", propertyValue);
            
            setProperty(sifFields[i], propertyValue);
        }
    }   
    return 0;
}
コード例 #5
0
ファイル: Util.cpp プロジェクト: MOURAD24/SearchClip
bool IsURL(wstring const &str)
{
	if(str.find(TEXT(" "), 0) != wstring::npos)
	{
		return false;
	}

	wstring upr(UpperCase(str));

	if(upr.compare(0, 7, TEXT("HTTP://")) == 0 || upr.compare(0, 8, TEXT("HTTPS://")) == 0)
	{
		return true;
	}

	WCHAR **tld = gTopLevelDomains;
	while(*tld != nullptr)
	{
		if(upr.find(*tld, 0) != wstring::npos)
		{
			return true;
		}
		++tld;
	}
	return false;
}
コード例 #6
0
ファイル: filelist.cpp プロジェクト: watsonmw/platform
bool FileList::setCurrentFile(const wstring &current_file)
{
    wstring base_path = FilePath::cleanUpPath(_baseDirectory.getPath()) + L"\\";;
    if (current_file.find(base_path) != 0) {
        return false;
    }

    if (base_path.length() == current_file.length()) {
        return false;
    }

    vector<wstring> split_path;
    FilePath::splitFilePath(current_file.substr(base_path.length()), split_path);

    wstring current_path = base_path;
    for (vector<wstring>::iterator i = split_path.begin(); i != split_path.end(); ++i) {
        wstring name = *i;
        current_path += name + L"\\";

        FileInfo fileInfo(current_path);
        if (fileInfo.isDirectory()) {
            Directory *next_directory = new Directory(current_path);
            _directories.top()->setCurrentSubDirectory(name);
            _directories.push(next_directory);
        }
        else if (fileInfo.isFile()) {
            return _directories.top()->setCurrentFile(name);
        }
        else {
            return false;
        }
    }
    return false;
}
コード例 #7
0
ファイル: QueryAssembler.cpp プロジェクト: Samsung/veles.nlp
wstring QueryAssembler::interpolate(const wstring& rule, const shared_ptr<IMatch>& match, const NetEvaluator& evaluator)
{
	unordered_map<wstring, wstring> evaluation = evaluator.Evaluate(match, currentFrameTense); //evaluator calculates all values which could be interpolated into the template

	wstring filler;
	
	wstring toReturn = rule;

	size_t c_pos = 0;
	size_t pos = 0;

	while((pos = rule.find(L"${", c_pos)) != wstring::npos) //replace all placeholders in the template with calculated values
	{
		size_t pos2 = rule.find(L"}", pos);
		if(pos2 == wstring::npos)
		{
			throw EInvalidSlotRule(match->GetNetName().c_str());
		}

		wstring placeHolder = rule.substr(pos + 2, pos2 - pos - 2);

		size_t point_pos;

		if((point_pos = placeHolder.find(L".")) != wstring::npos) //reference to subfield ".field" is supported
		{
			wstring field = placeHolder.substr(point_pos + 1);
			if(evaluation.find(field) == evaluation.end())
			{
				throw ENoExistingFieldReference(match->GetNetName().c_str());
			}
			filler = evaluation.at(field);
		}
		else
		{
			filler = evaluation.at(NetEvaluator::VALUE); //if no field is referenced field .VALUE is referenced by default
		}

		c_pos = pos2;

		size_t repl1 = toReturn.find(L"${");
		size_t repl2 = toReturn.find(L"}") + 1;

		toReturn.replace(repl1, repl2 - repl1, filler);
	}

	return toReturn;
}
コード例 #8
0
ファイル: ParseSearchChgText.cpp プロジェクト: ACUVE/EDCB
void CParseSearchChgText::ChgText(wstring& chgText)
{
	for( size_t i = 0; i<this->chgKey.size(); i++ ){
		if( chgText.find( this->chgKey[i].oldText ) != string::npos ){
			Replace(chgText, this->chgKey[i].oldText, this->chgKey[i].newText);
		}
	}
}
コード例 #9
0
ファイル: utils.cpp プロジェクト: kevx/sdkfz000
wstring substr_after(const wstring& s, const wstring& skip) {
	size_t p = s.find(skip);
	if (p == wstring::npos) {
		return NULL;
	}
	
	return s.substr(skip.length() + p);
}
コード例 #10
0
wstring 
Utils::get_tag_value(wstring tags, wstring values) {
  vector<wstring> pval=StringUtils::split_wstring(values,L"|");

  for(wstring::size_type i=0; i<pval.size(); i++) {
    if (tags.find(pval[i]) != wstring::npos)
    {
		int pos=tags.find(pval[i]);
		if( (pos==0 || tags[pos-1]==L'.') && (pos==tags.size()-1 || tags[pos+1]==L'.'))
			return pval[i];
		else
			return L"";
    }
  }

  return L"";
}
コード例 #11
0
ファイル: OS.cpp プロジェクト: penbor/jwebtop
			// 根据相对路径获取绝对路径
			// 如果relativePath已经是绝对路径,则直接返回
			// 否则将返回appPath+relativePath
			wstring getAbsolutePath(wstring &relativePath, wstring &appPath){
				if (relativePath.find(L":") == -1){// 如果指定的路径是相对路径
					wstring _path(appPath);
					_path.append(relativePath);
					return _path;
				}
				return relativePath;
			}
コード例 #12
0
ファイル: SOCKET.cpp プロジェクト: tiku/test
bool Inet::StatusCodeAnalysis(wstring sctext,int* res){
	int i,n,pos;
	wchar_t *err;
	if(pos=sctext.find(' ')==wstring::npos){
		return false;
	}
	sctext.erase(0,pos+1);
	if(pos=sctext.find(' ')==wstring::npos){
		return false;
	}
	sctext.erase(pos);
	*res=wcstol(sctext.c_str(),&err,10);
	if(lstrlen(err)!=0){
		return false;
	}
	return true;
}
コード例 #13
0
wstring
Utils::get_tags(wstring word) {
  wstring::size_type p=word.find(L"<",0);
  if (p!=wstring::npos)
    return word.substr(p, word.size()-p);
  else //Unknown word, no tags for it
    return L"";
}
コード例 #14
0
ファイル: RealTextParser.cpp プロジェクト: AeonAxan/mpc-hc
bool CRealTextParser::GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars)
{
    while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == wstring::npos) {
        p_rszString += p_rszLine.at(p_riPos);
        ++p_riPos;
    }

    return p_rszLine.length() > p_riPos;
}
コード例 #15
0
ファイル: nbtools.cpp プロジェクト: JohnBFrm/NohBoard
wstring NBTools::doReplace(wstring text, wstring find, wstring replace)
{
    while (true)
    {
        size_t pos = text.find(find);
        if (0 > pos || pos > text.length()) return text;
        text = text.replace(pos, find.length(), replace);
    }
}
コード例 #16
0
ファイル: WXML.cpp プロジェクト: leedabin/framework
	template<> void WXML::constructKey(wstring &str)
	{
		long startX = str.find('<') + 1;
		long endX =
			Math::calcMin<long>
			(
		{
			indexFilter(str.find(' ', startX)),
			indexFilter(str.find('\n', startX)),
			indexFilter(str.find('\t', startX)),
			indexFilter(str.find('>', startX)),
			indexFilter(str.find('/', startX))
		}
		).getValue();

		//Determinate the KEY
		key = move(WStringUtil::substring(str, startX, endX));
	}
コード例 #17
0
ファイル: UnitConverter.cpp プロジェクト: rrps/calculator
vector<wstring> UnitConverter::StringToVector(const wstring& w, const wchar_t * delimiter, bool addRemainder)
{
    size_t delimiterIndex = w.find(delimiter);
    size_t startIndex = 0;
    vector<wstring> serializedTokens = vector<wstring>();
    while (delimiterIndex != w.npos)
    {
        serializedTokens.push_back(w.substr(startIndex, delimiterIndex - startIndex));
        startIndex = delimiterIndex + (int)wcslen(delimiter);
        delimiterIndex = w.find(delimiter, startIndex);
    }
    if (addRemainder)
    {
        delimiterIndex = w.size();
        serializedTokens.push_back(w.substr(startIndex, delimiterIndex - startIndex));
    }
    return serializedTokens;
}
コード例 #18
0
ファイル: Register.cpp プロジェクト: stjeong/Straw
wstring GetNewVersion(wstring txt)
{
    wstring startTag = L"<version>";

    size_t spos = txt.find(startTag);
    if (spos == wstring::npos)
    {
        return L"";
    }

    size_t epos = txt.find(L"</version>", spos);
    if (epos == wstring::npos)
    {
        return L"";
    }

    spos += startTag.length();
    return txt.substr(spos, epos - spos);
}
コード例 #19
0
wstring
Utils::get_lemma(wstring word) {
  wstring s=L"";

  wstring::size_type p=word.find(L"<",0);
  if (p!=wstring::npos)
    s=word.substr(0, p);

  return s;
}
コード例 #20
0
ファイル: DataTuple.cpp プロジェクト: mrevow/nnTcl
HRESULT CDataTuple::GetNextValue(int &iVal, wstring &line, size_t &start)
{
	HRESULT hRet = E_FAIL;
	size_t	 end;
	wstring	sep(TEXT(" \t"), 1);

	if (start >= line.length())
	{
		return hRet;
	}

	end = line.find_first_of (sep, start+1);

	wstring substr;

	if (string::npos != end && end > start)
	{
		substr = line.substr(start, end -start);
	}
	else
	{
		substr = line.substr(start, line.length() -start);
	}

	if (substr.length() > 0)
	{
		float val;
		if (1 == _stscanf_s(substr.c_str(), TEXT("%f"), &val))
		{
			iVal = (int)val;
			hRet = S_OK;
		}
	}
	else
	{
		start = string::npos;
	}

	if (SUCCEEDED(hRet) && end != string::npos)
	{
		start = line.find(sep, end);

		while (start < line.length() && line[start +1] == ' ')
		{
			++start;
		}

	}
	else
	{
		start = string::npos;
	}

	return hRet;
}
コード例 #21
0
ファイル: CWaveSession.cpp プロジェクト: pvginkel/wave-notify
wstring CWaveSession::GetKeyFromSessionResponse(wstring szKey, wstring & szResponse) const
{
	// TODO: Extend the Json library to include this functionality.

	ASSERT(!szKey.empty());

	INT nOffset = 0;

	while (nOffset != string::npos)
	{
		nOffset = szResponse.find(szKey + L":'", nOffset);

		if (nOffset != string::npos)
		{
			CHAR cBefore = nOffset == 0 ? '\0' : szResponse[nOffset - 1];

			nOffset += szKey.length() + 1;

			if (!iswalnum(cBefore) && cBefore != '_')
			{
				break;
			}
		}
	}

	if (nOffset != string::npos)
	{
		nOffset = szResponse.find(L'\'', nOffset) + 1;
	}

	if (nOffset != string::npos)
	{
		INT nEnd = szResponse.find(L'\'', nOffset);

		if (nEnd != string::npos)
		{
			return szResponse.substr(nOffset, nEnd - nOffset);
		}
	}

	return L"";
}
コード例 #22
0
ファイル: CrabStringFindWholeWord.cpp プロジェクト: 1054/Crab
wstring CrabStringFindWholeWord(const wstring &t, size_t pos, const wstring &BreakupMark, const wstring &BreakupMarkOnceMore)
{
    wstring foundstr;
    if(0==pos) {
        wstring strR = t;
        size_t foundposL = 0;
        size_t foundposR = t.find(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposR){foundposR = strR.find(BreakupMarkOnceMore);}else{
                if(strR.find(BreakupMarkOnceMore)<foundposR){foundposR=strR.find(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposR){foundposR=t.length()-1;}else{
            foundposR=foundposR-1;
        }
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    } else if(t.length()-1==pos) {
        wstring strL = t;
        size_t foundposL = t.rfind(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposL){foundposL = strL.rfind(BreakupMarkOnceMore);}else{
                if(strL.rfind(BreakupMarkOnceMore)>foundposL){foundposL=strL.rfind(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposL){foundposL=0;}else{
            foundposL=foundposL+1;
        }
        size_t foundposR = t.length()-1;
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    } else if(0<pos && t.length()-1>pos) {
        wstring strL = t.substr(0,pos);
        wstring strR = t.substr(pos);
        size_t foundposL = strL.rfind(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposL){foundposL = strL.rfind(BreakupMarkOnceMore);}else{
                if(strL.rfind(BreakupMarkOnceMore)>foundposL){foundposL=strL.rfind(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposL){foundposL=0;}else{
            foundposL=foundposL+1;
        }
        size_t foundposR = strR.find(BreakupMark);
        if(BreakupMarkOnceMore.length()>0){ // <added><20150615><dzliu> use another BreakupMarkOnceMore
            if(wstring::npos==foundposR){foundposR = strR.find(BreakupMarkOnceMore);}else{
                if(strR.find(BreakupMarkOnceMore)<foundposR){foundposR=strR.find(BreakupMarkOnceMore);}
            }
        }
        if(wstring::npos==foundposR){foundposR=t.length()-1;}else{
            foundposR=foundposR-1+pos;
        }
        foundstr = t.substr(foundposL,foundposR-foundposL+1);
    }
    return foundstr;
}
コード例 #23
0
ファイル: wsex.cpp プロジェクト: Narazaka/aya5.js
/* -----------------------------------------------------------------------
 *  関数名  :  ws_replace
 *  機能概要:  str内のbeforeをすべてafterに置換します
 * -----------------------------------------------------------------------
 */
void	ws_replace(wstring &str, const wstring &before, const wstring &after)
{
	int	sz_bef = before.size();
	int	sz_aft = after.size();
	for(int rp_pos = 0; ; rp_pos += sz_aft) {
		rp_pos = str.find(before, rp_pos);
		if (rp_pos == -1)
			break;
		str.replace(rp_pos, sz_bef, after);
	}
}
コード例 #24
0
inline wstring VertifyFilename( const wstring& sFilename )
{
	static wstring wsCHarMap1 = L"\\/:*\"|<>?!'";
	static wstring wsCHarMap2 = SConv("\xEF\xBC\xBC\xEF\xBC\x8F\xEF\xBC\x9A\xEF\xBC\x8A\xEF\xBC\x82\xEF\xBD\x9C\xEF\xBC\x9C\xEF\xBC\x9E\xEF\xBC\x9F\xEF\xBC\x81\xE2\x80\x99");

	wstring sNewName = sFilename;
	while( true )
	{
		size_t uPos = sNewName.find_first_of( wsCHarMap1 );
		if( uPos == wstring::npos )
			break;

		auto x1 = sNewName[uPos];
		auto x2 = wsCHarMap1.find( sNewName[uPos] );
		auto x3 = wsCHarMap1[ wsCHarMap1.find( sNewName[uPos] ) ];

		sNewName[uPos] = wsCHarMap2[ wsCHarMap1.find( sNewName[uPos] ) ];
	}
	return sNewName;
}
コード例 #25
0
void StringUtilities::ReplaceAll(wstring &str, const wstring &search, const wstring &replace)
{
    for (size_t pos = 0;; pos += replace.length() - 1)
    {
        pos = str.find(search, pos);
        if (pos == string::npos) break;

        str.erase(pos, search.length());
        str.insert(pos, replace);
    }
}
コード例 #26
0
ファイル: CodeCvs.cpp プロジェクト: svn2github/ybtx
void string_replace( wstring& strBig, const wstring& strSrc, const wstring& strDst )
{
	wstring::size_type pos=0;
	wstring::size_type srclen = strSrc.size();
	wstring::size_type dstlen = strDst.size();
	while( (pos=strBig.find(strSrc, pos)) != wstring::npos)
	{
		strBig.replace(pos, srclen, strDst);
		pos += dstlen;
	}
}
コード例 #27
0
ファイル: GokuClient.cpp プロジェクト: dalinhuang/demodemo
static int split_next(const wstring &src, wstring &des, char ch, int start){
	int pos = 0;
	pos = src.find(ch, start);
	des.clear();
	if(pos < start){
		pos = src.length();
	}
	if(pos > start){
		des.assign(src, start, pos - start);
	}
	return pos;
}
コード例 #28
0
ファイル: farver.cpp プロジェクト: FarGroup/FarManager
wstring extract_version_number(const wstring& text, const wstring& ver_name) {
  size_t pos = text.find(ver_name);
  CHECK(pos != wstring::npos);
  pos += ver_name.size();
  while (pos < text.size() && (text[pos] == L' ' || text[pos] == L'\t'))
    pos++;
  size_t start_pos = pos;
  while (pos < text.size() && text[pos] >= L'0' && text[pos] <= L'9')
    pos++;
  size_t end_pos = pos;
  return text.substr(start_pos, end_pos - start_pos);
}
コード例 #29
0
// & の削除
static wstring	RemoveAmpersand( wstring sLavel)
{
	size_t	nPos =0;
	while ((nPos = sLavel.find( L"&", nPos)) != wstring::npos) {
		if (sLavel[nPos+1] == L'&') {
			// &&
			sLavel.replace( nPos, 1, L"");
		}
		nPos ++;
	}
	return sLavel;
}
コード例 #30
0
ファイル: Library.cpp プロジェクト: lMattl/homework
int compare_string(const wstring &s, const wstring &t) {
	int score = 0;
	int n = t.length();
	for (int j = 1; j <= n; ++ j)
		for (int i = 0; i + j < n; ++ i) {
			wstring sub = t.substr(i, j);
			if (s.find(sub) != wstring::npos) {
				score += sub.length();
			}
		}
	return score;
}