本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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"";
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
示例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;
}
示例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;
}