本文整理汇总了C++中CStdString::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::clear方法的具体用法?C++ CStdString::clear怎么用?C++ CStdString::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetKeyName
CStdString CKeyboardStat::GetKeyName(int KeyID)
{ int keyid;
CStdString keyname;
XBMCKEYTABLE keytable;
keyname.clear();
// Get modifiers
if (KeyID & CKey::MODIFIER_CTRL)
keyname.append("ctrl-");
if (KeyID & CKey::MODIFIER_SHIFT)
keyname.append("shift-");
if (KeyID & CKey::MODIFIER_ALT)
keyname.append("alt-");
if (KeyID & CKey::MODIFIER_SUPER)
keyname.append("win-");
if (KeyID & CKey::MODIFIER_META)
keyname.append("meta-");
// Now get the key name
keyid = KeyID & 0xFF;
if (KeyTableLookupVKeyName(keyid, &keytable))
keyname.append(keytable.keyname);
else
keyname.AppendFormat("%i", keyid);
keyname.AppendFormat(" (0x%02x)", KeyID);
return keyname;
}
示例2: GetAdditiveString
bool XMLUtils::GetAdditiveString(const TiXmlNode* pRootNode, const char* strTag,
const CStdString& strSeparator, CStdString& strStringValue,
bool clear)
{
CStdString strTemp;
const TiXmlElement* node = pRootNode->FirstChildElement(strTag);
bool bResult=false;
if (node && node->FirstChild() && clear)
strStringValue.clear();
while (node)
{
if (node->FirstChild())
{
bResult = true;
strTemp = node->FirstChild()->Value();
const char* clear=node->Attribute("clear");
if (strStringValue.IsEmpty() || (clear && strcasecmp(clear,"true")==0))
strStringValue = strTemp;
else
strStringValue += strSeparator+strTemp;
}
node = node->NextSiblingElement(strTag);
}
return bResult;
}
示例3:
void CAirPlayServer::CTCPClient::ComposeAuthRequestAnswer(CStdString& responseHeader, CStdString& responseBody)
{
int16_t random=rand();
CStdString randomStr = StringUtils::Format("%i", random);
m_authNonce=XBMC::XBMC_MD5::GetMD5(randomStr);
responseHeader = StringUtils::Format(AUTH_REQUIRED, m_authNonce.c_str());
responseBody.clear();
}
示例4: LoadItem
bool CPictureThumbLoader::LoadItem(CFileItem* pItem)
{
if (pItem->m_bIsShareOrDrive) return true;
if (pItem->IsParentFolder()) return true;
if (pItem->HasThumbnail() && m_regenerateThumbs)
{
CTextureCache::Get().ClearCachedImage(pItem->GetThumbnailImage());
CTextureDatabase db;
if (db.Open())
db.ClearTextureForPath(pItem->GetPath(), "thumb");
pItem->SetThumbnailImage("");
}
CStdString thumb;
if (pItem->IsPicture() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // load the thumb from the image file
thumb = pItem->HasThumbnail() ? pItem->GetThumbnailImage() : CTextureCache::GetWrappedThumbURL(pItem->GetPath());
}
else if (pItem->IsVideo() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // video
thumb = pItem->GetCachedVideoThumb();
if (!CFile::Exists(thumb))
{
CStdString strPath, strFileName;
URIUtils::Split(thumb, strPath, strFileName);
CStdString autoThumb = strPath + "auto-" + strFileName;
// this is abit of a hack to avoid loading zero sized images
// which we know will fail. They will just display empty image
// we should really have some way for the texture loader to
// do fallbacks to default images for a failed image instead
if (CFile::Exists(autoThumb))
{
thumb = autoThumb;
}
else if (g_guiSettings.GetBool("myvideos.extractthumb") && g_guiSettings.GetBool("myvideos.extractflags"))
{
CFileItem item(*pItem);
CThumbExtractor* extract = new CThumbExtractor(item, pItem->GetPath(), true, autoThumb);
AddJob(extract);
thumb.clear();
}
}
}
else if (!pItem->HasThumbnail())
{ // folder, zip, cbz, rar, cbr, playlist may have a previously cached image
thumb = GetCachedImage(*pItem, "thumb");
}
if (!thumb.IsEmpty())
{
CTextureCache::Get().BackgroundCacheImage(thumb);
pItem->SetThumbnailImage(thumb);
}
pItem->FillInDefaultIcon();
return true;
}
示例5: StartServer
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const CStdString &password/*=""*/)
{
bool success = false;
CStdString pw = password;
CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface();
StopServer(true);
if (net)
{
m_macAddress = net->GetMacAddress();
StringUtils::Replace(m_macAddress, ":","");
while (m_macAddress.size() < 12)
{
m_macAddress = CStdString("0") + m_macAddress;
}
}
else
{
m_macAddress = "000102030405";
}
if (!usePassword)
{
pw.clear();
}
ServerInstance = new CAirTunesServer(port, nonlocal);
if (ServerInstance->Initialize(pw))
{
success = true;
CStdString appName = StringUtils::Format("%[email protected]%s",
m_macAddress.c_str(),
g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME).c_str());
std::vector<std::pair<std::string, std::string> > txt;
txt.push_back(std::make_pair("txtvers", "1"));
txt.push_back(std::make_pair("cn", "0,1"));
txt.push_back(std::make_pair("ch", "2"));
txt.push_back(std::make_pair("ek", "1"));
txt.push_back(std::make_pair("et", "0,1"));
txt.push_back(std::make_pair("sv", "false"));
txt.push_back(std::make_pair("tp", "UDP"));
txt.push_back(std::make_pair("sm", "false"));
txt.push_back(std::make_pair("ss", "16"));
txt.push_back(std::make_pair("sr", "44100"));
txt.push_back(std::make_pair("pw", usePassword?"true":"false"));
txt.push_back(std::make_pair("vn", "3"));
txt.push_back(std::make_pair("da", "true"));
txt.push_back(std::make_pair("vs", "130.14"));
txt.push_back(std::make_pair("md", "0,1,2"));
txt.push_back(std::make_pair("am", "Xbmc,1"));
CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt);
}
return success;
}
示例6: Europe
TEST_F(TestCharsetConverter, getCharsetNameByLabel)
{
CStdString varstr =
g_charsetConverter.getCharsetNameByLabel("Western Europe (ISO)");
EXPECT_STREQ("ISO-8859-1", varstr.c_str());
varstr.clear();
varstr = g_charsetConverter.getCharsetNameByLabel("Bogus");
EXPECT_STREQ("", varstr.c_str());
}
示例7: LoadItemCached
bool CPictureThumbLoader::LoadItemCached(CFileItem* pItem)
{
if (pItem->m_bIsShareOrDrive
|| pItem->IsParentFolder())
return false;
if (pItem->HasArt("thumb") && m_regenerateThumbs)
{
CTextureCache::Get().ClearCachedImage(pItem->GetArt("thumb"));
if (m_textureDatabase->Open())
{
m_textureDatabase->ClearTextureForPath(pItem->GetPath(), "thumb");
m_textureDatabase->Close();
}
pItem->SetArt("thumb", "");
}
CStdString thumb;
if (pItem->IsPicture() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // load the thumb from the image file
thumb = pItem->HasArt("thumb") ? pItem->GetArt("thumb") : CTextureCache::GetWrappedThumbURL(pItem->GetPath());
}
else if (pItem->IsVideo() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList())
{ // video
CVideoThumbLoader loader;
if (!loader.FillThumb(*pItem))
{
CStdString thumbURL = CVideoThumbLoader::GetEmbeddedThumbURL(*pItem);
if (CTextureCache::Get().HasCachedImage(thumbURL))
{
thumb = thumbURL;
}
else if (CSettings::Get().GetBool("myvideos.extractthumb") && CSettings::Get().GetBool("myvideos.extractflags"))
{
CFileItem item(*pItem);
CThumbExtractor* extract = new CThumbExtractor(item, pItem->GetPath(), true, thumbURL);
AddJob(extract);
thumb.clear();
}
}
}
else if (!pItem->HasArt("thumb"))
{ // folder, zip, cbz, rar, cbr, playlist may have a previously cached image
thumb = GetCachedImage(*pItem, "thumb");
}
if (!thumb.IsEmpty())
{
CTextureCache::Get().BackgroundCacheImage(thumb);
pItem->SetArt("thumb", thumb);
}
pItem->FillInDefaultIcon();
return true;
}
示例8: 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(" ");
}
示例9: GetHeader
void CHttpHeader::GetHeader(CStdString& strHeader) const
{
strHeader.clear();
std::map<CStdString,CStdString>::const_iterator iter = m_params.begin();
while (iter != m_params.end())
{
strHeader += ((*iter).first + ": " + (*iter).second + "\n");
iter++;
}
strHeader += "\n";
}
示例10: GetFirstFontSetUnicode
bool GUIFontManager::GetFirstFontSetUnicode(CStdString& strFontSet)
{
strFontSet.clear();
// Load our font file
CXBMCTinyXML xmlDoc;
if (!OpenFontFile(xmlDoc))
return false;
TiXmlElement* pRootElement = xmlDoc.RootElement();
const TiXmlNode *pChild = pRootElement->FirstChild();
CStdString strValue = pChild->Value();
if (strValue == "fontset")
{
while (pChild)
{
strValue = pChild->Value();
if (strValue == "fontset")
{
const char* idAttr = ((TiXmlElement*) pChild)->Attribute("id");
const char* unicodeAttr = ((TiXmlElement*) pChild)->Attribute("unicode");
// Check if this is a fontset with a ttf attribute set to true
if (unicodeAttr != NULL && stricmp(unicodeAttr, "true") == 0)
{
// This is the first ttf fontset
strFontSet=idAttr;
break;
}
}
pChild = pChild->NextSibling();
}
// If no fontset was loaded
if (pChild == NULL)
CLog::Log(LOGWARNING, "file doesnt have <fontset> with attribute unicode=\"true\"");
}
else
{
CLog::Log(LOGERROR, "file doesnt have <fontset> in <fonts>, but rather %s", strValue.c_str());
}
return !strFontSet.empty();
}
示例11: GetPath
bool XMLUtils::GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue)
{
const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag);
if (!pElement) return false;
const char* encoded = pElement->Attribute("urlencoded");
const TiXmlNode* pNode = pElement->FirstChild();
if (pNode != NULL)
{
strStringValue = pNode->Value();
if (encoded && strcasecmp(encoded,"yes") == 0)
strStringValue = CURL::Decode(strStringValue);
return true;
}
strStringValue.clear();
return false;
}
示例12: GetCachedImage
CStdString CTextureCache::GetCachedImage(const CStdString &image, CStdString &cachedHash, bool trackUsage)
{
cachedHash.clear();
CStdString url = UnwrapImageURL(image);
if (IsCachedImage(url))
return url;
// lookup the item in the database
CTextureDetails details;
if (GetCachedTexture(url, details))
{
if (trackUsage)
IncrementUseCount(details);
return GetCachedPath(details.file);
}
return "";
}
示例13: GetAndCutNextTerm
void CTextSearch::GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm)
{
CStdString strFindNext(" ");
if (StringUtils::EndsWith(strSearchTerm, "\""))
{
strSearchTerm.erase(0, 1);
strFindNext = "\"";
}
int iNextPos = strSearchTerm.Find(strFindNext);
if (iNextPos != -1)
{
strNextTerm = strSearchTerm.Left(iNextPos);
strSearchTerm.erase(0, iNextPos + 1);
}
else
{
strNextTerm = strSearchTerm;
strSearchTerm.clear();
}
}
示例14: OnGetFanart
// Allow user to select a Fanart
void CGUIDialogMusicInfo::OnGetFanart()
{
CFileItemList items;
if (m_albumItem->HasProperty("fanart_image"))
{
CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false));
itemCurrent->SetThumbnailImage(m_albumItem->GetProperty("fanart_image").asString());
itemCurrent->SetLabel(g_localizeStrings.Get(20440));
items.Add(itemCurrent);
}
// Grab the thumbnails from the web
for (unsigned int i = 0; i < m_artist.fanart.GetNumFanarts(); i++)
{
CStdString strItemPath;
strItemPath.Format("fanart://Remote%i",i);
CFileItemPtr item(new CFileItem(strItemPath, false));
CStdString thumb = m_artist.fanart.GetPreviewURL(i);
item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(thumb));
item->SetIconImage("DefaultPicture.png");
item->SetLabel(g_localizeStrings.Get(20441));
// TODO: Do we need to clear the cached image?
// CTextureCache::Get().ClearCachedImage(thumb);
items.Add(item);
}
// Grab a local thumb
CMusicDatabase database;
database.Open();
CStdString strArtistPath;
database.GetArtistPath(m_artist.idArtist,strArtistPath);
CFileItem item(strArtistPath,true);
CStdString strLocal = item.GetLocalFanart();
if (!strLocal.IsEmpty())
{
CFileItemPtr itemLocal(new CFileItem("fanart://Local",false));
itemLocal->SetThumbnailImage(strLocal);
itemLocal->SetLabel(g_localizeStrings.Get(20438));
// TODO: Do we need to clear the cached image?
CTextureCache::Get().ClearCachedImage(strLocal);
items.Add(itemLocal);
}
else
{
CFileItemPtr itemNone(new CFileItem("fanart://None", false));
itemNone->SetIconImage("DefaultArtist.png");
itemNone->SetLabel(g_localizeStrings.Get(20439));
items.Add(itemNone);
}
CStdString result;
VECSOURCES sources(g_settings.m_musicSources);
g_mediaManager.GetLocalDrives(sources);
bool flip=false;
if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445))
return; // user cancelled
// delete the thumbnail if that's what the user wants, else overwrite with the
// new thumbnail
if (result.Equals("fanart://Current"))
return;
if (result.Equals("fanart://Local"))
result = strLocal;
if (result.Left(15) == "fanart://Remote")
{
int iFanart = atoi(result.Mid(15).c_str());
m_artist.fanart.SetPrimaryFanart(iFanart);
result = m_artist.fanart.GetImageURL();
}
else if (result.Equals("fanart://None") || !CFile::Exists(result))
result.clear();
if (flip && !result.empty())
result = CTextureCache::GetWrappedImageURL(result, "", "flipped");
// update thumb in the database
CMusicDatabase db;
if (db.Open())
{
db.SetArtForItem(m_albumItem->GetMusicInfoTag()->GetDatabaseId(), m_albumItem->GetMusicInfoTag()->GetType(), "fanart", result);
db.Close();
}
if (!result.empty())
m_albumItem->SetProperty("fanart_image",result);
else
m_albumItem->ClearProperty("fanart_image");
m_hasUpdatedThumb = true;
// tell our GUI to completely reload all controls (as some of them
// are likely to have had this image in use so will need refreshing)
CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
g_windowManager.SendMessage(msg);
// Update our screen
Update();
//.........这里部分代码省略.........
示例15: GetParentPath
bool URIUtils::GetParentPath(const CStdString& strPath, CStdString& strParent)
{
strParent = "";
CURL url(strPath);
CStdString strFile = url.GetFileName();
if ( URIUtils::ProtocolHasParentInHostname(url.GetProtocol()) && strFile.IsEmpty())
{
strFile = url.GetHostName();
return GetParentPath(strFile, strParent);
}
else if ((url.GetProtocol() == "videodb" || url.GetProtocol() == "musicdb") && !url.GetOptions().empty())
{
CStdString options = url.GetOptions();
size_t filterStart = options.find("filter=");
if (filterStart != string::npos)
{
size_t filterEnd = options.find("&", filterStart);
options.erase(filterStart, filterEnd - filterStart);
if (options.Equals("?"))
options.clear();
url.SetOptions(options);
strParent = url.Get();
return true;
}
}
else if (url.GetProtocol() == "stack")
{
CStackDirectory dir;
CFileItemList items;
dir.GetDirectory(strPath,items);
GetDirectory(items[0]->GetPath(),items[0]->m_strDVDLabel);
if (items[0]->m_strDVDLabel.Mid(0,6).Equals("rar://") || items[0]->m_strDVDLabel.Mid(0,6).Equals("zip://"))
GetParentPath(items[0]->m_strDVDLabel, strParent);
else
strParent = items[0]->m_strDVDLabel;
for( int i=1;i<items.Size();++i)
{
GetDirectory(items[i]->GetPath(),items[i]->m_strDVDLabel);
if (items[0]->m_strDVDLabel.Mid(0,6).Equals("rar://") || items[0]->m_strDVDLabel.Mid(0,6).Equals("zip://"))
items[i]->SetPath(GetParentPath(items[i]->m_strDVDLabel));
else
items[i]->SetPath(items[i]->m_strDVDLabel);
GetCommonPath(strParent,items[i]->GetPath());
}
return true;
}
else if (url.GetProtocol() == "multipath")
{
// get the parent path of the first item
return GetParentPath(CMultiPathDirectory::GetFirstPath(strPath), strParent);
}
else if (url.GetProtocol() == "plugin")
{
if (!url.GetOptions().IsEmpty())
{
url.SetOptions("");
strParent = url.Get();
return true;
}
if (!url.GetFileName().IsEmpty())
{
url.SetFileName("");
strParent = url.Get();
return true;
}
if (!url.GetHostName().IsEmpty())
{
url.SetHostName("");
strParent = url.Get();
return true;
}
return true; // already at root
}
else if (url.GetProtocol() == "special")
{
if (HasSlashAtEnd(strFile) )
strFile = strFile.Left(strFile.size() - 1);
if(strFile.ReverseFind('/') < 0)
return false;
}
else if (strFile.size() == 0)
{
if (url.GetHostName().size() > 0)
{
// we have an share with only server or workgroup name
// set hostname to "" and return true to get back to root
url.SetHostName("");
strParent = url.Get();
return true;
}
return false;
}
if (HasSlashAtEnd(strFile) )
{
strFile = strFile.Left(strFile.size() - 1);
}
//.........这里部分代码省略.........