当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::find方法代码示例

本文整理汇总了C++中std::wstring::find方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::find方法的具体用法?C++ wstring::find怎么用?C++ wstring::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::wstring的用法示例。


在下文中一共展示了wstring::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseVideoURL

HRESULT URLParser::ParseVideoURL(std::wstring& wstrURL, std::wstring& wstrVideoURL)
{
    HRESULT hr = E_FAIL;
    std::wstring wstrNormalizedURL;
    URLParser::VIDEO_URL_PARSER eVideoURLParser;
    int iCount = 0;
    if(0 == wstrURL.find(L"http://"))
    {
        iCount += wcslen(L"http://");
    }
    if(iCount == wstrURL.find(L"www."))
    {
        iCount += wcslen(L"www.");
    }
    if(iCount == wstrURL.find(L"youtube"))
    {
        eVideoURLParser = URLParser::YOUTUBE_VIDEO_URL_PARSER;
        hr = GetVideoInfoURL(eVideoURLParser, wstrURL, wstrVideoURL );
    }
    /*
    else if(OTHER_VIDEO_PARSERS)
    {
        // For Future
    }
    */
    return hr;
}
开发者ID:navtez,项目名称:YoutubeDownloader,代码行数:27,代码来源:URLParser.cpp

示例2: GetVideoInfoURL

HRESULT URLParser::GetVideoInfoURL(URLParser::VIDEO_URL_PARSER eVideoURLParser, std::wstring& wstrURL, std::wstring& wstrVideoURL)
{
    HRESULT hr          = E_FAIL;
    int     iVdoIDStart = -1;
    int     iVdoIDEnd   = -1;
    std::wstring wstrVideoID;
    if(std::wstring::npos != (iVdoIDStart = wstrURL.find(L"v=")))
    {
        iVdoIDStart += wcslen(L"v=");
        iVdoIDEnd = wstrURL.find(L"&", iVdoIDStart);
        if(std::wstring::npos != iVdoIDEnd)
        {
            // pick start to end
            wstrVideoID = wstrURL.substr(iVdoIDStart, (iVdoIDEnd - iVdoIDStart));
        }
        else
        {
            // pick the entire string
            wstrVideoID = wstrURL.substr(iVdoIDStart, (wstrURL.length() - iVdoIDStart));
        }
    }
    if(0 != wstrVideoID.length())
    {
        wstrVideoURL.clear();
        wstrVideoURL.assign(PRE_VIDEO_ID_URL_STRING);
        wstrVideoURL.append(wstrVideoID);
        wstrVideoURL.append(POST_VIDEO_ID_URL_STRING);
        hr = S_OK;
    }
    return hr;
}
开发者ID:navtez,项目名称:YoutubeDownloader,代码行数:31,代码来源:URLParser.cpp

示例3: FirstInvalidDirSeparatorSizetap

int FirstInvalidDirSeparatorSizetap(std::wstring& aPath, std::wstring::size_type& aIndex)
	{
	// If path semantics is correct (as needed by sisx library)
	// then the function will return 0
	int ret = 0; 
	int pos = 0;
	#ifdef __LINUX__
	if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos)
	#else
	if((pos = aPath.find(L"//", aIndex)) != std::wstring::npos)
	#endif
		{
		ret = 2;
		}
	#ifdef __LINUX__
	else if((pos = aPath.find(L"\\", aIndex)) != std::wstring::npos)
	#else
	else if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos)
	#endif
		{
		ret = 1;
		}
	aIndex = pos;
	return ret;
	}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:25,代码来源:dirparse.cpp

示例4: ReplaceWString

void ReplaceWString(std::wstring & str, const std::wstring & find, const std::wstring & replace)
{
    for(auto i = str.find(find); i != std::wstring::npos ;i = str.find(find))
    {
        str.replace(i, find.size(), replace);
    }
}
开发者ID:blaquee,项目名称:x64dbgpatchexporter,代码行数:7,代码来源:pluginmain.cpp

示例5: CalculateFormatIndex

