本文整理汇总了C++中CStdString::capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::capacity方法的具体用法?C++ CStdString::capacity怎么用?C++ CStdString::capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::capacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetURLWithoutFilename
void CURL::GetURLWithoutFilename(CStdString& strURL) const
{
unsigned int sizeneed = m_strProtocol.length()
+ m_strDomain.length()
+ m_strUserName.length()
+ m_strPassword.length()
+ m_strHostName.length()
+ 10;
if( strURL.capacity() < sizeneed )
strURL.reserve(sizeneed);
if (m_strProtocol == "")
{
#ifdef _LINUX
strURL.Empty();
#else
strURL = m_strFileName.substr(0, 2); // only copy 'e:'
#endif
return ;
}
strURL = m_strProtocol;
strURL += "://";
if (m_strDomain != "")
{
strURL += m_strDomain;
strURL += ";";
}
else if (m_strUserName != "")
{
strURL += URLEncodeInline(m_strUserName);
if (m_strPassword != "")
{
strURL += ":";
strURL += URLEncodeInline(m_strPassword);
}
strURL += "@";
}
else if (m_strDomain != "")
strURL += "@";
if (m_strHostName != "")
{
if( m_strProtocol.Equals("rar") || m_strProtocol.Equals("zip") || m_strProtocol.Equals("musicsearch"))
strURL += URLEncodeInline(m_strHostName);
else
strURL += m_strHostName;
if (HasPort())
{
CStdString strPort;
strPort.Format("%i", m_iPort);
strURL += ":";
strURL += strPort;
}
strURL += "/";
}
}
示例2: GetURL
void CURL::GetURL(CStdString& strURL) const
{
unsigned int sizeneed = m_strProtocol.length()
+ m_strDomain.length()
+ m_strUserName.length()
+ m_strPassword.length()
+ m_strHostName.length()
+ m_strFileName.length()
+ m_strOptions.length()
+ 10;
if( strURL.capacity() < sizeneed )
strURL.reserve(sizeneed);
if (m_strProtocol == "")
{
strURL = m_strFileName;
return ;
}
GetURLWithoutFilename(strURL);
strURL += m_strFileName;
if( m_strOptions.length() > 0 )
strURL += m_strOptions;
}
示例3: GetURLWithoutUserDetails
void CURL::GetURLWithoutUserDetails(CStdString& strURL) const
{
if (m_strProtocol.Equals("stack"))
{
CFileItemList items;
CStdString strURL2;
GetURL(strURL2);
DIRECTORY::CStackDirectory dir;
dir.GetDirectory(strURL2,items);
vector<CStdString> newItems;
for (int i=0;i<items.Size();++i)
{
CURL url(items[i]->m_strPath);
url.GetURLWithoutUserDetails(items[i]->m_strPath);
newItems.push_back(items[i]->m_strPath);
}
dir.ConstructStackPath(newItems,strURL);
return;
}
unsigned int sizeneed = m_strProtocol.length()
+ m_strDomain.length()
+ m_strHostName.length()
+ m_strFileName.length()
+ m_strOptions.length()
+ 10;
if( strURL.capacity() < sizeneed )
strURL.reserve(sizeneed);
if (m_strProtocol == "")
{
strURL = m_strFileName;
return ;
}
strURL = m_strProtocol;
strURL += "://";
if (m_strHostName != "")
{
if (m_strProtocol.Equals("rar") || m_strProtocol.Equals("zip"))
{
CURL url2(m_strHostName);
CStdString strHost;
url2.GetURLWithoutUserDetails(strHost);
strURL += strHost;
}
else
strURL += m_strHostName;
if ( HasPort() )
{
CStdString strPort;
strPort.Format("%i", m_iPort);
strURL += ":";
strURL += strPort;
}
strURL += "/";
}
strURL += m_strFileName;
if( m_strOptions.length() > 0 )
strURL += m_strOptions;
}