本文整理汇总了C++中CStdString::ReverseFind方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::ReverseFind方法的具体用法?C++ CStdString::ReverseFind怎么用?C++ CStdString::ReverseFind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::ReverseFind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTrackName
CStdString CCDDARipper::GetTrackName(CFileItem *item)
{
// get track number from "cdda://local/01.cdda"
int trackNumber = atoi(item->GetPath().substr(13, item->GetPath().size() - 13 - 5).c_str());
// Format up our ripped file label
CFileItem destItem(*item);
destItem.SetLabel("");
// get track file name format from audiocds.trackpathformat setting,
// use only format part starting from the last '/'
CStdString strFormat = CSettings::Get().GetString("audiocds.trackpathformat");
int pos = max(strFormat.ReverseFind('/'), strFormat.ReverseFind('\\'));
if (pos != -1)
{
strFormat = strFormat.Right(strFormat.GetLength() - pos - 1);
}
CLabelFormatter formatter(strFormat, "");
formatter.FormatLabel(&destItem);
// grab the label to use it as our ripped filename
CStdString track = destItem.GetLabel();
if (track.IsEmpty())
track.Format("%s%02i", "Track-", trackNumber);
track += GetExtension(CSettings::Get().GetInt("audiocds.encoder"));
return track;
}
示例2: GetCurrLevel
int CDAAPDirectory::GetCurrLevel(CStdString strPath)
{
int intSPos;
int intEPos;
int intLevel;
int intCnt;
CStdString strJustPath;
intSPos = strPath.Find("://");
if (intSPos > -1)
strJustPath = strPath.Right(strPath.size() - (intSPos + 3));
else
strJustPath = strPath;
URIUtils::RemoveSlashAtEnd(strJustPath);
intLevel = -1;
intSPos = strPath.length();
while (intSPos > -1)
{
intSPos = strJustPath.ReverseFind("/", intSPos);
if (intSPos > -1) intLevel ++;
intSPos -= 2;
}
m_selectedPlaylist = "";
m_selectedArtist = "";
m_selectedAlbum = "";
intCnt = intLevel;
intEPos = (strJustPath.length() - 1);
while (intCnt >= 0)
{
intSPos = strJustPath.ReverseFind("/", intEPos);
if (intSPos > -1)
{
if (intCnt == 2) // album
{
m_selectedAlbum = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
}
else if (intCnt == 1) // artist
{
m_selectedArtist = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
}
else if (intCnt == 0) // playlist
{
m_selectedPlaylist = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
}
intEPos = (intSPos - 1);
intCnt --;
}
}
return intLevel;
}
示例3: FilePath
CStdString FilePath(CStdString& path)
{
CStdString result;
int lastSeparatorPosition = path.ReverseFind('/');
if(lastSeparatorPosition == -1)
{
lastSeparatorPosition = path.ReverseFind('\\');
}
if(lastSeparatorPosition != -1 && path.GetLength()>3)
{
result = path.Left(lastSeparatorPosition + 1);
}
return result;
}
示例4: Update
void CPVRRecording::Update(const CPVRRecording &tag)
{
m_strRecordingId = tag.m_strRecordingId;
m_iClientId = tag.m_iClientId;
m_strTitle = tag.m_strTitle;
m_recordingTime = tag.m_recordingTime;
m_duration = tag.m_duration;
m_iPriority = tag.m_iPriority;
m_iLifetime = tag.m_iLifetime;
m_strDirectory = tag.m_strDirectory;
m_strPlot = tag.m_strPlot;
m_strPlotOutline = tag.m_strPlotOutline;
m_strStreamURL = tag.m_strStreamURL;
m_strChannelName = tag.m_strChannelName;
m_strGenre = tag.m_strGenre;
CStdString strShow;
strShow.Format("%s - ", g_localizeStrings.Get(20364).c_str());
if (m_strPlotOutline.Left(strShow.size()).Equals(strShow))
{
CStdString strEpisode = m_strPlotOutline;
CStdString strTitle = m_strDirectory;
int pos = strTitle.ReverseFind('/');
strTitle.erase(0, pos + 1);
strEpisode.erase(0, strShow.size());
m_strTitle.Format("%s - %s", strTitle.c_str(), strEpisode);
pos = strEpisode.Find('-');
strEpisode.erase(0, pos + 2);
m_strPlotOutline = strEpisode;
}
UpdatePath();
}
示例5: GetTestPath
CStdString CTestUtils::GetTestPath(const CStdString& sModule)
{
CStdString sModuleName = sModule;
sModuleName.ToLower();
if ((sModuleName.Find(ARCHDIR + _T( "\\debug\\")) != -1) ||
(sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1))
{
return PathBefore(sModuleName, ARCHDIR ) + "\\Test Files\\";
}
if (sModuleName.Find(_T("\\common\\testingframework\\")) != -1)
{
return PathBefore(sModuleName, "\\common") + "\\Test Files\\";
}
int iFileName = sModuleName.Find(_T("\\testharness.exe")) ;
if (iFileName != -1)
{
return sModuleName.Mid(0, sModuleName.Find(_T("testharness.exe"))) + _T("Test Files\\");
}
iFileName = sModuleName.ReverseFind('\\');
if (iFileName != -1)
{
return sModuleName.Mid(0, iFileName) + _T("Tests\\Test Files\\");
}
return _T("");
}
示例6: Init
bool ASAPCodec::Init(const CStdString &strFile, unsigned int filecache)
{
if (!m_dll.Load())
return false;
CStdString strFileToLoad = strFile;
int song = -1;
CStdString strExtension;
CUtil::GetExtension(strFile, strExtension);
strExtension.MakeLower();
if (strExtension == ".asapstream")
{
CStdString strFileName = CUtil::GetFileName(strFile);
int iStart = strFileName.ReverseFind('-') + 1;
song = atoi(strFileName.substr(iStart, strFileName.size() - iStart - 11).c_str()) - 1;
CStdString strPath = strFile;
CUtil::GetDirectory(strPath, strFileToLoad);
CUtil::RemoveSlashAtEnd(strFileToLoad);
}
int duration;
if (!m_dll.asapLoad(strFileToLoad.c_str(), song, &m_Channels, &duration))
return false;
m_TotalTime = duration;
m_SampleRate = 44100;
m_BitsPerSample = 16;
return true;
}
示例7: RemoveExtension
void URIUtils::RemoveExtension(CStdString& strFileName)
{
if(IsURL(strFileName))
{
CURL url(strFileName);
strFileName = url.GetFileName();
RemoveExtension(strFileName);
url.SetFileName(strFileName);
strFileName = url.Get();
return;
}
int iPos = strFileName.ReverseFind(".");
// Extension found
if (iPos > 0)
{
CStdString strExtension = GetExtension(strFileName);
strExtension.ToLower();
strExtension += "|";
CStdString strFileMask;
strFileMask = g_advancedSettings.m_pictureExtensions;
strFileMask += "|" + g_advancedSettings.m_musicExtensions;
strFileMask += "|" + g_advancedSettings.m_videoExtensions;
#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) >= 0)
strFileName = strFileName.Left(iPos);
}
}
示例8: GetBinaryInstalledPath
CStdString CTestUtils::GetBinaryInstalledPath(const CStdString& sBinaryName)
{
CStdString sModuleName = GetLongModuleName();
sModuleName.ToLower();
if ((sModuleName.Find(ARCHDIR + _T( "\\debug\\")) != -1) ||
(sModuleName.Find(_T("\\common\\testingframework\\debug\\")) != -1) ||
(sModuleName.Find(_T("\\common\\testingframework\\debug unicode\\")) != -1))
{
CStdString sLikelyPath = StopStringAfter(sModuleName, ARCHDIR + L"\\debug\\");
if (_taccess(sLikelyPath + sBinaryName, 0) != -1)
{
return (sLikelyPath) + sBinaryName;
}
}
if ((sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1) ||
(sModuleName.Find(_T("\\common\\testingframework\\release\\")) != -1) ||
(sModuleName.Find(_T("\\common\\testingframework\\release unicode\\")) != -1))
{
CStdString sLikelyPath = StopStringAfter(sModuleName, ARCHDIR + L"\\release\\");
if (_taccess(sLikelyPath + sBinaryName, 0) != -1)
{
return sLikelyPath + sBinaryName;
}
}
int iFileName = sModuleName.Find(_T("\\testharness.exe")) ;
if (iFileName != -1)
{
CStdString sDir = sModuleName.Mid(0, sModuleName.Find(_T("tests\\testharness.exe")));
if (_taccess(sDir + sBinaryName, 0) != -1)
{
return sDir + sBinaryName;
}
if (_taccess(sDir + _T("Tests\\") + sBinaryName, 0) != -1)
{
return sDir + _T("Tests\\") + sBinaryName;
}
}
iFileName = sModuleName.ReverseFind('\\');
if (iFileName != -1)
{
CStdString sDir = sModuleName.Mid(0, iFileName+1);
if (_taccess(sDir + sBinaryName, 0) != -1)
{
return sDir + sBinaryName;
}
}
return _T("");
}
示例9: SetCore
HRESULT CWmp_scrobbler::SetCore(IWMPCore *pCore)
{
HRESULT hr = S_OK;
// release any existing WMP core interfaces
ReleaseCore();
// If we get passed a NULL core, this means
// that the plugin is being shutdown.
if (pCore == NULL)
{
return S_OK;
}
m_spCore = pCore;
// connect up the event interface
CComPtr<IConnectionPointContainer> spConnectionContainer;
hr = m_spCore->QueryInterface( &spConnectionContainer );
if (SUCCEEDED(hr))
{
hr = spConnectionContainer->FindConnectionPoint( __uuidof(IWMPEvents), &m_spConnectionPoint );
}
if (SUCCEEDED(hr))
{
hr = m_spConnectionPoint->Advise( GetUnknown(), &m_dwAdviseCookie );
if ((FAILED(hr)) || (0 == m_dwAdviseCookie))
{
m_spConnectionPoint = NULL;
}
}
m_wmpBootStrap.setParentHwnd( FindWindow( "WMPlayerApp", "Windows Media Player" ) );
char filename[512];
// Get the DLL filename etc
GetModuleFileName( _Module.GetModuleInstance(), filename, sizeof( filename ) );
CStdString Temp = filename;
int pos = Temp.ReverseFind('\\');
StartScrobbling( Temp.Left( pos + 1 ), _Module.GetModuleInstance() );
if( m_wmpBootStrap.bootStrapRequired() )
{
m_wmpBootStrap.setCore( m_spCore );
m_wmpBootStrap.setScrobSub( &m_Submitter );
m_wmpBootStrap.setModuleHandle( _Module.GetModuleInstance() );
m_wmpBootStrap.startBootStrap();
}
return hr;
}
示例10: FileBaseName
CStdString FileBaseName(CStdString& path)
{
CStdString result;
int lastSeparatorPosition = path.ReverseFind('/');
if(lastSeparatorPosition == -1)
{
lastSeparatorPosition = path.ReverseFind('\\');
}
if(lastSeparatorPosition != -1 && path.GetLength()>3)
{
result = path.Right(path.GetLength() - lastSeparatorPosition - 1);
}
else
{
result = path;
}
return result;
}
示例11: Init
bool Codec::Init(const CStdString & strFile, unsigned int filecache) {
m_bufferSize = 2048 * sizeof(int16_t) * 50;
m_buffer = new char[m_bufferSize];
CStdString uri = URIUtils::GetFileName(strFile);
CStdString extension = uri.Right(uri.GetLength() - uri.Find('.') - 1);
if (extension.Left(12) == "spotifyradio") {
//if its a radiotrack the radionumber and tracknumber is secretly encoded at the end of the extension
CStdString trackStr = extension.Right(
extension.GetLength() - extension.ReverseFind('#') - 1);
Logger::printOut(extension);
CStdString radioNumber = extension.Left(uri.Find('#'));
Logger::printOut(radioNumber);
radioNumber = radioNumber.Right(
radioNumber.GetLength() - radioNumber.Find('#') - 1);
Logger::printOut("loading codec radio");
RadioHandler::getInstance()->pushToTrack(atoi(radioNumber),
atoi(trackStr));
}
//we have a non legit extension so remove it manually
uri = uri.Left(uri.Find('.'));
Logger::printOut("trying to load track:");
Logger::printOut(uri);
sp_link *spLink = sp_link_create_from_string(uri);
m_currentTrack = sp_link_as_track(spLink);
sp_track_add_ref(m_currentTrack);
sp_link_release(spLink);
m_endOfTrack = false;
m_bufferPos = 0;
m_startStream = false;
m_isPlayerLoaded = false;
m_TotalTime = sp_track_duration(m_currentTrack);
//prefetch the next track!
CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
int nextSong = g_playlistPlayer.GetNextSong();
if (nextSong >= 0 && nextSong < playlist.size()){
CFileItemPtr song = playlist[nextSong];
if (song != NULL){
CStdString uri = song->GetPath();
if (uri.Left(7).Equals("spotify")){
uri = uri.Left(uri.Find('.'));
Logger::printOut("prefetching track:");
Logger::printOut(uri);
sp_link *spLink = sp_link_create_from_string(uri);
sp_track* track = sp_link_as_track(spLink);
sp_session_player_prefetch(getSession(), track);
sp_link_release(spLink);
}
}
}
return true;
}
示例12: AddBackslashIfNecessary
void CTestUtils::AddBackslashIfNecessary(CStdString& sTempPath)
{
if(IsDirectory(sTempPath))
{
if (sTempPath.ReverseFind('\\') != (sTempPath.length() - 1))
{
sTempPath += _T("\\");
}
}
}
示例13: GetFilePath
CStdString CDefragStorage::GetFilePath(CStdString sFullName)
{
sFullName.Replace(_T('/'),'\\');
int iLastDirPos = sFullName.ReverseFind('\\');
if (iLastDirPos == -1)
return _T("");
return sFullName.Left(iLastDirPos+1);
}
示例14: GetDirectory
void URIUtils::GetDirectory(const CStdString& strFilePath,
CStdString& strDirectoryPath)
{
// Will from a full filename return the directory the file resides in.
// Keeps the final slash at end
int iPos1 = strFilePath.ReverseFind('/');
int iPos2 = strFilePath.ReverseFind('\\');
if (iPos2 > iPos1)
{
iPos1 = iPos2;
}
if (iPos1 > 0)
{
strDirectoryPath = strFilePath.Left(iPos1 + 1); // include the slash
}
}
示例15: GetProfilesRoot
CStdString SystemFolderInfo::GetProfilesRoot()
{
CStdString sPath;
switch (GetWindowsVersion())
{
case WINDOWS_95:
case WINDOWS_ME:
case WINDOWS_98:
{
sPath = GetWindowsPath();
if (HasWin98UserGotProfile())
sPath += _T("\\Profiles");
}
break;
case WINDOWS_NT:
{
sPath = GetLocalUserAppDataPath();
int nPos = sPath.ReverseFind('\\');
sPath = sPath.Left(nPos);
nPos = sPath.ReverseFind('\\');
sPath = sPath.Left(nPos);
}
break;
case WINDOWS_2003SERVER:
case WINDOWS_2K:
case WINDOWS_XP:
default:
{
sPath = GetProfilesDirectory();
}
break;
}
return sPath;
}