int FacadeDocumentProviderImpl::CalculateFormatIndex(const std::wstring& formatString, std::wstring extension)
{
	if (extension[0] == L'.')
		extension = extension.substr(1);

	std::wstring filter = L"*." + CStdStringW(extension).ToLower();

	unsigned int iPos = (unsigned int) -1;
	int iIndex = 1;
	while (true)
	{
		iPos = (x64_int_cast)formatString.find(L"|", iPos+1);
		if (iPos == formatString.npos)
			return 1;

		int startPos = iPos;
		iPos = (x64_int_cast)formatString.find(L"|", iPos+1);
		if (iPos == formatString.npos)
			return 1;

		int endPos = iPos;
		std::wstring thisFormat = formatString.substr(startPos+1, endPos-startPos-1);

		if (thisFormat.find(filter) != thisFormat.npos)
			return iIndex;

		iIndex++;

		iPos++;
	}
	return 1;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:32,代码来源:FacadeDocumentProviderImpl.cpp

示例6: ReplaceMeasures

/*
** Replaces %1, %2, ... with the corresponding measure value.
**
*/
bool Meter::ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale, double scale, int decimals, bool percentual)
{
	bool replaced = false;

	if (str.find(L'%') != std::wstring::npos)
	{
		WCHAR buffer[64];

		for (size_t i = m_Measures.size(); i > 0; --i)
		{
			size_t len = _snwprintf_s(buffer, _TRUNCATE, L"%%%i", (int)i);
			size_t start = 0, pos;

			const WCHAR* measureValue = m_Measures[i - 1]->GetStringOrFormattedValue(
				autoScale, scale, decimals, percentual);
			const size_t measureValueLen = wcslen(measureValue);

			do
			{
				pos = str.find(buffer, start, len);
				if (pos != std::wstring::npos)
				{
					str.replace(pos, len, measureValue, measureValueLen);
					start = pos + measureValueLen;
					replaced = true;
				}
			}
			while (pos != std::wstring::npos);
		}
	}

	return replaced;
}
开发者ID:shengd,项目名称:rainmeter,代码行数:37,代码来源:Meter.cpp

示例7: ReplaceMeasures

/*
** Replaces %1, %2 etc with the corresponding measure value
*/
bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std::wstring& str)
{
	bool replaced = false;

	if (str.find(L'%') != std::wstring::npos)
	{
		WCHAR buffer[64];

		// Create the actual text (i.e. replace %1, %2, .. with the measure texts)
		for (size_t i = stringValues.size(); i > 0; --i)
		{
			size_t len = _snwprintf_s(buffer, _TRUNCATE, L"%%%i", (int)i);
			size_t start = 0, pos;
			do
			{
				pos = str.find(buffer, start, len);
				if (pos != std::wstring::npos)
				{
					str.replace(pos, len, stringValues[i - 1]);
					start = pos + stringValues[i - 1].length();
					replaced = true;
				}
			}
			while (pos != std::wstring::npos);
		}
	}

	return replaced;
}
开发者ID:RichVRed,项目名称:rainmeter,代码行数:32,代码来源:Meter.cpp

示例8:

static std::wstring rawinput_device_improve_name(const std::wstring &name)
{
	// The RAW name received is formatted as:
	//   \??\type-id#hardware-id#instance-id#{DeviceClasses-id}
	// XP starts with "\??\"
	// Vista64 starts with "\\?\"

	// ensure the name is something we can handle
	if (name.find(L"\\\\?\\") != 0 && name.find(L"\\??\\") != 0)
		return name;

	std::wstring regpath = compute_device_regpath(name);

	bool hid = false;
	auto improved = improve_name_from_base_path(regpath, &hid);
	if (!improved.empty())
		return improved;

	if (hid)
	{
		improved = improve_name_from_usb_path(regpath);
		if (!improved.empty())
			return improved;
	}

	// Fall back to the original name
	return name;
}
开发者ID:goofwear,项目名称:mame,代码行数:28,代码来源:input_rawinput.cpp

示例9: getParameterFromTag

