本文整理汇总了C++中CStdString::find方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::find方法的具体用法?C++ CStdString::find怎么用?C++ CStdString::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplaceBuffers
void CScraperParser::ReplaceBuffers(CStdString& strDest)
{
// insert buffers
int iIndex;
for (int i=MAX_SCRAPER_BUFFERS-1; i>=0; i--)
{
CStdString temp;
iIndex = 0;
temp.Format("$$%i",i+1);
while ((size_t)(iIndex = strDest.find(temp,iIndex)) != CStdString::npos) // COPIED FROM CStdString WITH THE ADDITION OF $ ESCAPING
{
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+temp.GetLength(),m_param[i]);
iIndex += m_param[i].length();
}
}
// insert settings
iIndex = 0;
while ((size_t)(iIndex = strDest.find("$INFO[",iIndex)) != CStdString::npos)
{
int iEnd = strDest.Find("]",iIndex);
CStdString strInfo = strDest.Mid(iIndex+6,iEnd-iIndex-6);
CStdString strReplace;
if (m_scraper)
strReplace = m_scraper->GetSetting(strInfo);
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iEnd+1,strReplace);
iIndex += strReplace.length();
}
iIndex = 0;
while ((size_t)(iIndex = strDest.find("\\n",iIndex)) != CStdString::npos)
strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+2,"\n");
}
示例2: GetLibrary
CStdString OfflineDocIDResolver::GetLibrary( const CStdString& sDocID ) const
{
int iPosStart = (x64_int_cast)sDocID.find( _T("//") );
int iPosEnd = (x64_int_cast)sDocID.find( _T('/'), iPosStart + 2 );
return sDocID.Mid(iPosStart + 2, iPosEnd - (iPosStart + 2));
}
示例3: GetPathList
void PathReadWriter::GetPathList(const CStdString& sPathList, std::vector<CStdString>& pathList)
{
pathList.clear();
pathList.reserve(std::count(sPathList.begin(), sPathList.end(), _T(';')) + 1);
int nStartPos = 0;
for (int nEndPos = (int) sPathList.find(_T(';'));
nEndPos >= 0;
nEndPos = (int) sPathList.find(_T(';'), nStartPos = nEndPos + 1))
{
CStdString sSubPath = sPathList.Mid(nStartPos, nEndPos - nStartPos).Trim();
if (!sSubPath.IsEmpty())
{
::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
sSubPath.ReleaseBuffer();
pathList.push_back(sSubPath);
}
}
CStdString sSubPath = sPathList.Mid(nStartPos).Trim();
if (!sSubPath.IsEmpty())
{
::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
sSubPath.ReleaseBuffer();
pathList.push_back(sSubPath);
}
}
示例4: ConvertNameToVersion
WordVersions WordVersionChecker::ConvertNameToVersion(const CStdString& sVersionName)
{
CStdString sMajVersion = sVersionName;
if (sVersionName.find(_T('.'))!=-1)
{
sMajVersion = sVersionName.Left(sVersionName.find(_T('.')));
}
int iMajVer = _ttoi(sVersionName.c_str());
switch (iMajVer)
{
case 8:
return WORD_97;
case 9:
return WORD_2K;
case 10:
return WORD_XP;
case 11:
return WORD_2003;
case 12:
return WORD_2007;
case 14:
return WORD_2010;
default:
return UNKNOWN_WORD_VERSION;
}
}
示例5: RemoveFromPath
void PathHelper::RemoveFromPath(CStdString sPath)
{
CStdString sFullPath = GetProcessPath();
sFullPath.ToLower();
sPath.ToLower();
if ( sPath.Right(1) == _T("\\") )
{
sPath = sPath.Left(sPath.length() - 1);
}
int nStart = (x64_int_cast)sFullPath.find(sPath);
while (nStart >= 0) // there may be multiple copies
{
int nEnd = nStart + (x64_int_cast)sPath.length() + 1;
sFullPath = sFullPath.Left(nStart) + sFullPath.Right(sFullPath.length() - nEnd );
sFullPath.TrimRight();
sFullPath.TrimLeft();
if (sFullPath.Left(1) == _T(";"))
sFullPath = sFullPath.Mid(1);
sFullPath.Replace(_T(";;"),_T(";"));
nStart = (x64_int_cast)sFullPath.find(sPath);
}
SetProcessPath(sFullPath);
}
示例6: AddAudioStreams
void CGUIDialogAudioSubtitleSettings::AddAudioStreams(CSettingGroup *group, const std::string &settingId)
{
m_audioStreamStereoMode = false;
if (group == NULL || settingId.empty())
return;
m_audioStream = g_application.m_pPlayer->GetAudioStream();
if (m_audioStream < 0)
m_audioStream = 0;
// check if we have a single, stereo stream, and if so, allow us to split into
// left, right or both
if (g_application.m_pPlayer->GetAudioStreamCount() == 1)
{
CStdString strAudioInfo;
g_application.m_pPlayer->GetAudioInfo(strAudioInfo);
/* TODO:STRING_CLEANUP */
int iNumChannels = 0;
size_t pos = strAudioInfo.find("chns:");
if (pos != std::string::npos)
iNumChannels = static_cast<int>(strtol(strAudioInfo.substr(pos + 5).c_str(), NULL, 0));
std::string strAudioCodec;
if (strAudioInfo.size() > 7)
strAudioCodec = strAudioInfo.substr(7, strAudioInfo.find(") VBR") - 5);
bool bDTS = strAudioCodec.find("DTS") != std::string::npos;
bool bAC3 = strAudioCodec.find("AC3") != std::string::npos;
if (iNumChannels == 2 && !(bDTS || bAC3))
{ // ok, enable these options
/* if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream == -1)
{ // default to stereo stream
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = 0;
}*/
StaticIntegerSettingOptions options;
for (int i = 0; i < 3; ++i)
options.push_back(make_pair(i, 13320 + i));
m_audioStream = -CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream - 1;
m_audioStreamStereoMode = true;
AddSpinner(group, settingId, 460, 0, m_audioStream, options);
return;
}
}
AddSpinner(group, settingId, 460, 0, m_audioStream, AudioStreamsOptionFiller);
}
示例7: GetFirstPath
CStdString CMultiPathDirectory::GetFirstPath(const CStdString &strPath)
{
size_t pos = strPath.find("/", 12);
if (pos != std::string::npos)
return CURL::Decode(strPath.substr(12, pos - 12));
return "";
}
示例8: GetWordPath
bool TestWindowActivate::GetWordPath(CStdString& csWordPath)
{
if( !m_csWordPath.IsEmpty() )
return true;
TCHAR szValue[MAX_PATH]={0};
DWORD cbValue = MAX_PATH;
DWORD wKeyType = REG_SZ;
HKEY hStartKey = NULL;
bool bRet = false;
CStdString csPossibleResult;
assertTest( RegOpenKey( HKEY_CLASSES_ROOT,
_T("\\Word.Document.8\\shell\\Open\\command"),
&hStartKey) == ERROR_SUCCESS );
assertTest( RegQueryValueEx(hStartKey, NULL, NULL,
&wKeyType,
(unsigned char*) szValue,
&cbValue) == ERROR_SUCCESS);
csPossibleResult = szValue;
csPossibleResult.ToLower();
int iFind =(x64_int_cast) csPossibleResult.find( _T("winword.exe") );
if( iFind != CStdString::npos )
{
m_csWordPath = csPossibleResult;
bRet = true;
}
RegCloseKey(hStartKey);
return bRet;
}
示例9: SoundDeviceExists
bool CALSADirectSound::SoundDeviceExists(const CStdString& device)
{
void **hints, **n;
char *name;
CStdString strName;
bool retval = false;
if (snd_device_name_hint(-1, "pcm", &hints) == 0)
{
for (n = hints; *n; n++)
{
if ((name = snd_device_name_get_hint(*n, "NAME")) != NULL)
{
strName = name;
if (strName.find(device) != string::npos)
{
retval = true;
break;
}
free(name);
}
}
snd_device_name_free_hint(hints);
}
return retval;
}
示例10: ParseItem
static void ParseItem(CFileItem* item, SResources& resources, TiXmlElement* root, const CStdString& path)
{
for (TiXmlElement* child = root->FirstChildElement(); child; child = child->NextSiblingElement())
{
CStdString name = child->Value();
CStdString xmlns;
size_t pos = name.find(':');
if(pos != std::string::npos)
{
xmlns = name.substr(0, pos);
name.erase(0, pos+1);
}
if (xmlns == "media")
ParseItemMRSS (item, resources, child, name, xmlns, path);
else if (xmlns == "itunes")
ParseItemItunes (item, resources, child, name, xmlns, path);
else if (xmlns == "voddler")
ParseItemVoddler(item, resources, child, name, xmlns, path);
else if (xmlns == "boxee")
ParseItemBoxee (item, resources, child, name, xmlns, path);
else if (xmlns == "zn")
ParseItemZink (item, resources, child, name, xmlns, path);
else if (xmlns == "svtplay")
ParseItemSVT (item, resources, child, name, xmlns, path);
else
ParseItemRSS (item, resources, child, name, xmlns, path);
}
}
示例11: TranslatePath
std::string CTsReader::TranslatePath(const char* pszFileName)
{
if (m_basePath.length() == 0)
return pszFileName;
CStdString sTimeshiftFile = pszFileName;
size_t found = string::npos;
if ((m_cardSettings) && (m_cardSettings->size() > 0))
{
for (CCards::iterator it = m_cardSettings->begin(); it < m_cardSettings->end(); it++)
{
// Determine whether the first part of the timeshift file name is shared with this card
found = sTimeshiftFile.find(it->TimeshiftingFolder);
if (found != string::npos)
{
// Remove the original base path and replace it with the given path
sTimeshiftFile = m_basePath + sTimeshiftFile.substr(it->TimeshiftingFolder.length()+1);
break;
}
}
XBMC->Log(LOG_DEBUG, "CTsReader:TranslatePath %s -> %s", pszFileName, sTimeshiftFile.c_str());
return sTimeshiftFile;
}
return pszFileName;
}
示例12: ParseNvSettings
bool CVideoReferenceClock::ParseNvSettings(int& RefreshRate)
{
double fRefreshRate;
char Buff[255];
int ReturnV;
struct lconv *Locale = localeconv();
FILE* NvSettings;
const char* VendorPtr = (const char*)glGetString(GL_VENDOR);
if (!VendorPtr)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: glGetString(GL_VENDOR) returned NULL, not using nvidia-settings");
return false;
}
CStdString Vendor = VendorPtr;
Vendor.ToLower();
if (Vendor.find("nvidia") == std::string::npos)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR:%s, not using nvidia-settings", Vendor.c_str());
return false;
}
NvSettings = popen(NVSETTINGSCMD, "r");
if (!NvSettings)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: %s: %s", NVSETTINGSCMD, strerror(errno));
return false;
}
ReturnV = fscanf(NvSettings, "%254[^\n]", Buff);
pclose(NvSettings);
if (ReturnV != 1)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: %s produced no output", NVSETTINGSCMD);
return false;
}
CLog::Log(LOGDEBUG, "CVideoReferenceClock: output of %s: %s", NVSETTINGSCMD, Buff);
for (int i = 0; i < 255 && Buff[i]; i++)
{
//workaround for locale mismatch
if (Buff[i] == '.' || Buff[i] == ',')
Buff[i] = *Locale->decimal_point;
}
ReturnV = sscanf(Buff, "%lf", &fRefreshRate);
if (ReturnV != 1 || fRefreshRate <= 0.0)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: can't make sense of that");
return false;
}
RefreshRate = MathUtils::round_int(fRefreshRate);
CLog::Log(LOGDEBUG, "CVideoReferenceClock: Detected refreshrate by nvidia-settings: %f hertz, rounding to %i hertz",
fRefreshRate, RefreshRate);
return true;
}
示例13: RemoveExtension
void URIUtils::RemoveExtension(std::string& strFileName)
{
if(IsURL(strFileName))
{
CURL url(strFileName);
strFileName = url.GetFileName();
RemoveExtension(strFileName);
url.SetFileName(strFileName);
strFileName = url.Get();
return;
}
size_t period = strFileName.find_last_of("./\\");
if (period != string::npos && strFileName[period] == '.')
{
CStdString strExtension = strFileName.substr(period);
StringUtils::ToLower(strExtension);
strExtension += "|";
CStdString strFileMask;
strFileMask = g_advancedSettings.m_pictureExtensions;
strFileMask += "|" + g_advancedSettings.m_musicExtensions;
strFileMask += "|" + g_advancedSettings.m_videoExtensions;
strFileMask += "|" + g_advancedSettings.m_subtitlesExtensions;
#if defined(TARGET_DARWIN)
strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg|.app|.applescript|.workflow";
#else
strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg";
#endif
strFileMask += "|";
if (strFileMask.find(strExtension) != std::string::npos)
strFileName.erase(period);
}
}
示例14: IsValidFile
bool CSmbFile::IsValidFile(const CStdString& strFileName)
{
if (strFileName.find('/') == std::string::npos || /* doesn't have sharename */
StringUtils::EndsWith(strFileName, "/.") || /* not current folder */
StringUtils::EndsWith(strFileName, "/..")) /* not parent folder */
return false;
return true;
}
示例15: removeNItem
CStdString CGUIDialogBoxeeTechInfo::removeNItem(int n, CStdString str)
{
size_t pos;
CStdString tempStr;
for (int i=1; i<n; i++)
{
pos = str.find(",");
tempStr = tempStr.c_str() + str.substr(0, pos+2);
str = str.substr(pos+2);
//printf ("CGUIDialogBoxeeTechInfo::removeNItem - str: %s, tempStr: %s\n",str.c_str(), tempStr.c_str());
}
pos = str.find(",");
str = str.substr(pos+2);
tempStr = tempStr + str;
return tempStr;
}