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


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

本文整理汇总了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");
}
开发者ID:AaronDnz,项目名称:xbmc,代码行数:31,代码来源:ScraperParser.cpp

示例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));
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:OfflineDocIDResolver.cpp

示例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);
	}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:PathReadWriter.cpp

示例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;
	}

}
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:WordVersionChecker.cpp

示例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);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:33,代码来源:pathhelper.cpp

示例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);
}
开发者ID:CEikermann,项目名称:xbmc,代码行数:49,代码来源:GUIDialogAudioSubtitleSettings.cpp

示例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 "";
}
开发者ID:Anankin,项目名称:xbmc,代码行数:7,代码来源:MultiPathDirectory.cpp

示例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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:DemoTestClass.cpp

示例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;
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:26,代码来源:ALSADirectSound.cpp

示例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);
  }
}
开发者ID:dougall08,项目名称:xbmc,代码行数:29,代码来源:RSSDirectory.cpp

示例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;
}
开发者ID:SirTomselon,项目名称:xbmc,代码行数:27,代码来源:TSReader.cpp

示例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;
}
开发者ID:AWilco,项目名称:xbmc,代码行数:60,代码来源:VideoReferenceClock.cpp

示例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);
  }
}
开发者ID:7orlum,项目名称:xbmc,代码行数:35,代码来源:URIUtils.cpp

示例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;
}
开发者ID:CybeSystems,项目名称:XBMCPortable,代码行数:8,代码来源:SmbFile.cpp

示例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;
}
开发者ID:marksuman,项目名称:boxee,代码行数:17,代码来源:GUIDialogBoxeeTechInfo.cpp


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