本文整理汇总了C++中CStdStringArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringArray::push_back方法的具体用法?C++ CStdStringArray::push_back怎么用?C++ CStdStringArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringArray
的用法示例。
在下文中一共展示了CStdStringArray::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitString
// Splits the string input into pieces delimited by delimiter.
// if 2 delimiters are in a row, it will include the empty string between them.
// added MaxStrings parameter to restrict the number of returned substrings (like perl and python)
int StringUtils::SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results, unsigned int iMaxStrings /* = 0 */)
{
int iPos = -1;
int newPos = -1;
int sizeS2 = delimiter.GetLength();
int isize = input.GetLength();
results.clear();
vector<unsigned int> positions;
newPos = input.Find (delimiter, 0);
if ( newPos < 0 )
{
results.push_back(input);
return 1;
}
while ( newPos > iPos )
{
positions.push_back(newPos);
iPos = newPos;
newPos = input.Find (delimiter, iPos + sizeS2);
}
// numFound is the number of delimiters which is one less
// than the number of substrings
unsigned int numFound = positions.size();
if (iMaxStrings > 0 && numFound >= iMaxStrings)
numFound = iMaxStrings - 1;
for ( unsigned int i = 0; i <= numFound; i++ )
{
CStdString s;
if ( i == 0 )
{
if ( i == numFound )
s = input;
else
s = input.Mid( i, positions[i] );
}
else
{
int offset = positions[i - 1] + sizeS2;
if ( offset < isize )
{
if ( i == numFound )
s = input.Mid(offset);
else if ( i > 0 )
s = input.Mid( positions[i - 1] + sizeS2,
positions[i] - positions[i - 1] - sizeS2 );
}
}
results.push_back(s);
}
// return the number of substrings
return results.size();
}
示例2: SplitString
// Splits the string input into pieces delimited by delimiter.
// if 2 delimiters are in a row, it will include the empty string between them.
int StringUtils::SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results)
{
int iPos = -1;
int newPos = -1;
int sizeS2 = delimiter.GetLength();
int isize = input.GetLength();
results.clear();
//CArray positions;
vector<unsigned int> positions;
newPos = input.Find (delimiter, 0);
if ( newPos < 0 )
{
results.push_back(input);
return 1;
}
int numFound = 1;
while ( newPos > iPos )
{
numFound++;
positions.push_back(newPos);
iPos = newPos;
newPos = input.Find (delimiter, iPos + sizeS2);
}
for ( unsigned int i = 0; i <= positions.size(); i++ )
{
CStdString s;
if ( i == 0 )
{
if (i == positions.size())
s = input;
else
s = input.Mid( i, positions[i] );
}
else
{
int offset = positions[i - 1] + sizeS2;
if ( offset < isize )
{
if ( i == positions.size() )
s = input.Mid(offset);
else if ( i > 0 )
s = input.Mid( positions[i - 1] + sizeS2,
positions[i] - positions[i - 1] - sizeS2 );
}
}
results.push_back(s);
}
return numFound;
}
示例3: OnUninstall
void CGUIDialogAddonInfo::OnUninstall()
{
if (!m_localAddon.get())
return;
// ensure the addon is not a dependency of other installed addons
VECADDONS addons;
CStdStringArray deps;
CAddonMgr::Get().GetAllAddons(addons);
for (VECADDONS::iterator it = addons.begin();
it != addons.end();++it)
{
if ((*it)->GetDeps().find(m_localAddon->ID()) != (*it)->GetDeps().end())
deps.push_back((*it)->Name());
}
if (!CAddonInstaller::Get().CheckDependencies(m_localAddon) && deps.size())
{
CStdString strLine0, strLine1;
StringUtils::JoinString(deps, ", ", strLine1);
strLine0.Format(g_localizeStrings.Get(24046), m_localAddon->Name().c_str());
CGUIDialogOK::ShowAndGetInput(24037, strLine0, strLine1, 24047);
return;
}
// ensure the addon isn't disabled in our database
CAddonDatabase database;
database.Open();
database.DisableAddon(m_localAddon->ID(), false);
CJobManager::GetInstance().AddJob(new CAddonUnInstallJob(m_localAddon),
&CAddonInstaller::Get());
CAddonMgr::Get().RemoveAddon(m_localAddon->ID());
Close();
}
示例4: lock
void WatchDog::CTestPathJob::DoWork()
{
#ifndef WATCHDOG_DONT_TEST_PATH
if (!m_jobHandler)
{
CLog::Log(LOGWARNING,"CTestPathJob::DoWork - Can't execute the job. [jobHandler=NULL] (testpath)");
return;
}
//CLog::Log(LOGDEBUG,"CTestPathJob::DoWork - Enter function. [server=%d][internet=%d] (testpath)",m_jobHandler->IsConnectedToServer(),m_jobHandler->IsConnectedToInternet());
// scan all shares
CStdStringArray arr;
// first copy share names from map to temp array so that we only lock the map shortly
{
CSingleLock lock(m_jobHandler->m_lock);
for (std::map<CStdString, PathStatus>::iterator iter=m_jobHandler->m_mapPaths.begin(); iter != m_jobHandler->m_mapPaths.end(); iter++)
{
arr.push_back(iter->first);
}
}
for (size_t n=0; n<arr.size() && !m_jobHandler->IsStoped(); n++)
{
//CLog::Log(LOGDEBUG,"CTestPathJob::DoWork - [%d/%d] - Going to test [path=%s]. [server=%d][internet=%d] (testpath)",(int)n+1,(int)arr.size(),arr[n].c_str(),m_jobHandler->IsConnectedToServer(),m_jobHandler->IsConnectedToInternet());
m_jobHandler->TestPath(arr[n]);
}
//CLog::Log(LOGDEBUG,"CTestPathJob::DoWork - Exit function. [server=%d][internet=%d] (testpath)",m_jobHandler->IsConnectedToServer(),m_jobHandler->IsConnectedToInternet());
#endif
}
示例5: ShowAndGetFileList
bool CGUIDialogFileBrowser::ShowAndGetFileList(const VECSOURCES &shares, const CStdString &mask, const CStdString &heading, CStdStringArray &path, bool useThumbs /* = false */, bool useFileDirectories /* = false */)
{
CGUIDialogFileBrowser *browser = new CGUIDialogFileBrowser();
if (!browser)
return false;
g_windowManager.AddUniqueInstance(browser);
browser->m_useFileDirectories = useFileDirectories;
browser->m_multipleSelection = true;
browser->m_browsingForImages = useThumbs;
browser->SetHeading(heading);
browser->SetSources(shares);
browser->m_browsingForFolders = 0;
browser->m_rootDir.SetMask(mask);
browser->m_addNetworkShareEnabled = false;
browser->DoModal();
bool confirmed(browser->IsConfirmed());
if (confirmed)
{
if (browser->m_markedPath.size())
path = browser->m_markedPath;
else
path.push_back(browser->m_selectedPath);
}
g_windowManager.Remove(browser->GetID());
delete browser;
return confirmed;
}
示例6:
TEST(TestStringUtils, FindBestMatch)
{
double refdouble, vardouble;
int refint, varint;
CStdStringArray strarray;
refint = 3;
refdouble = 0.5625f;
strarray.push_back("");
strarray.push_back("a");
strarray.push_back("e");
strarray.push_back("es");
strarray.push_back("t");
varint = StringUtils::FindBestMatch("test", strarray, vardouble);
EXPECT_EQ(refint, varint);
EXPECT_EQ(refdouble, vardouble);
}
示例7: Join
CStdString StringUtils::Join(const vector<string> &strings, const CStdString& delimiter)
{
CStdStringArray strArray;
for (unsigned int index = 0; index < strings.size(); index++)
strArray.push_back(strings.at(index));
return JoinString(strArray, delimiter);
}
示例8: GetRegionNames
// Fills the array with the region names available for this language
void CLangInfo::GetRegionNames(CStdStringArray& array)
{
for (ITMAPREGIONS it=m_regions.begin(); it!=m_regions.end(); ++it)
{
CStdString strName=it->first;
if (strName=="N/A")
strName=g_localizeStrings.Get(416);
array.push_back(strName);
}
}
示例9: readFile_using_std_stream
bool CASCIIManager::readFile_using_std_stream(CStdString strFileName, CStdStringArray &aRighe /*, UV_MFC::CDlg_Progresso *pDlg*/) ///< Leggo da file.
{
std::wifstream myfile(strFileName);
std::streampos pos_begin = std::ios::beg;
std::streampos pos_curr;
std::wstring line;
CStdString strLine;
int fileLen = 0;
int nI = 0, nCont = 3500;
ULONGLONG nPosition;
double dPerc, dPerc1;
CStdString strFase;
if (myfile.is_open())
{
// get length of file:
myfile.seekg(0, myfile.end);
fileLen = (int)myfile.tellg();
myfile.seekg(0, myfile.beg);
pos_curr = myfile.tellg();
aRighe.clear();
while (getline(myfile, line))
{
pos_curr = myfile.tellg();
// std::cout << line << '\n';
strLine.Format(_T("%s"), line.c_str());
aRighe.push_back(strLine);
nI++;
//if (pDlg && nI > nCont)
//{
// nPosition = pos_curr.seekpos();
// dPerc = nPosition / (double)fileLen;
// dPerc = max(0, min(1, dPerc));
// dPerc1 = pDlg->m_dPercMin + dPerc*(pDlg->m_dPercMax - pDlg->m_dPercMin);
// pDlg->SetPos(dPerc1);
// strFase.Format(_T("[%d/%d] Reading rows (%.1lf%%)"), pDlg->m_nFaseCurr, pDlg->m_nFaseTot, 100.0*dPerc);
// pDlg->SetFase(strFase);
// nI = 0;
// if (!pDlg->m_bContinua)
// {
// myfile.close();
// return false;
// }
//}
}
myfile.close();
}
return true;
}
示例10: GetContent
bool CDirectoryNodeTvShowsOverview::GetContent(CFileItemList& items)
{
CStdStringArray vecRoot;
vecRoot.push_back(g_localizeStrings.Get(135)); // Genres
vecRoot.push_back(g_localizeStrings.Get(369)); // Title
vecRoot.push_back(g_localizeStrings.Get(562)); // Year
vecRoot.push_back(g_localizeStrings.Get(344)); // Actors
for (int i = 0; i < (int)vecRoot.size(); ++i)
{
CFileItemPtr pItem(new CFileItem(vecRoot[i]));
CStdString strDir;
strDir.Format("%i/", i+1);
pItem->m_strPath = BuildPath() + strDir;
pItem->m_bIsFolder = true;
pItem->SetCanQueue(false);
items.Add(pItem);
}
return true;
}
示例11: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdString &addonID, bool showNone /*= false*/)
{
CStdStringArray addonIDs;
if (!addonID.IsEmpty())
addonIDs.push_back(addonID);
int retval = SelectAddonID(types, addonIDs, showNone, false);
if (addonIDs.size() > 0)
addonID = addonIDs.at(0);
else
addonID = "";
return retval;
}
示例12: OnSettingAction
void CGameSettings::OnSettingAction(const CSetting* setting)
{
if (setting == NULL)
return;
const std::string& settingId = setting->GetId();
if (settingId == "gamesgeneral.manageaddons")
{
CStdStringArray params;
params.push_back("addons://all/xbmc.gameclient");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
}
}
示例13: GetContent
bool CDirectoryNodeMusicVideosOverview::GetContent(CFileItemList& items)
{
CStdStringArray vecRoot;
vecRoot.push_back(g_localizeStrings.Get(135)); // Genres
vecRoot.push_back(g_localizeStrings.Get(369)); // Title
vecRoot.push_back(g_localizeStrings.Get(345)); // Year
vecRoot.push_back(g_localizeStrings.Get(133)); // Artists
vecRoot.push_back(g_localizeStrings.Get(20348)); // Directors
vecRoot.push_back(g_localizeStrings.Get(20388)); // Studios
for (int i = 0; i < (int)vecRoot.size(); ++i)
{
CFileItem* pItem = new CFileItem(vecRoot[i]);
CStdString strDir;
strDir.Format("%i/", i+1);
pItem->m_strPath = BuildPath() + strDir;
pItem->m_bIsFolder = true;
pItem->SetCanQueue(false);
items.Add(pItem);
}
return true;
}
示例14: GetCustomRegexps
void CAdvancedSettings::GetCustomRegexps(TiXmlElement *pRootElement, CStdStringArray& settings)
{
TiXmlElement *pElement = pRootElement;
while (pElement)
{
int iAction = 0; // overwrite
// for backward compatibility
const char* szAppend = pElement->Attribute("append");
if ((szAppend && stricmp(szAppend, "yes") == 0))
iAction = 1;
// action takes precedence if both attributes exist
const char* szAction = pElement->Attribute("action");
if (szAction)
{
iAction = 0; // overwrite
if (stricmp(szAction, "append") == 0)
iAction = 1; // append
else if (stricmp(szAction, "prepend") == 0)
iAction = 2; // prepend
}
if (iAction == 0)
settings.clear();
TiXmlNode* pRegExp = pElement->FirstChild("regexp");
int i = 0;
while (pRegExp)
{
if (pRegExp->FirstChild())
{
CStdString regExp = pRegExp->FirstChild()->Value();
regExp.MakeLower();
if (iAction == 2)
settings.insert(settings.begin() + i++, 1, regExp);
else
settings.push_back(regExp);
}
pRegExp = pRegExp->NextSibling("regexp");
}
pElement = pElement->NextSiblingElement(pRootElement->Value());
}
}
示例15: GameLauchDialog
bool CRetroPlayerDialogs::GameLauchDialog(const CFileItem &file, GameClientPtr &result)
{
CFileItem fileCopy = file;
// If an explicit game client was specified, try to download that
if (fileCopy.HasProperty("gameclient"))
{
if (InstallGameClient(fileCopy.GetProperty("gameclient").asString(), fileCopy, result))
return true;
fileCopy.ClearProperty("gameclient"); // don't want this to interfere later on
}
// First, ask the user if they would like to install a game client or go to
// the add-on manager
CContextButtons choices;
choices.Add(0, 24026); // Install emulator
choices.Add(1, 24058); // Add-on manager
int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices);
if (btnid == 0) // Install emulator
{
return InstallGameClientDialog(fileCopy, result);
}
else if (btnid == 1) // Add-on manager
{
// Queue the file so that if a compatible game client is installed, the
// user will be asked to launch the file.
CGameManager::Get().SetAutoLaunch(fileCopy);
CLog::Log(LOGDEBUG, "RetroPlayer: User chose to go to the add-on manager");
CStdStringArray params;
params.push_back("addons://all/xbmc.gameclient");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
}
else
{
CLog::Log(LOGDEBUG, "RetroPlayer: User canceled game client selection");
}
return false;
}