本文整理汇总了C++中CStdString::TrimRight方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::TrimRight方法的具体用法?C++ CStdString::TrimRight怎么用?C++ CStdString::TrimRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::TrimRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_pair
pair<CStdString,CStdString> CPartyModeManager::GetWhereClauseWithHistory() const
{
CStdString historyWhereMusic;
CStdString historyWhereVideo;
// now add this on to the normal where clause
if (m_history.size())
{
if (m_strCurrentFilterMusic.IsEmpty())
historyWhereMusic = "songview.idSong not in (";
else
historyWhereMusic = m_strCurrentFilterMusic + " and songview.idSong not in (";
if (m_strCurrentFilterVideo.IsEmpty())
historyWhereVideo = "idMVideo not in (";
else
historyWhereVideo = m_strCurrentFilterVideo + " and idMVideo not in (";
for (unsigned int i = 0; i < m_history.size(); i++)
{
CStdString number;
number.Format("%i,", m_history[i].second);
if (m_history[i].first == 1)
historyWhereMusic += number;
if (m_history[i].first == 2)
historyWhereVideo += number;
}
historyWhereMusic.TrimRight(",");
historyWhereMusic += ")";
historyWhereVideo.TrimRight(",");
historyWhereVideo += ")";
}
return make_pair(historyWhereMusic,historyWhereVideo);
}
示例2: IsSource
/*!
\brief Is the share \e strPath in the virtual directory.
\param strPath Share to test
\return Returns \e true, if share is in the virtual directory.
\note The parameter \e strPath can not be a share with directory. Eg. "iso9660://dir" will return \e false.
It must be "iso9660://".
*/
bool CVirtualDirectory::IsSource(const CStdString& strPath, VECSOURCES *sources, CStdString *name) const
{
CStdString strPathCpy = strPath;
strPathCpy.TrimRight("/");
strPathCpy.TrimRight("\\");
// just to make sure there's no mixed slashing in share/default defines
// ie. f:/video and f:\video was not be recognised as the same directory,
// resulting in navigation to a lower directory then the share.
if(URIUtils::IsDOSPath(strPathCpy))
strPathCpy.Replace("/", "\\");
VECSOURCES shares;
if (sources)
shares = *sources;
else
GetSources(shares);
for (int i = 0; i < (int)shares.size(); ++i)
{
const CMediaSource& share = shares.at(i);
CStdString strShare = share.strPath;
strShare.TrimRight("/");
strShare.TrimRight("\\");
if(URIUtils::IsDOSPath(strShare))
strShare.Replace("/", "\\");
if (strShare == strPathCpy)
{
if (name)
*name = share.strName;
return true;
}
}
return false;
}
示例3: 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);
}
示例4: ParseIPFilter
bool ParseIPFilter(CStdString in, std::list<CStdString>* output /*=0*/)
{
bool valid = true;
in.Replace(_T("\n"), _T(" "));
in.Replace(_T("\r"), _T(" "));
in.Replace(_T("\t"), _T(" "));
while (in.Replace(_T(" "), _T(" ")));
in.TrimLeft(_T(" "));
in.TrimRight(_T(" "));
in += _T(" ");
int pos;
while ((pos = in.Find(_T(" "))) != -1)
{
CStdString ip = in.Left(pos);
if (ip == _T(""))
break;
in = in.Mid(pos + 1);
if (ip == _T("*") || IsValidAddressFilter(ip))
{
if (output)
output->push_back(ip);
}
else
valid = false;
}
return valid;
}
示例5: LocalizeOverview
void CWeatherJob::LocalizeOverview(CStdString &str)
{
CStdStringArray words;
StringUtils::SplitString(str, " ", words);
str.clear();
for (unsigned int i = 0; i < words.size(); i++)
{
LocalizeOverviewToken(words[i]);
str += words[i] + " ";
}
str.TrimRight(" ");
}
示例6: DecodeImageURL
CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info)
{
// unwrap the URL as required
CStdString image(url);
additional_info.clear();
width = height = 0;
if (url.compare(0, 8, "image://") == 0)
{
// format is image://[[email protected]]<url_encoded_path>?options
CURL thumbURL(url);
if (!thumbURL.GetUserName().IsEmpty())
{
if (thumbURL.GetUserName() == "music")
additional_info = "music";
else
return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs)
}
image = thumbURL.GetHostName();
CURL::Decode(image);
CStdString optionString = thumbURL.GetOptions().Mid(1);
optionString.TrimRight('/'); // in case XBMC adds a slash
std::vector<CStdString> options;
StringUtils::SplitString(optionString, "&", options);
for (std::vector<CStdString>::iterator i = options.begin(); i != options.end(); i++)
{
CStdString option, value;
int pos = i->Find('=');
if (pos != -1)
{
option = i->Left(pos);
value = i->Mid(pos + 1);
}
else
{
option = *i;
value = "";
}
if (option == "size" && value == "thumb")
{
width = height = g_advancedSettings.GetThumbSize();
}
else if (option == "flipped")
{
additional_info = "flipped";
}
}
}
return image;
}
示例7: GetCast
const CStdString CVideoInfoTag::GetCast(bool bIncludeRole /*= false*/) const
{
CStdString strLabel;
for (iCast it = m_cast.begin(); it != m_cast.end(); ++it)
{
CStdString character;
if (it->strRole.IsEmpty() || !bIncludeRole)
character.Format("%s\n", it->strName.c_str());
else
character.Format("%s %s %s\n", it->strName.c_str(), g_localizeStrings.Get(20347).c_str(), it->strRole.c_str());
strLabel += character;
}
return strLabel.TrimRight("\n");
}
示例8: ForceDirectory
bool DocProvHelper::ForceDirectory(CStdString lpDirectory) const
{
ASSERT(lpDirectory);
CStdString szDirectory = lpDirectory;
/* TXTEX_IGNORE */ szDirectory.TrimRight(_T("\\"));
/* TXTEX_IGNORE */ szDirectory.TrimRight(_T("/"));
if( (GetFilePath(szDirectory) == szDirectory) || CGeneral::FileExists(szDirectory) )
return true;
if (PathIsUNCFolderShare(szDirectory))
return true; // if it_T('s a share assume it exists - it')ll fail at the next level up if not
if(!ForceDirectory(GetFilePath(szDirectory)))
return false;
if (!CreateDirectory(szDirectory, NULL))
return false;
return true;
}
示例9: GetMemoryUnitSources
void CMemoryUnitManager::GetMemoryUnitSources(VECSOURCES &shares)
{
for (unsigned int i = 0; i < m_memUnits.size(); i++)
{
CMediaSource share;
CStdString volumeName = m_memUnits[i]->GetVolumeName();
volumeName.TrimRight(' ');
// Memory Unit # (volumeName) (fs)
if (volumeName.IsEmpty())
share.strName.Format("%s %i (%s)", g_localizeStrings.Get(20136).c_str(), i + 1, m_memUnits[i]->GetFileSystem());
else
share.strName.Format("%s %i (%s) (%s)", g_localizeStrings.Get(20136).c_str(), i + 1, volumeName.c_str(), m_memUnits[i]->GetFileSystem());
share.strPath.Format("mem%i://", i);
shares.push_back(share);
}
}
示例10: GetDiskLabel
CStdString CMediaManager::GetDiskLabel(const CStdString& devicePath)
{
#ifdef TARGET_WINDOWS
if(!m_bhasoptical)
return "";
CStdString strDevice = TranslateDevicePath(devicePath);
WCHAR cVolumenName[128];
WCHAR cFSName[128];
URIUtils::AddSlashAtEnd(strDevice);
if(GetVolumeInformationW(CStdStringW(strDevice).c_str(), cVolumenName, 127, NULL, NULL, NULL, cFSName, 127)==0)
return "";
g_charsetConverter.wToUTF8(cVolumenName, strDevice);
return strDevice.TrimRight(" ");
#else
return MEDIA_DETECT::CDetectDVDMedia::GetDVDLabel();
#endif
}
示例11: TranslateSingleString
bool CGUIDialogPluginSettings::TranslateSingleString(const CStdString &strCondition, vector<CStdString> &condVec)
{
CStdString strTest = strCondition;
strTest.ToLower();
strTest.TrimLeft(" ");
strTest.TrimRight(" ");
int pos1 = strTest.Find("(");
int pos2 = strTest.Find(",");
int pos3 = strTest.Find(")");
if (pos1 >= 0 && pos2 > pos1 && pos3 > pos2)
{
condVec.push_back(strTest.Left(pos1));
condVec.push_back(strTest.Mid(pos1 + 1, pos2 - pos1 - 1));
condVec.push_back(strTest.Mid(pos2 + 1, pos3 - pos2 - 1));
return true;
}
return false;
}
示例12: GetResource
/*----------------------------------------------------------------------
| CUPnPDirectory::GetDirectory
+---------------------------------------------------------------------*/
bool CUPnPDirectory::GetResource(const CURL& path, CFileItem &item)
{
if(path.GetProtocol() != "upnp")
return false;
CUPnP* upnp = CUPnP::GetInstance();
if(!upnp)
return false;
CStdString uuid = path.GetHostName();
CStdString object = path.GetFileName();
object.TrimRight("/");
CURL::Decode(object);
PLT_DeviceDataReference device;
if(!FindDeviceWait(upnp, uuid.c_str(), device)) {
CLog::Log(LOGERROR, "CUPnPDirectory::GetResource - unable to find uuid %s", uuid.c_str());
return false;
}
PLT_MediaObjectListReference list;
if (NPT_FAILED(upnp->m_MediaBrowser->BrowseSync(device, object.c_str(), list, true))) {
CLog::Log(LOGERROR, "CUPnPDirectory::GetResource - unable to find object %s", object.c_str());
return false;
}
if (list.IsNull() || !list->GetItemCount()) {
CLog::Log(LOGERROR, "CUPnPDirectory::GetResource - no items returned for object %s", object.c_str());
return false;
}
PLT_MediaObjectList::Iterator entry = list->GetFirstItem();
if (entry == 0)
return false;
return UPNP::GetResource(*entry, item);
}
示例13: ParseAndCorrectUrl
void CCurlFile::ParseAndCorrectUrl(CURL &url2)
{
CStdString strProtocol = url2.GetTranslatedProtocol();
url2.SetProtocol(strProtocol);
if( strProtocol.Equals("ftp")
|| strProtocol.Equals("ftps") )
{
/* this is uggly, depending on from where */
/* we get the link it may or may not be */
/* url encoded. if handed from ftpdirectory */
/* it won't be so let's handle that case */
CStdString partial, filename(url2.GetFileName());
CStdStringArray array;
/* our current client doesn't support utf8 */
g_charsetConverter.utf8ToStringCharset(filename);
/* TODO: create a tokenizer that doesn't skip empty's */
CUtil::Tokenize(filename, array, "/");
filename.Empty();
for(CStdStringArray::iterator it = array.begin(); it != array.end(); it++)
{
if(it != array.begin())
filename += "/";
partial = *it;
CURL::Encode(partial);
filename += partial;
}
/* make sure we keep slashes */
if(url2.GetFileName().Right(1) == "/")
filename += "/";
url2.SetFileName(filename);
CStdString options = url2.GetOptions().Mid(1);
options.TrimRight('/'); // hack for trailing slashes being added from source
m_ftpauth = "";
m_ftpport = "";
m_ftppasvip = false;
/* parse options given */
CUtil::Tokenize(options, array, "&");
for(CStdStringArray::iterator it = array.begin(); it != array.end(); it++)
{
CStdString name, value;
int pos = it->Find('=');
if(pos >= 0)
{
name = it->Left(pos);
value = it->Mid(pos+1, it->size());
}
else
{
name = (*it);
value = "";
}
if(name.Equals("auth"))
{
m_ftpauth = value;
if(m_ftpauth.IsEmpty())
m_ftpauth = "any";
}
else if(name.Equals("active"))
{
m_ftpport = value;
if(value.IsEmpty())
m_ftpport = "-";
}
else if(name.Equals("pasvip"))
{
if(value == "0")
m_ftppasvip = false;
else
m_ftppasvip = true;
}
}
/* ftp has no options */
url2.SetOptions("");
}
else if( strProtocol.Equals("http")
|| strProtocol.Equals("https"))
{
if (g_guiSettings.GetBool("network.usehttpproxy")
&& !g_guiSettings.GetString("network.httpproxyserver").empty()
&& !g_guiSettings.GetString("network.httpproxyport").empty()
&& m_proxy.IsEmpty())
{
m_proxy = g_guiSettings.GetString("network.httpproxyserver");
m_proxy += ":" + g_guiSettings.GetString("network.httpproxyport");
if (g_guiSettings.GetString("network.httpproxyusername").length() > 0 && m_proxyuserpass.IsEmpty())
{
m_proxyuserpass = g_guiSettings.GetString("network.httpproxyusername");
m_proxyuserpass += ":" + g_guiSettings.GetString("network.httpproxypassword");
//.........这里部分代码省略.........
示例14: if
CStdString CPlayListM3U::GetBestBandwidthStream(const CStdString &strFileName, size_t bandwidth)
{
// we may be passed a playlist that does not contain playlists of different
// bitrates (eg: this playlist is really the HLS video). So, default the
// return to the filename so it can be played
char szLine[4096];
CStdString strLine;
CStdString strPlaylist = strFileName;
size_t maxBandwidth = 0;
// if we cannot get the last / we wont be able to determine the sub-playlists
size_t baseEnd = strPlaylist.rfind('/');
if (baseEnd == std::string::npos)
return strPlaylist;
// store the base path (the path without the filename)
CStdString basePath = strPlaylist.substr(0, baseEnd + 1);
// open the file, and if it fails, return
CFile file;
if (!file.Open(strFileName) )
{
file.Close();
return strPlaylist;
}
// convert bandwidth specified in kbps to bps used by the m3u8
bandwidth *= 1000;
while (file.ReadString(szLine, 1024))
{
// read and trim a line
strLine = szLine;
strLine.TrimRight(" \t\r\n");
strLine.TrimLeft(" \t");
// skip the first line
if (strLine == M3U_START_MARKER)
continue;
else if (strLine.Left(strlen(M3U_STREAM_MARKER)) == M3U_STREAM_MARKER)
{
// parse the line so we can pull out the bandwidth
std::map< CStdString, CStdString > params = ParseStreamLine(strLine);
std::map< CStdString, CStdString >::iterator it = params.find(M3U_BANDWIDTH_MARKER);
if (it != params.end())
{
size_t streamBandwidth = atoi(it->second.c_str());
if ((maxBandwidth < streamBandwidth) && (streamBandwidth <= bandwidth))
{
// read the next line
if (!file.ReadString(szLine, 1024))
continue;
strLine = szLine;
strLine.TrimRight(" \t\r\n");
strLine.TrimLeft(" \t");
// this line was empty
if (strLine.empty())
continue;
// store the max bandwidth
maxBandwidth = streamBandwidth;
// if the path is absolute just use it
if (CURL::IsFullPath(strLine))
strPlaylist = strLine;
else
strPlaylist = basePath + strLine;
}
}
}
}
CLog::Log(LOGINFO, "Auto-selecting %s based on configured bandwidth.", strPlaylist.c_str());
return strPlaylist;
}
示例15: Load
bool CPlayListPLS::Load(const CStdString &strFile)
{
//read it from the file
CStdString strFileName(strFile);
m_strPlayListName = URIUtils::GetFileName(strFileName);
Clear();
bool bShoutCast = false;
if( strFileName.Left(8).Equals("shout://") )
{
strFileName.Delete(0, 8);
strFileName.Insert(0, "http://");
m_strBasePath = "";
bShoutCast = true;
}
else
URIUtils::GetParentPath(strFileName, m_strBasePath);
CFile file;
if (!file.Open(strFileName) )
{
file.Close();
return false;
}
if (file.GetLength() > 1024*1024)
{
CLog::Log(LOGWARNING, "%s - File is larger than 1 MB, most likely not a playlist",__FUNCTION__);
return false;
}
char szLine[4096];
CStdString strLine;
// run through looking for the [playlist] marker.
// if we find another http stream, then load it.
while (1)
{
if ( !file.ReadString(szLine, sizeof(szLine) ) )
{
file.Close();
return size() > 0;
}
strLine = szLine;
strLine.TrimLeft(" \t");
strLine.TrimRight(" \n\r");
if(strLine.Equals(START_PLAYLIST_MARKER))
break;
// if there is something else before playlist marker, this isn't a pls file
if(!strLine.IsEmpty())
return false;
}
bool bFailed = false;
while (file.ReadString(szLine, sizeof(szLine) ) )
{
strLine = szLine;
StringUtils::RemoveCRLF(strLine);
int iPosEqual = strLine.Find("=");
if (iPosEqual > 0)
{
CStdString strLeft = strLine.Left(iPosEqual);
iPosEqual++;
CStdString strValue = strLine.Right(strLine.size() - iPosEqual);
strLeft.ToLower();
while (strLeft[0] == ' ' || strLeft[0] == '\t')
strLeft.erase(0,1);
if (strLeft == "numberofentries")
{
m_vecItems.reserve(atoi(strValue.c_str()));
}
else if (strLeft.Left(4) == "file")
{
vector <int>::size_type idx = atoi(strLeft.c_str() + 4);
if (!Resize(idx))
{
bFailed = true;
break;
}
// Skip self - do not load playlist recursively
if (URIUtils::GetFileName(strValue).Equals(URIUtils::GetFileName(strFileName)))
continue;
if (m_vecItems[idx - 1]->GetLabel().empty())
m_vecItems[idx - 1]->SetLabel(URIUtils::GetFileName(strValue));
CFileItem item(strValue, false);
if (bShoutCast && !item.IsAudio())
strValue.Replace("http:", "shout:");
strValue = URIUtils::SubstitutePath(strValue);
CUtil::GetQualifiedFilename(m_strBasePath, strValue);
g_charsetConverter.unknownToUTF8(strValue);
m_vecItems[idx - 1]->SetPath(strValue);
}
else if (strLeft.Left(5) == "title")
{
//.........这里部分代码省略.........