std::wstring Database::getParameterFromTag(std::wstring temp)
{
    size_t pos;
    const size_t nExist = std::wstring::npos;

    pos = temp.find('"');

    if ( pos != nExist)
    {
       temp.erase(0 , pos+1);
       pos = temp.find(L'"');

       if ( pos != nExist)
       {
            temp.erase(pos);
            return temp;
       }

       else
       {
           std::wcout << L"Fehler 1, getParameterFromTag()" << std::endl;
       }
    }

    else
    {
       std::wcout << L"Fehler 2, getParameterFromTag()" << std::endl;
    }

    return L"";
}
开发者ID:Dante999,项目名称:CCFAG_Crafting-Calculator-for-any-Game,代码行数:31,代码来源:database.cpp

示例10: IsLegalPath

BOOL CImageUtility::IsLegalPath(std::wstring& wstrPathName)
{
	TSAUTO();

	size_t stPos1 = wstrPathName.find_first_of(L':');
	size_t stPos2 = wstrPathName.find_first_of(L'\\');

	BOOL bIsLegal = TRUE;
	if (1 != stPos1 || 2 != stPos2 || 3 > wstrPathName.length() || wstrPathName.find(_T("//")) != std::wstring::npos || wstrPathName.find(_T("\\\\")) != std::wstring::npos
		|| wstrPathName.find(_T("/\\")) != std::wstring::npos || wstrPathName.find(_T("\\/")) != std::wstring::npos)
	{
		bIsLegal = FALSE;
	}
	if (wstrPathName.size() > 150)
	{
		bIsLegal = FALSE;
	}
	if (TRUE == bIsLegal)
	{
		TCHAR* szUnLegalChars = L"/:*?\"<>|";
		std::wstring wstrPathNameWithoutHead = wstrPathName.substr(2);
		for (int i = 0; i < 8; ++i)
		{
			if (wstrPathNameWithoutHead.npos != wstrPathNameWithoutHead.find_first_of(szUnLegalChars[i]))
			{
				bIsLegal = FALSE;
				break;
			}
		}
	}

	return bIsLegal;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:33,代码来源:ImageUtility.cpp

示例11: getTemplateFilter

std::wstring getTemplateFilter(const std::wstring & templateContent)
{
    size_t idx_template = templateContent.find(L"$TEMPLATE_FILEFILTER:");
    std::wstring line;
    if(idx_template != std::wstring::npos)
    {
        idx_template += wcslen(L"$TEMPLATE_FILEFILTER:");
        size_t EOL = templateContent.find(L"\n", idx_template);
        if(EOL == std::wstring::npos)
            EOL = templateContent.size() - idx_template - 1;
        if(templateContent.at(EOL - 1) == L'\r')
            EOL--;
        if(EOL < idx_template)
            EOL = idx_template;
        line = templateContent.substr(idx_template, EOL - idx_template);
    }
    else
    {
        line = LoadWideString(IDS_FILTER);
    }
    for(size_t i = 0; i < line.size(); i++)
        if(line[i] == L'|')
            line[i] = L'\0';
    line.push_back(L'\0');
    return line;
}
开发者ID:blaquee,项目名称:x64dbgpatchexporter,代码行数:26,代码来源:pluginmain.cpp

示例12: CheckEquLabel

bool CheckEquLabel(std::wstring& str)
{
	size_t s = str.find(L" equ ");
	if (s == std::string::npos) s = str.find(L":equ ");
	if (s != std::string::npos)
	{
		std::wstring name = str.substr(0,s);
		if (name.back() == ':') name.pop_back();

		if (Global.symbolTable.isValidSymbolName(name) == false)
		{
			Logger::printError(Logger::Error,L"Invalid equation name %s",name);
			return true;
		}

		if (Global.symbolTable.symbolExists(name,Global.FileInfo.FileNum,Global.Section))
		{
			Logger::printError(Logger::Error,L"Equation name %s already defined",name);
			return true;
		}
		
		std::wstring replacement = str.substr(s+5);
		Global.symbolTable.addEquation(name,Global.FileInfo.FileNum,Global.Section,replacement);
		return true;
	}

	return false;
}
开发者ID:kabochi,项目名称:armips,代码行数:28,代码来源:Assembler.cpp

示例13: outputMessage

// ---------------------------------------------------------------------------
// Name:        vspPackageWrapper::outputMessage
// Description: Send a text message to the output pane of visual studio
// Arguments:   gtString messageString
// Return Val:  void
// Author:      Gilad Yarnitzky
// Date:        17/2/2011
// ---------------------------------------------------------------------------
void vspPackageWrapper::outputMessage(const std::wstring& messageString, bool outputOnlyToLog)
{
    // Add to log:
    VSCORE(vscPrintDebugMsgToDebugLog)(messageString.c_str());

    if (!outputOnlyToLog)
    {
        IVsOutputWindowPane* spOutputWindowPane = getDebugPane();
        VSP_ASSERT(spOutputWindowPane != NULL);

        if (spOutputWindowPane != NULL)
        {
            HRESULT rc = spOutputWindowPane->Activate();
            bool isOk = (rc == S_OK);

            if (isOk)
            {
                std::wstring messageForOutputPane = messageString;
                // handle a case where the string begins with \n\n\n\n- we don't want to have many "CodeXL-" with no messege
                std::size_t found1 = messageString.find(VS_STR_NewLine);

                if (found1 == 0)
                {
                    for (;;)
                    {
                        std::size_t found2 = messageString.find(VS_STR_NewLine, found1 + 2);

                        if ((found2 != std::string::npos) && (found1 + 2) == found2)
                        {
                            found1 = found2;
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }

                    messageForOutputPane.insert(found1 + 1, VS_STR_CodeXLPrefix);
                }
                else
                {
                    messageForOutputPane.insert(0, VS_STR_CodeXLPrefix);
                }

                messageForOutputPane += VS_STR_NewLine;

                // Add the message to the debug pane:
                BSTR oleMessageString = SysAllocString(messageForOutputPane.c_str());
                spOutputWindowPane->OutputString(oleMessageString);
                SysFreeString(oleMessageString);

                // Reduce the reference count
                spOutputWindowPane->Release();
            }
        }
    }
}
开发者ID:imace,项目名称:CodeXL,代码行数:66,代码来源:vspPackageWrapper.cpp

示例14: parseEngWordForEn

std::wstring parseEngWordForEn(const std::wstring& innerW,const std::wstring& start,const std::wstring& end,int maxLine = 1 )
{
	int pos = 0;
	int endpos = 0;
/*
	for(int i = 0 ; i < maxLine ; i ++ )
	{
		endpos = innerW.find(L"。",endpos);
		if (endpos == std::wstring::npos)
		{
			endpos = innerW.size();
			break;
		}
		endpos ++; //skip 。
	}
*/
	endpos = innerW.size();

	int hit = innerW.find(start,pos);
	if (hit == std::wstring::npos || hit > endpos)
	{
		return L"";
	}
	hit += start.size();
	
	int hyphenpos = innerW.find(L"|",hit);
	int closepos = innerW.find(end,hit);
	if (hyphenpos == std::wstring::npos)
	{
		if (closepos == std::wstring::npos)
		{
			return L"";
		}
	}
	else
	{
		if (closepos == std::wstring::npos)
		{
			closepos = hyphenpos;
		}
		else
		{
			if (closepos > hyphenpos)
			{
				closepos = hyphenpos;
			}
		}
	}

	if (closepos > endpos)
	{
		return L"";
	}
	
	std::wstring a = innerW.substr(hit , closepos - hit);
	a = cleaningYomi(a);
	return a;
}
开发者ID:rti7743,项目名称:wiki2dic,代码行数:58,代码来源:wiki2eng.cpp

示例15: GetSwitchDelimiterLength

int CommandLineArguments::GetSwitchDelimiterLength(std::wstring arg) {
  if (arg.find(L"--") == 0) {
    return 2;
  } else if (arg.find(L"-") == 0 || arg.find(L"/") == 0) {
    return 1;
  }

  return 0;
}
开发者ID:anahorny,项目名称:Selenium2,代码行数:9,代码来源:CommandLineArguments.cpp


注:本文中的std::wstring::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。