本文整理汇总了C++中CStdString::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::find_last_of方法的具体用法?C++ CStdString::find_last_of怎么用?C++ CStdString::find_last_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::find_last_of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayRecording
bool CGUIWindowPVRCommon::PlayRecording(CFileItem *item, bool bPlayMinimized /* = false */)
{
if (item->GetPath().Left(17) != "pvr://recordings/")
return false;
CStdString stream = item->GetPVRRecordingInfoTag()->m_strStreamURL;
if (stream == "")
return false;
/* Isolate the folder from the filename */
size_t found = stream.find_last_of("/");
if (found == CStdString::npos)
found = stream.find_last_of("\\");
if (found != CStdString::npos)
{
/* Check here for asterisk at the begin of the filename */
if (stream[found+1] == '*')
{
/* Create a "stack://" url with all files matching the extension */
CStdString ext = URIUtils::GetExtension(stream);
CStdString dir = stream.substr(0, found).c_str();
CFileItemList items;
CDirectory::GetDirectory(dir, items);
items.Sort(SORT_METHOD_FILE ,SORT_ORDER_ASC);
vector<int> stack;
for (int i = 0; i < items.Size(); ++i)
{
if (URIUtils::GetExtension(items[i]->GetPath()) == ext)
stack.push_back(i);
}
if (stack.size() > 0)
{
/* If we have a stack change the path of the item to it */
CStackDirectory dir;
CStdString stackPath = dir.ConstructStackPath(items, stack);
item->SetPath(stackPath);
}
}
else
{
/* If no asterisk is present play only the given stream URL */
item->SetPath(stream);
}
}
else
{
CLog::Log(LOGERROR, "PVRManager - %s - can't open recording: no valid filename", __FUNCTION__);
CGUIDialogOK::ShowAndGetInput(19033,0,19036,0);
return false;
}
g_application.getApplicationMessenger().PlayFile(*item, false);
return true;
}
示例2: ShortenPath
CStdString CGUILabelControl::ShortenPath(const CStdString &path)
{
if (m_width == 0 || path.empty())
return path;
char cDelim = '\0';
size_t nPos;
nPos = path.find_last_of( '\\' );
if ( nPos != std::string::npos )
cDelim = '\\';
else
{
nPos = path.find_last_of( '/' );
if ( nPos != std::string::npos )
cDelim = '/';
}
if ( cDelim == '\0' )
return path;
CStdString workPath(path);
// remove trailing slashes
if (workPath.size() > 3)
if (!StringUtils::EndsWith(workPath, "://") &&
!StringUtils::EndsWith(workPath, ":\\"))
if (nPos == workPath.size() - 1)
{
workPath.erase(workPath.size() - 1);
nPos = workPath.find_last_of( cDelim );
}
if (m_label.SetText(workPath))
MarkDirtyRegion();
float textWidth = m_label.GetTextWidth();
while ( textWidth > m_width )
{
size_t nGreaterDelim = workPath.find_last_of( cDelim, nPos );
if (nGreaterDelim == std::string::npos)
break;
nPos = workPath.find_last_of( cDelim, nGreaterDelim - 1 );
if ( nPos == std::string::npos )
break;
workPath.replace( nPos + 1, nGreaterDelim - nPos - 1, "..." );
if (m_label.SetText(workPath))
MarkDirtyRegion();
textWidth = m_label.GetTextWidth();
}
return workPath;
}
示例3: ShortenPath
CStdString CGUILabelControl::ShortenPath(const CStdString &path)
{
if (!m_label.font || m_width == 0 || path.IsEmpty())
return path;
char cDelim = '\0';
size_t nPos;
nPos = path.find_last_of( '\\' );
if ( nPos != std::string::npos )
cDelim = '\\';
else
{
nPos = path.find_last_of( '/' );
if ( nPos != std::string::npos )
cDelim = '/';
}
if ( cDelim == '\0' )
return path;
CStdString workPath(path);
// remove trailing slashes
if (workPath.size() > 3)
if (workPath.Right(3).Compare("://") != 0 && workPath.Right(2).Compare(":\\") != 0)
if (nPos == workPath.size() - 1)
{
workPath.erase(workPath.size() - 1);
nPos = workPath.find_last_of( cDelim );
}
float fTextHeight, fTextWidth;
m_textLayout.Update(workPath);
m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
while ( fTextWidth > m_width )
{
size_t nGreaterDelim = workPath.find_last_of( cDelim, nPos );
if (nGreaterDelim == std::string::npos)
break;
nPos = workPath.find_last_of( cDelim, nGreaterDelim - 1 );
if ( nPos == std::string::npos )
break;
workPath.replace( nPos + 1, nGreaterDelim - nPos - 1, "..." );
m_textLayout.Update(workPath);
m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
}
return workPath;
}
示例4: 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");
size_t pos = strFormat.find_last_of("/\\");
if (pos != std::string::npos)
strFormat.erase(0, pos+1);
CLabelFormatter formatter(strFormat, "");
formatter.FormatLabel(&destItem);
// grab the label to use it as our ripped filename
CStdString track = destItem.GetLabel();
if (track.empty())
track = StringUtils::Format("%s%02i", "Track-", trackNumber);
AddonPtr addon;
CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
if (addon)
{
boost::shared_ptr<CAudioEncoder> enc = boost::static_pointer_cast<CAudioEncoder>(addon);
track += enc->extension;
}
return track;
}
示例5: RemoveExtension
void URIUtils::RemoveExtension(CStdString& 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);
}
}
示例6: HasExtension
bool URIUtils::HasExtension(const CStdString& strFileName)
{
if (IsURL(strFileName))
{
CURL url(strFileName);
return HasExtension(url.GetFileName());
}
size_t iPeriod = strFileName.find_last_of("./\\");
return iPeriod != string::npos && strFileName[iPeriod] == '.';
}
示例7: GetFileName
/* handles both / and \, and options in urls*/
const CStdString URIUtils::GetFileName(const CStdString& strFileNameAndPath)
{
if(IsURL(strFileNameAndPath))
{
CURL url(strFileNameAndPath);
return GetFileName(url.GetFileName());
}
/* find the last slash */
const size_t slash = strFileNameAndPath.find_last_of("/\\");
return strFileNameAndPath.substr(slash+1);
}
示例8: GetFileName
/* handles both / and \, and options in urls*/
const CStdString URIUtils::GetFileName(const CStdString& strFileNameAndPath)
{
if(IsURL(strFileNameAndPath))
{
CURL url(strFileNameAndPath);
return GetFileName(url.GetFileName());
}
/* find any slashes */
const int slash1 = strFileNameAndPath.find_last_of('/');
const int slash2 = strFileNameAndPath.find_last_of('\\');
/* select the last one */
int slash;
if(slash2>slash1)
slash = slash2;
else
slash = slash1;
return strFileNameAndPath.substr(slash+1);
}
示例9: GetPESValueForRegistry
CStdString OutlookAddinRegistrar::GetPESValueForRegistry()
{
CStdString sFileName = GetFile();
int pos = (x64_int_cast) sFileName.find_last_of(_T("\\"));
sFileName = sFileName.substr(0, pos+1);
sFileName += _T("Workshare.Client.OutlookExtension.dll");
return _T("4.0;") + sFileName + _T(";1;00000100000001;1001000");
}
示例10: GetExtension
/* returns filename extension including period of filename */
CStdString URIUtils::GetExtension(const CStdString& strFileName)
{
if (IsURL(strFileName))
{
CURL url(strFileName);
return GetExtension(url.GetFileName());
}
size_t period = strFileName.find_last_of("./\\");
if (period == string::npos || strFileName[period] != '.')
return CStdString();
return strFileName.substr(period);
}
示例11: RemoveExtension
CStdString LocalTempCopyOfFile::RemoveExtension(CStdString sFileName)
{
CStdString sFileNameWithoutExtension;
size_t index = sFileName.find_last_of(_T("."));
if ( index != -1 )
{
sFileNameWithoutExtension = sFileName.Left(index);
}
else
{
sFileNameWithoutExtension = sFileName;
}
return sFileNameWithoutExtension;
}
示例12: GetDirectory
CStdString URIUtils::GetDirectory(const CStdString &strFilePath)
{
// Will from a full filename return the directory the file resides in.
// Keeps the final slash at end and possible |option=foo options.
size_t iPosSlash = strFilePath.find_last_of("/\\");
if (iPosSlash == string::npos)
return ""; // No slash, so no path (ignore any options)
size_t iPosBar = strFilePath.rfind('|');
if (iPosBar == string::npos)
return strFilePath.substr(0, iPosSlash + 1); // Only path
return strFilePath.substr(0, iPosSlash + 1) + strFilePath.substr(iPosBar); // Path + options
}
示例13: GetExtension
/* returns filename extension including period of filename */
const CStdString URIUtils::GetExtension(const CStdString& strFileName)
{
if(IsURL(strFileName))
{
CURL url(strFileName);
return GetExtension(url.GetFileName());
}
int period = strFileName.find_last_of('.');
if(period >= 0)
{
if( strFileName.find_first_of('/', period+1) != string::npos ) return "";
if( strFileName.find_first_of('\\', period+1) != string::npos ) return "";
return strFileName.substr(period);
}
else
return "";
}
示例14: BuildServiceType
void CService::BuildServiceType()
{
CStdString str = LibPath();
CStdString ext;
size_t p = str.find_last_of('.');
if (p != string::npos)
ext = str.substr(p + 1);
#ifdef HAS_PYTHON
CStdString pythonExt = ADDON_PYTHON_EXT;
pythonExt.erase(0, 2);
if ( ext.Equals(pythonExt) )
m_type = PYTHON;
else
#endif
{
m_type = UNKNOWN;
CLog::Log(LOGERROR, "ADDON: extension '%s' is not currently supported for service addon", ext.c_str());
}
}
示例15: GetAlbumDirName
CStdString CCDDARipper::GetAlbumDirName(const MUSIC_INFO::CMusicInfoTag& infoTag)
{
CStdString strAlbumDir;
// use audiocds.trackpathformat setting to format
// directory name where CD tracks will be stored,
// use only format part ending at the last '/'
strAlbumDir = CSettings::Get().GetString("audiocds.trackpathformat");
size_t pos = strAlbumDir.find_last_of("/\\");
if (pos == std::string::npos)
return ""; // no directory
strAlbumDir = strAlbumDir.substr(0, pos);
// replace %A with album artist name
if (strAlbumDir.find("%A") != std::string::npos)
{
CStdString strAlbumArtist = StringUtils::Join(infoTag.GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator);
if (strAlbumArtist.empty())
strAlbumArtist = StringUtils::Join(infoTag.GetArtist(), g_advancedSettings.m_musicItemSeparator);
if (strAlbumArtist.empty())
strAlbumArtist = "Unknown Artist";
else
StringUtils::Replace(strAlbumArtist, '/', '_');
StringUtils::Replace(strAlbumDir, "%A", strAlbumArtist);
}
// replace %B with album title
if (strAlbumDir.find("%B") != std::string::npos)
{
CStdString strAlbum = infoTag.GetAlbum();
if (strAlbum.empty())
strAlbum = StringUtils::Format("Unknown Album %s", CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime().c_str());
else
StringUtils::Replace(strAlbum, '/', '_');
StringUtils::Replace(strAlbumDir, "%B", strAlbum);
}
// replace %G with genre
if (strAlbumDir.find("%G") != std::string::npos)
{
CStdString strGenre = StringUtils::Join(infoTag.GetGenre(), g_advancedSettings.m_musicItemSeparator);
if (strGenre.empty())
strGenre = "Unknown Genre";
else
StringUtils::Replace(strGenre, '/', '_');
StringUtils::Replace(strAlbumDir, "%G", strGenre);
}
// replace %Y with year
if (strAlbumDir.find("%Y") != std::string::npos)
{
CStdString strYear = infoTag.GetYearString();
if (strYear.empty())
strYear = "Unknown Year";
else
StringUtils::Replace(strYear, '/', '_');
StringUtils::Replace(strAlbumDir, "%Y", strYear);
}
return strAlbumDir;
}