iterator -> const_iterator

This commit is contained in:
Tomas Jakobsson 2017-11-11 15:56:22 +01:00
parent b63a2835ba
commit 9fbe95daa3
55 changed files with 296 additions and 295 deletions

View file

@ -37,7 +37,7 @@ CollectionSystemManager::CollectionSystemManager(Window* window) : mWindow(windo
// create a map
std::vector<CollectionSystemDecl> tempSystemDecl = std::vector<CollectionSystemDecl>(systemDecls, systemDecls + sizeof(systemDecls) / sizeof(systemDecls[0]));
for (std::vector<CollectionSystemDecl>::iterator it = tempSystemDecl.begin(); it != tempSystemDecl.end(); ++it )
for (std::vector<CollectionSystemDecl>::const_iterator it = tempSystemDecl.cbegin(); it != tempSystemDecl.cend(); ++it )
{
mCollectionSystemDeclsIndex[(*it).name] = (*it);
}
@ -68,7 +68,7 @@ CollectionSystemManager::~CollectionSystemManager()
removeCollectionsFromDisplayedSystems();
// iterate the map
for(std::map<std::string, CollectionSystemData>::iterator it = mCustomCollectionSystemsData.begin() ; it != mCustomCollectionSystemsData.end() ; it++ )
for(std::map<std::string, CollectionSystemData>::const_iterator it = mCustomCollectionSystemsData.cbegin() ; it != mCustomCollectionSystemsData.cend() ; it++ )
{
if (it->second.isPopulated)
{
@ -103,14 +103,14 @@ void CollectionSystemManager::saveCustomCollection(SystemData* sys)
{
std::string name = sys->getName();
std::unordered_map<std::string, FileData*> games = sys->getRootFolder()->getChildrenByFilename();
bool found = mCustomCollectionSystemsData.find(name) != mCustomCollectionSystemsData.end();
bool found = mCustomCollectionSystemsData.find(name) != mCustomCollectionSystemsData.cend();
if (found) {
CollectionSystemData sysData = mCustomCollectionSystemsData.at(name);
if (sysData.needsSave)
{
std::ofstream configFile;
configFile.open(getCustomCollectionConfigPath(name));
for(std::unordered_map<std::string, FileData*>::iterator iter = games.begin(); iter != games.end(); ++iter)
for(std::unordered_map<std::string, FileData*>::const_iterator iter = games.cbegin(); iter != games.cend(); ++iter)
{
std::string path = iter->first;
configFile << path << std::endl;
@ -151,7 +151,7 @@ void CollectionSystemManager::loadEnabledListFromSettings()
// iterate the map
for(std::map<std::string, CollectionSystemData>::iterator it = mAutoCollectionSystemsData.begin() ; it != mAutoCollectionSystemsData.end() ; it++ )
{
it->second.isEnabled = (std::find(autoSelected.begin(), autoSelected.end(), it->first) != autoSelected.end());
it->second.isEnabled = (std::find(autoSelected.cbegin(), autoSelected.cend(), it->first) != autoSelected.cend());
}
// we parse the custom collection settings list
@ -160,7 +160,7 @@ void CollectionSystemManager::loadEnabledListFromSettings()
// iterate the map
for(std::map<std::string, CollectionSystemData>::iterator it = mCustomCollectionSystemsData.begin() ; it != mCustomCollectionSystemsData.end() ; it++ )
{
it->second.isEnabled = (std::find(customSelected.begin(), customSelected.end(), it->first) != customSelected.end());
it->second.isEnabled = (std::find(customSelected.cbegin(), customSelected.cend(), it->first) != customSelected.cend());
}
}
@ -178,7 +178,7 @@ void CollectionSystemManager::updateSystemsList()
std::sort(SystemData::sSystemVector.begin(), SystemData::sSystemVector.end(), systemSort);
// move RetroPie system to end, before auto collections
for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); )
for(auto sysIt = SystemData::sSystemVector.cbegin(); sysIt != SystemData::sSystemVector.cend(); )
{
if ((*sysIt)->getName() == "retropie")
{
@ -204,7 +204,7 @@ void CollectionSystemManager::updateSystemsList()
addEnabledCollectionsToDisplayedSystems(&mAutoCollectionSystemsData);
// create views for collections, before reload
for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); sysIt++)
for(auto sysIt = SystemData::sSystemVector.cbegin(); sysIt != SystemData::sSystemVector.cend(); sysIt++)
{
if ((*sysIt)->isCollection())
{
@ -227,10 +227,10 @@ void CollectionSystemManager::refreshCollectionSystems(FileData* file)
return;
std::map<std::string, CollectionSystemData> allCollections;
allCollections.insert(mAutoCollectionSystemsData.begin(), mAutoCollectionSystemsData.end());
allCollections.insert(mCustomCollectionSystemsData.begin(), mCustomCollectionSystemsData.end());
allCollections.insert(mAutoCollectionSystemsData.cbegin(), mAutoCollectionSystemsData.cend());
allCollections.insert(mCustomCollectionSystemsData.cbegin(), mCustomCollectionSystemsData.cend());
for(auto sysDataIt = allCollections.begin(); sysDataIt != allCollections.end(); sysDataIt++)
for(auto sysDataIt = allCollections.cbegin(); sysDataIt != allCollections.cend(); sysDataIt++)
{
updateCollectionSystem(file, sysDataIt->second);
}
@ -245,7 +245,7 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
SystemData* curSys = sysData.system;
const std::unordered_map<std::string, FileData*>& children = curSys->getRootFolder()->getChildrenByFilename();
bool found = children.find(key) != children.end();
bool found = children.find(key) != children.cend();
FileData* rootFolder = curSys->getRootFolder();
FileFilterIndex* fileIndex = curSys->getIndex();
std::string name = curSys->getName();
@ -292,8 +292,8 @@ void CollectionSystemManager::deleteCollectionFiles(FileData* file)
std::string key = file->getFullPath();
// find games in collection systems
std::map<std::string, CollectionSystemData> allCollections;
allCollections.insert(mAutoCollectionSystemsData.begin(), mAutoCollectionSystemsData.end());
allCollections.insert(mCustomCollectionSystemsData.begin(), mCustomCollectionSystemsData.end());
allCollections.insert(mAutoCollectionSystemsData.cbegin(), mAutoCollectionSystemsData.cend());
allCollections.insert(mCustomCollectionSystemsData.cbegin(), mCustomCollectionSystemsData.cend());
for(auto sysDataIt = allCollections.begin(); sysDataIt != allCollections.end(); sysDataIt++)
{
@ -301,7 +301,7 @@ void CollectionSystemManager::deleteCollectionFiles(FileData* file)
{
const std::unordered_map<std::string, FileData*>& children = (sysDataIt->second.system)->getRootFolder()->getChildrenByFilename();
bool found = children.find(key) != children.end();
bool found = children.find(key) != children.cend();
if (found) {
sysDataIt->second.needsSave = true;
FileData* collectionEntry = children.at(key);
@ -316,7 +316,7 @@ void CollectionSystemManager::deleteCollectionFiles(FileData* file)
bool CollectionSystemManager::isThemeGenericCollectionCompatible(bool genericCustomCollections)
{
std::vector<std::string> cfgSys = getCollectionThemeFolders(genericCustomCollections);
for(auto sysIt = cfgSys.begin(); sysIt != cfgSys.end(); sysIt++)
for(auto sysIt = cfgSys.cbegin(); sysIt != cfgSys.cend(); sysIt++)
{
if(!themeFolderExists(*sysIt))
return false;
@ -332,7 +332,7 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vector<std:
// get theme path
auto themeSets = ThemeData::getThemeSets();
auto set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set != themeSets.end())
if(set != themeSets.cend())
{
std::string defaultThemeFilePath = set->second.path.string() + "/theme.xml";
if (fs::exists(defaultThemeFilePath))
@ -341,7 +341,7 @@ bool CollectionSystemManager::isThemeCustomCollectionCompatible(std::vector<std:
}
}
for(auto sysIt = stringVector.begin(); sysIt != stringVector.end(); sysIt++)
for(auto sysIt = stringVector.cbegin(); sysIt != stringVector.cend(); sysIt++)
{
if(!themeFolderExists(*sysIt))
return false;
@ -380,10 +380,10 @@ std::string CollectionSystemManager::getValidNewCollectionName(std::string inNam
// get folders assigned to user collections
std::vector<std::string> userSys = getUserCollectionThemeFolders();
// add them all to the list of systems in use
systemsInUse.insert(systemsInUse.end(), autoSys.begin(), autoSys.end());
systemsInUse.insert(systemsInUse.end(), customSys.begin(), customSys.end());
systemsInUse.insert(systemsInUse.end(), userSys.begin(), userSys.end());
for(auto sysIt = systemsInUse.begin(); sysIt != systemsInUse.end(); sysIt++)
systemsInUse.insert(systemsInUse.cend(), autoSys.cbegin(), autoSys.cend());
systemsInUse.insert(systemsInUse.cend(), customSys.cbegin(), customSys.cend());
systemsInUse.insert(systemsInUse.cend(), userSys.cbegin(), userSys.cend());
for(auto sysIt = systemsInUse.cbegin(); sysIt != systemsInUse.cend(); sysIt++)
{
if (*sysIt == name)
{
@ -394,14 +394,14 @@ std::string CollectionSystemManager::getValidNewCollectionName(std::string inNam
}
}
// if it matches one of the custom collections reserved names
if (mCollectionSystemDeclsIndex.find(name) != mCollectionSystemDeclsIndex.end())
if (mCollectionSystemDeclsIndex.find(name) != mCollectionSystemDeclsIndex.cend())
return getValidNewCollectionName(name, index+1);
return name;
}
void CollectionSystemManager::setEditMode(std::string collectionName)
{
if (mCustomCollectionSystemsData.find(collectionName) == mCustomCollectionSystemsData.end())
if (mCustomCollectionSystemsData.find(collectionName) == mCustomCollectionSystemsData.cend())
{
LOG(LogError) << "Tried to edit a non-existing collection: " << collectionName;
return;
@ -449,7 +449,7 @@ bool CollectionSystemManager::toggleGameInCollection(FileData* file)
std::string key = file->getFullPath();
FileData* rootFolder = sysData->getRootFolder();
const std::unordered_map<std::string, FileData*>& children = rootFolder->getChildrenByFilename();
bool found = children.find(key) != children.end();
bool found = children.find(key) != children.cend();
FileFilterIndex* fileIndex = sysData->getIndex();
std::string name = sysData->getName();
@ -523,7 +523,7 @@ SystemData* CollectionSystemManager::getSystemToView(SystemData* sys)
const std::unordered_map<std::string, FileData*>& bundleChildren = bundleRootFolder->getChildrenByFilename();
// is the rootFolder bundled in the "My Collections" system?
bool sysFoundInBundle = bundleChildren.find(rootFolder->getKey()) != bundleChildren.end();
bool sysFoundInBundle = bundleChildren.find(rootFolder->getKey()) != bundleChildren.cend();
if (sysFoundInBundle && sys->isCollection())
{
@ -536,7 +536,7 @@ SystemData* CollectionSystemManager::getSystemToView(SystemData* sys)
// loads Automatic Collection systems (All, Favorites, Last Played)
void CollectionSystemManager::initAutoCollectionSystems()
{
for(std::map<std::string, CollectionSystemDecl>::iterator it = mCollectionSystemDeclsIndex.begin() ; it != mCollectionSystemDeclsIndex.end() ; it++ )
for(std::map<std::string, CollectionSystemDecl>::const_iterator it = mCollectionSystemDeclsIndex.cbegin() ; it != mCollectionSystemDeclsIndex.cend() ; it++ )
{
CollectionSystemDecl sysDecl = it->second;
if (!sysDecl.isCustom)
@ -567,7 +567,7 @@ void CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sys)
{
std::string games_list = "";
int games_counter = 0;
for(std::unordered_map<std::string, FileData*>::iterator iter = games.begin(); iter != games.end(); ++iter)
for(std::unordered_map<std::string, FileData*>::const_iterator iter = games.cbegin(); iter != games.cend(); ++iter)
{
games_counter++;
FileData* file = iter->second;
@ -619,7 +619,7 @@ void CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sys)
void CollectionSystemManager::initCustomCollectionSystems()
{
std::vector<std::string> systems = getCollectionsFromConfigFolder();
for (auto nameIt = systems.begin(); nameIt != systems.end(); nameIt++)
for (auto nameIt = systems.cbegin(); nameIt != systems.cend(); nameIt++)
{
addNewCustomCollection(*nameIt);
}
@ -678,12 +678,12 @@ void CollectionSystemManager::populateAutoCollection(CollectionSystemData* sysDa
CollectionSystemDecl sysDecl = sysData->decl;
FileData* rootFolder = newSys->getRootFolder();
FileFilterIndex* index = newSys->getIndex();
for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); sysIt++)
for(auto sysIt = SystemData::sSystemVector.cbegin(); sysIt != SystemData::sSystemVector.cend(); sysIt++)
{
// we won't iterate all collections
if ((*sysIt)->isGameSystem() && !(*sysIt)->isCollection()) {
std::vector<FileData*> files = (*sysIt)->getRootFolder()->getFilesRecursive(GAME);
for(auto gameIt = files.begin(); gameIt != files.end(); gameIt++)
for(auto gameIt = files.cbegin(); gameIt != files.cend(); gameIt++)
{
bool include = includeFileInAutoCollections((*gameIt));
switch(sysDecl.type) {
@ -736,8 +736,8 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys
for(std::string gameKey; getline(input, gameKey); )
{
std::unordered_map<std::string,FileData*>::iterator it = allFilesMap.find(gameKey);
if (it != allFilesMap.end()) {
std::unordered_map<std::string,FileData*>::const_iterator it = allFilesMap.find(gameKey);
if (it != allFilesMap.cend()) {
CollectionFileData* newGame = new CollectionFileData(it->second, newSys);
rootFolder->addChild(newGame);
index->addToIndex(newGame);
@ -755,7 +755,7 @@ void CollectionSystemManager::populateCustomCollection(CollectionSystemData* sys
void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
{
// remove all Collection Systems
for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); )
for(auto sysIt = SystemData::sSystemVector.cbegin(); sysIt != SystemData::sSystemVector.cend(); )
{
if ((*sysIt)->isCollection())
{
@ -771,7 +771,7 @@ void CollectionSystemManager::removeCollectionsFromDisplayedSystems()
// this should not delete the objects from memory!
FileData* customRoot = mCustomCollectionsBundle->getRootFolder();
std::vector<FileData*> mChildren = customRoot->getChildren();
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
customRoot->removeChild(*it);
}
@ -866,11 +866,11 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
return systems;
}
auto set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set == themeSets.end())
std::map<std::string, ThemeSet>::const_iterator set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set == themeSets.cend())
{
// currently selected theme set is missing, so just pick the first available set
set = themeSets.begin();
set = themeSets.cbegin();
Settings::getInstance()->setString("ThemeSet", set->first);
}
@ -912,13 +912,13 @@ std::vector<std::string> CollectionSystemManager::getUnusedSystemsFromTheme()
// get folders assigned to user collections
std::vector<std::string> userSys = getUserCollectionThemeFolders();
// add them all to the list of systems in use
systemsInUse.insert(systemsInUse.end(), autoSys.begin(), autoSys.end());
systemsInUse.insert(systemsInUse.end(), customSys.begin(), customSys.end());
systemsInUse.insert(systemsInUse.end(), userSys.begin(), userSys.end());
systemsInUse.insert(systemsInUse.cend(), autoSys.cbegin(), autoSys.cend());
systemsInUse.insert(systemsInUse.cend(), customSys.cbegin(), customSys.cend());
systemsInUse.insert(systemsInUse.cend(), userSys.cbegin(), userSys.cend());
for(auto sysIt = themeSys.begin(); sysIt != themeSys.end(); )
for(auto sysIt = themeSys.cbegin(); sysIt != themeSys.cend(); )
{
if (std::find(systemsInUse.begin(), systemsInUse.end(), *sysIt) != systemsInUse.end())
if (std::find(systemsInUse.cbegin(), systemsInUse.cend(), *sysIt) != systemsInUse.cend())
{
sysIt = themeSys.erase(sysIt);
}
@ -967,7 +967,7 @@ std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder
std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool custom)
{
std::vector<std::string> systems;
for(std::map<std::string, CollectionSystemDecl>::iterator it = mCollectionSystemDeclsIndex.begin() ; it != mCollectionSystemDeclsIndex.end() ; it++ )
for(std::map<std::string, CollectionSystemDecl>::const_iterator it = mCollectionSystemDeclsIndex.cbegin() ; it != mCollectionSystemDeclsIndex.cend() ; it++ )
{
CollectionSystemDecl sysDecl = it->second;
if (sysDecl.isCustom == custom)
@ -982,7 +982,7 @@ std::vector<std::string> CollectionSystemManager::getCollectionThemeFolders(bool
std::vector<std::string> CollectionSystemManager::getUserCollectionThemeFolders()
{
std::vector<std::string> systems;
for(std::map<std::string, CollectionSystemData>::iterator it = mCustomCollectionSystemsData.begin() ; it != mCustomCollectionSystemsData.end() ; it++ )
for(std::map<std::string, CollectionSystemData>::const_iterator it = mCustomCollectionSystemsData.cbegin() ; it != mCustomCollectionSystemsData.cend() ; it++ )
{
systems.push_back(it->second.decl.themeFolder);
}
@ -993,7 +993,7 @@ std::vector<std::string> CollectionSystemManager::getUserCollectionThemeFolders(
bool CollectionSystemManager::themeFolderExists(std::string folder)
{
std::vector<std::string> themeSys = getSystemsFromTheme();
return std::find(themeSys.begin(), themeSys.end(), folder) != themeSys.end();
return std::find(themeSys.cbegin(), themeSys.cend(), folder) != themeSys.cend();
}
bool CollectionSystemManager::includeFileInAutoCollections(FileData* file)
@ -1020,7 +1020,7 @@ bool systemSort(SystemData* sys1, SystemData* sys2)
{
std::string name1 = sys1->getName();
std::string name2 = sys2->getName();
transform(name1.begin(), name1.end(), name1.begin(), ::toupper);
transform(name2.begin(), name2.end(), name2.begin(), ::toupper);
transform(name1.cbegin(), name1.cend(), name1.begin(), ::toupper);
transform(name2.cbegin(), name2.cend(), name2.begin(), ::toupper);
return name1.compare(name2) < 0;
}

View file

@ -88,7 +88,7 @@ const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
if (idx->isFiltered()) {
mFilteredChildren.clear();
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
if (idx->showFile((*it))) {
mFilteredChildren.push_back(*it);
@ -167,7 +167,7 @@ std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask, bool d
std::vector<FileData*> out;
FileFilterIndex* idx = mSystem->getIndex();
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
if((*it)->getType() & typeMask)
{
@ -178,7 +178,7 @@ std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask, bool d
if((*it)->getChildren().size() > 0)
{
std::vector<FileData*> subchildren = (*it)->getFilesRecursive(typeMask, displayedOnly);
out.insert(out.end(), subchildren.cbegin(), subchildren.cend());
out.insert(out.cend(), subchildren.cbegin(), subchildren.cend());
}
}
@ -200,7 +200,7 @@ void FileData::addChild(FileData* file)
assert(file->getParent() == NULL);
const std::string key = file->getKey();
if (mChildrenByFilename.find(key) == mChildrenByFilename.end())
if (mChildrenByFilename.find(key) == mChildrenByFilename.cend())
{
mChildrenByFilename[key] = file;
mChildren.push_back(file);
@ -213,7 +213,7 @@ void FileData::removeChild(FileData* file)
assert(mType == FOLDER);
assert(file->getParent() == this);
mChildrenByFilename.erase(file->getKey());
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
if(*it == file)
{
@ -232,7 +232,7 @@ void FileData::sort(ComparisonFunction& comparator, bool ascending)
{
std::stable_sort(mChildren.begin(), mChildren.end(), comparator);
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
if((*it)->getChildren().size() > 0)
(*it)->sort(comparator, ascending);

View file

@ -58,11 +58,11 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
std::vector<IndexImportStructure> indexImportDecl = std::vector<IndexImportStructure>(indexStructDecls, indexStructDecls + sizeof(indexStructDecls) / sizeof(indexStructDecls[0]));
for (std::vector<IndexImportStructure>::iterator indexesIt = indexImportDecl.begin(); indexesIt != indexImportDecl.end(); ++indexesIt )
for (std::vector<IndexImportStructure>::const_iterator indexesIt = indexImportDecl.cbegin(); indexesIt != indexImportDecl.cend(); ++indexesIt )
{
for (std::map<std::string, int>::iterator sourceIt = (*indexesIt).sourceIndex->begin(); sourceIt != (*indexesIt).sourceIndex->end(); ++sourceIt )
for (std::map<std::string, int>::const_iterator sourceIt = (*indexesIt).sourceIndex->cbegin(); sourceIt != (*indexesIt).sourceIndex->cend(); ++sourceIt )
{
if ((*indexesIt).destinationIndex->find((*sourceIt).first) == (*indexesIt).destinationIndex->end())
if ((*indexesIt).destinationIndex->find((*sourceIt).first) == (*indexesIt).destinationIndex->cend())
{
// entry doesn't exist
(*((*indexesIt).destinationIndex))[(*sourceIt).first] = (*sourceIt).second;
@ -211,15 +211,15 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
}
else
{
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) {
if ((*it).type == type)
{
FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = values->size() > 0;
filterData.currentFilteredKeys->clear();
for (std::vector<std::string>::iterator vit = values->begin(); vit != values->end(); ++vit ) {
for (std::vector<std::string>::const_iterator vit = values->cbegin(); vit != values->cend(); ++vit ) {
// check if exists
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->end()) {
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
filterData.currentFilteredKeys->push_back(std::string(*vit));
}
}
@ -231,7 +231,7 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
void FileFilterIndex::clearAllFilters()
{
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it )
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it )
{
FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = false;
@ -300,7 +300,7 @@ bool FileFilterIndex::showFile(FileData* game)
std::vector<FileData*> children = game->getChildren();
// iterate through all of the children, until there's a match
for (std::vector<FileData*>::iterator it = children.begin(); it != children.end(); ++it ) {
for (std::vector<FileData*>::const_iterator it = children.cbegin(); it != children.cend(); ++it ) {
if (showFile(*it))
{
return true;
@ -311,7 +311,7 @@ bool FileFilterIndex::showFile(FileData* game)
bool keepGoing = false;
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) {
FilterDataDecl filterData = (*it);
if(*(filterData.filteredByRef))
{
@ -352,7 +352,7 @@ bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type
{
if (filterTypes[i] == type)
{
for (std::vector<std::string>::iterator it = filterKeysList[i].begin(); it != filterKeysList[i].end(); ++it )
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin(); it != filterKeysList[i].cend(); ++it )
{
if (key == (*it))
{
@ -503,7 +503,7 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
return;
if (remove) {
// removing entry
if (index->find(key) == index->end())
if (index->find(key) == index->cend())
{
// this shouldn't happen
LOG(LogInfo) << "Couldn't find entry in index! " << key;
@ -519,7 +519,7 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
else
{
// adding entry
if (index->find(key) == index->end())
if (index->find(key) == index->cend())
{
(*index)[key] = 1;
}

View file

@ -42,8 +42,8 @@ namespace FileSorts
// we compare the actual metadata name, as collection files have the system appended which messes up the order
std::string name1 = file1->metadata.get("name");
std::string name2 = file2->metadata.get("name");
transform(name1.begin(), name1.end(), name1.begin(), ::toupper);
transform(name2.begin(), name2.end(), name2.begin(), ::toupper);
transform(name1.cbegin(), name1.cend(), name1.begin(), ::toupper);
transform(name2.cbegin(), name2.cend(), name2.begin(), ::toupper);
return name1.compare(name2) < 0;
}
@ -90,8 +90,8 @@ namespace FileSorts
{
std::string genre1 = file1->metadata.get("genre");
std::string genre2 = file2->metadata.get("genre");
transform(genre1.begin(), genre1.end(), genre1.begin(), ::toupper);
transform(genre2.begin(), genre2.end(), genre2.begin(), ::toupper);
transform(genre1.cbegin(), genre1.cend(), genre1.begin(), ::toupper);
transform(genre2.cbegin(), genre2.cend(), genre2.begin(), ::toupper);
return genre1.compare(genre2) < 0;
}
@ -99,8 +99,8 @@ namespace FileSorts
{
std::string developer1 = file1->metadata.get("developer");
std::string developer2 = file2->metadata.get("developer");
transform(developer1.begin(), developer1.end(), developer1.begin(), ::toupper);
transform(developer2.begin(), developer2.end(), developer2.begin(), ::toupper);
transform(developer1.cbegin(), developer1.cend(), developer1.begin(), ::toupper);
transform(developer2.cbegin(), developer2.cend(), developer2.begin(), ::toupper);
return developer1.compare(developer2) < 0;
}
@ -108,8 +108,8 @@ namespace FileSorts
{
std::string publisher1 = file1->metadata.get("publisher");
std::string publisher2 = file2->metadata.get("publisher");
transform(publisher1.begin(), publisher1.end(), publisher1.begin(), ::toupper);
transform(publisher2.begin(), publisher2.end(), publisher2.begin(), ::toupper);
transform(publisher1.cbegin(), publisher1.cend(), publisher1.begin(), ::toupper);
transform(publisher2.cbegin(), publisher2.cend(), publisher2.begin(), ::toupper);
return publisher1.compare(publisher2) < 0;
}
@ -117,8 +117,8 @@ namespace FileSorts
{
std::string system1 = file1->getSystemName();
std::string system2 = file2->getSystemName();
transform(system1.begin(), system1.end(), system1.begin(), ::toupper);
transform(system2.begin(), system2.end(), system2.begin(), ::toupper);
transform(system1.cbegin(), system1.cend(), system1.begin(), ::toupper);
transform(system2.cbegin(), system2.cend(), system2.begin(), ::toupper);
return system1.compare(system2) < 0;
}
};

View file

@ -41,7 +41,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
const std::unordered_map<std::string, FileData*>& children = treeNode->getChildrenByFilename();
std::string key = path_it->string();
found = children.find(key) != children.end();
found = children.find(key) != children.cend();
if (found) {
treeNode = children.at(key);
}

View file

@ -65,7 +65,7 @@ MetaDataList::MetaDataList(MetaDataListType type)
: mType(type), mWasChanged(false)
{
const std::vector<MetaDataDecl>& mdd = getMDD();
for(auto iter = mdd.begin(); iter != mdd.end(); iter++)
for(auto iter = mdd.cbegin(); iter != mdd.cend(); iter++)
set(iter->key, iter->defaultValue);
}
@ -76,7 +76,7 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node&
const std::vector<MetaDataDecl>& mdd = mdl.getMDD();
for(auto iter = mdd.begin(); iter != mdd.end(); iter++)
for(auto iter = mdd.cbegin(); iter != mdd.cend(); iter++)
{
pugi::xml_node md = node.child(iter->key.c_str());
if(md)
@ -100,10 +100,10 @@ void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, cons
{
const std::vector<MetaDataDecl>& mdd = getMDD();
for(auto mddIter = mdd.begin(); mddIter != mdd.end(); mddIter++)
for(auto mddIter = mdd.cbegin(); mddIter != mdd.cend(); mddIter++)
{
auto mapIter = mMap.find(mddIter->key);
if(mapIter != mMap.end())
if(mapIter != mMap.cend())
{
// we have this value!
// if it's just the default (and we ignore defaults), don't write it

View file

@ -68,7 +68,7 @@ int run_scraper_cmdline()
if(system_choice == "y" || system_choice == "Y")
{
out << "Will scrape all platforms.\n";
for(auto i = SystemData::sSystemVector.begin(); i != SystemData::sSystemVector.end(); i++)
for(auto i = SystemData::sSystemVector.cbegin(); i != SystemData::sSystemVector.cend(); i++)
{
out << " " << (*i)->getName() << " (" << (*i)->getGameCount() << " games)\n";
systems.push_back(*i);
@ -81,9 +81,9 @@ int run_scraper_cmdline()
out << "Type nothing and press enter when you are ready to continue.\n";
do {
for(auto i = SystemData::sSystemVector.begin(); i != SystemData::sSystemVector.end(); i++)
for(auto i = SystemData::sSystemVector.cbegin(); i != SystemData::sSystemVector.cend(); i++)
{
if(std::find(systems.begin(), systems.end(), (*i)) != systems.end())
if(std::find(systems.cbegin(), systems.cend(), (*i)) != systems.cend())
out << " C ";
else
out << " ";
@ -97,7 +97,7 @@ int run_scraper_cmdline()
break;
bool found = false;
for(auto i = SystemData::sSystemVector.begin(); i != SystemData::sSystemVector.end(); i++)
for(auto i = SystemData::sSystemVector.cbegin(); i != SystemData::sSystemVector.cend(); i++)
{
if((*i)->getName() == sys_name)
{
@ -145,14 +145,14 @@ int run_scraper_cmdline()
/*
std::shared_ptr<Scraper> scraper = Settings::getInstance()->getScraper();
for(auto sysIt = systems.begin(); sysIt != systems.end(); sysIt++)
for(auto sysIt = systems.cbegin(); sysIt != systems.cend(); sysIt++)
{
std::vector<FileData*> files = (*sysIt)->getRootFolder()->getFilesRecursive(GAME);
ScraperSearchParams params;
params.system = (*sysIt);
for(auto gameIt = files.begin(); gameIt != files.end(); gameIt++)
for(auto gameIt = files.cbegin(); gameIt != files.cend(); gameIt++)
{
params.nameOverride = "";
params.game = *gameIt;
@ -242,15 +242,15 @@ int run_scraper_cmdline()
out << "\n\n";
out << "Downloading boxart...\n";
for(auto sysIt = systems.begin(); sysIt != systems.end(); sysIt++)
for(auto sysIt = systems.cbegin(); sysIt != systems.cend(); sysIt++)
{
std::vector<FileData*> files = (*sysIt)->getRootFolder()->getFilesRecursive(GAME);
for(auto gameIt = files.begin(); gameIt != files.end(); gameIt++)
for(auto gameIt = files.cbegin(); gameIt != files.cend(); gameIt++)
{
FileData* game = *gameIt;
const std::vector<MetaDataDecl>& mdd = game->metadata.getMDD();
for(auto i = mdd.begin(); i != mdd.end(); i++)
for(auto i = mdd.cbegin(); i != mdd.cend(); i++)
{
std::string key = i->key;
std::string url = game->metadata.get(key);

View file

@ -122,7 +122,7 @@ void SystemData::populateFolder(FileData* folder)
//see issue #75: https://github.com/Aloshi/EmulationStation/issues/75
isGame = false;
if(std::find(mEnvData->mSearchExtensions.begin(), mEnvData->mSearchExtensions.end(), extension) != mEnvData->mSearchExtensions.end())
if(std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(), extension) != mEnvData->mSearchExtensions.cend())
{
// skip hidden files
if(!showHidden && isHidden(filePath))
@ -152,7 +152,7 @@ void SystemData::indexAllGameFilters(const FileData* folder)
{
const std::vector<FileData*>& children = folder->getChildren();
for(std::vector<FileData*>::const_iterator it = children.begin(); it != children.end(); ++it)
for(std::vector<FileData*>::const_iterator it = children.cbegin(); it != children.cend(); ++it)
{
switch((*it)->getType())
{
@ -231,7 +231,7 @@ bool SystemData::loadConfig()
const char* platformList = system.child("platform").text().get();
std::vector<std::string> platformStrs = readList(platformList);
std::vector<PlatformIds::PlatformId> platformIds;
for(auto it = platformStrs.begin(); it != platformStrs.end(); it++)
for(auto it = platformStrs.cbegin(); it != platformStrs.cend(); it++)
{
const char* str = it->c_str();
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
@ -363,8 +363,8 @@ SystemData* SystemData::getNext() const
do {
it++;
if (it == sSystemVector.end())
it = sSystemVector.begin();
if (it == sSystemVector.cend())
it = sSystemVector.cbegin();
} while ((*it)->getDisplayedGameCount() == 0);
// as we are starting in a valid gamelistview, this will always succeed, even if we have to come full circle.
@ -373,11 +373,12 @@ SystemData* SystemData::getNext() const
SystemData* SystemData::getPrev() const
{
auto it = getRevIterator();
std::vector<SystemData*>::const_reverse_iterator it = getRevIterator();
do {
it++;
if (it == sSystemVector.rend())
it = sSystemVector.rbegin();
if (it == sSystemVector.crend())
it = sSystemVector.crbegin();
} while ((*it)->getDisplayedGameCount() == 0);
// as we are starting in a valid gamelistview, this will always succeed, even if we have to come full circle.
@ -439,7 +440,7 @@ SystemData* SystemData::getRandomSystem()
{
// this is a bit brute force. It might be more efficient to just to a while (!gameSystem) do random again...
unsigned int total = 0;
for(auto it = sSystemVector.begin(); it != sSystemVector.end(); it++)
for(auto it = sSystemVector.cbegin(); it != sSystemVector.cend(); it++)
{
if ((*it)->isGameSystem())
total ++;
@ -447,7 +448,7 @@ SystemData* SystemData::getRandomSystem()
// get random number in range
int target = (int) std::round(((double)std::rand() / (double)RAND_MAX) * (total - 1));
for (auto it = sSystemVector.begin(); it != sSystemVector.end(); it++)
for (auto it = sSystemVector.cbegin(); it != sSystemVector.cend(); it++)
{
if ((*it)->isGameSystem())
{

View file

@ -34,7 +34,7 @@ public:
inline const std::string& getThemeFolder() const { return mThemeFolder; }
inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
inline const std::vector<PlatformIds::PlatformId>& getPlatformIds() const { return mEnvData->mPlatformIds; }
inline bool hasPlatformId(PlatformIds::PlatformId id) { if (!mEnvData) return false; return std::find(mEnvData->mPlatformIds.begin(), mEnvData->mPlatformIds.end(), id) != mEnvData->mPlatformIds.end(); }
inline bool hasPlatformId(PlatformIds::PlatformId id) { if (!mEnvData) return false; return std::find(mEnvData->mPlatformIds.cbegin(), mEnvData->mPlatformIds.cend(), id) != mEnvData->mPlatformIds.cend(); }
inline const std::shared_ptr<ThemeData>& getTheme() const { return mTheme; }
@ -52,8 +52,8 @@ public:
static std::vector<SystemData*> sSystemVector;
inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.begin(), sSystemVector.end(), this); };
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.rbegin(), sSystemVector.rend(), this); };
inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.cbegin(), sSystemVector.cend(), this); };
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.crbegin(), sSystemVector.crend(), this); };
inline bool isCollection() { return mIsCollectionSystem; };
inline bool isGameSystem() { return mIsGameSystem; }

View file

@ -259,8 +259,8 @@ void SystemScreenSaver::renderScreenSaver()
unsigned long SystemScreenSaver::countGameListNodes(const char *nodeName)
{
unsigned long nodeCount = 0;
std::vector<SystemData*>:: iterator it;
for (it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it)
std::vector<SystemData*>::const_iterator it;
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
{
// We only want images and videos from game systems that are not collections
if (!(*it)->isCollection() && (*it)->isGameSystem())
@ -309,8 +309,8 @@ void SystemScreenSaver::countImages()
void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeName, std::string& path)
{
std::vector<SystemData*>:: iterator it;
for (it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); ++it)
std::vector<SystemData*>::const_iterator it;
for (it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); ++it)
{
pugi::xml_document doc;
pugi::xml_node root;
@ -354,7 +354,7 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeNa
const std::unordered_map<std::string, FileData*>& children = rootFileData->getChildrenByFilename();
std::unordered_map<std::string, FileData*>::const_iterator screenSaverGame = children.find(shortPath);
if (screenSaverGame != children.end())
if (screenSaverGame != children.cend())
{
// Found the corresponding FileData
mCurrentGame = screenSaverGame->second;
@ -365,10 +365,10 @@ void SystemScreenSaver::pickGameListNode(unsigned long index, const char *nodeNa
// iterate on children
FileType type = GAME;
std::vector<FileData*> allFiles = rootFileData->getFilesRecursive(type);
std::vector<FileData*>::iterator itf; // declare an iterator to a vector of strings
std::vector<FileData*>::const_iterator itf; // declare an iterator to a vector of strings
int i = 0;
for(itf=allFiles.begin() ; itf < allFiles.end(); itf++,i++ ) {
for(itf=allFiles.cbegin() ; itf < allFiles.cend(); itf++,i++ ) {
if ((*itf)->getPath() == gamePath)
{
mCurrentGame = (*itf);

View file

@ -59,7 +59,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type)
mMD_Grid = std::make_shared<ComponentGrid>(mWindow, Vector2i(2, mMD_Pairs.size()*2 - 1));
unsigned int i = 0;
for(auto it = mMD_Pairs.begin(); it != mMD_Pairs.end(); it++)
for(auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); it++)
{
mMD_Grid->setEntry(it->first, Vector2i(0, i), false, true);
mMD_Grid->setEntry(it->second, Vector2i(1, i), false, it->resize);
@ -136,7 +136,7 @@ void ScraperSearchComponent::resizeMetadata()
// update label fonts
float maxLblWidth = 0;
for(auto it = mMD_Pairs.begin(); it != mMD_Pairs.end(); it++)
for(auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); it++)
{
it->first->setFont(fontLbl);
it->first->setSize(0, 0);

View file

@ -32,7 +32,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
std::shared_ptr< OptionListComponent<std::string> > folderThemes = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT THEME FOLDER", true);
// add Custom Systems
for(auto it = unusedFolders.begin() ; it != unusedFolders.end() ; it++ )
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ )
{
ComponentListRow row;
std::string name = *it;
@ -141,7 +141,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
autoOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT COLLECTIONS", true);
// add Auto Systems
for(std::map<std::string, CollectionSystemData>::iterator it = autoSystems.begin() ; it != autoSystems.end() ; it++ )
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin() ; it != autoSystems.cend() ; it++ )
{
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
}
@ -152,7 +152,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
customOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, "SELECT COLLECTIONS", true);
// add Custom Systems
for(std::map<std::string, CollectionSystemData>::iterator it = customSystems.begin() ; it != customSystems.end() ; it++ )
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin() ; it != customSystems.cend() ; it++ )
{
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
}

View file

@ -51,7 +51,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
// this is because of how GuiComponent::update works. if it was just delete this, this would happen when the metadata resolver is done:
// GuiGameScraper::update()
// GuiComponent::update()
// it = mChildren.begin();
// it = mChildren.cbegin();
// mBox::update()
// it++;
// mSearchComponent::update()
@ -61,7 +61,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
// so instead we do this:
// GuiGameScraper::update()
// GuiComponent::update()
// it = mChildren.begin();
// it = mChildren.cbegin();
// mBox::update()
// it++;
// mSearchComponent::update()

View file

@ -36,7 +36,7 @@ void GuiGamelistFilter::initializeMenu()
void GuiGamelistFilter::resetAllFilters()
{
mFilterIndex->resetFilters();
for (std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >>::iterator it = mFilterOptions.begin(); it != mFilterOptions.end(); ++it ) {
for (std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >>::const_iterator it = mFilterOptions.cbegin(); it != mFilterOptions.cend(); ++it ) {
std::shared_ptr< OptionListComponent<std::string> > optionList = it->second;
optionList->selectNone();
}
@ -57,7 +57,7 @@ void GuiGamelistFilter::addFiltersToMenu()
if (ViewController::get()->isUIModeKid())
skip = 2;
for (std::vector<FilterDataDecl>::iterator it = decls.begin(); it != decls.end()-skip; ++it ) {
for (std::vector<FilterDataDecl>::const_iterator it = decls.cbegin(); it != decls.cend()-skip; ++it ) {
FilterIndexType type = (*it).type; // type of filter
std::map<std::string, int>* allKeys = (*it).allIndexKeys; // all possible filters for this type
@ -84,7 +84,7 @@ void GuiGamelistFilter::addFiltersToMenu()
void GuiGamelistFilter::applyFilters()
{
std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls();
for (std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >>::iterator it = mFilterOptions.begin(); it != mFilterOptions.end(); ++it ) {
for (std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >>::const_iterator it = mFilterOptions.cbegin(); it != mFilterOptions.cend(); ++it ) {
std::shared_ptr< OptionListComponent<std::string> > optionList = it->second;
std::vector<std::string> filters = optionList->getSelectedObjects();
mFilterIndex->setFilter(it->first, &filters);

View file

@ -85,7 +85,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
std::map<std::string, CollectionSystemData> customCollections = CollectionSystemManager::get()->getCustomCollectionSystems();
if(ViewController::get()->isUIModeFull() &&
((customCollections.find(system->getName()) != customCollections.end() && CollectionSystemManager::get()->getEditingCollection() != system->getName()) ||
((customCollections.find(system->getName()) != customCollections.cend() && CollectionSystemManager::get()->getEditingCollection() != system->getName()) ||
CollectionSystemManager::get()->getCustomCollectionsBundle()->getName() == system->getName()))
{
row.elements.clear();

View file

@ -25,7 +25,7 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
screensavers.push_back("black");
screensavers.push_back("random video");
screensavers.push_back("slideshow");
for(auto it = screensavers.begin(); it != screensavers.end(); it++)
for(auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
screensaver_behavior->add(*it, *it, Settings::getInstance()->getString("ScreenSaverBehavior") == *it);
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);
addSaveFunc([this, screensaver_behavior] {

View file

@ -54,7 +54,7 @@ void GuiMenu::openScraperSettings()
// scrape from
auto scraper_list = std::make_shared< OptionListComponent< std::string > >(mWindow, "SCRAPE FROM", false);
std::vector<std::string> scrapers = getScraperList();
for(auto it = scrapers.begin(); it != scrapers.end(); it++)
for(auto it = scrapers.cbegin(); it != scrapers.cend(); it++)
scraper_list->add(*it, *it, *it == Settings::getInstance()->getString("Scraper"));
s->addWithLabel("SCRAPE FROM", scraper_list);
@ -101,7 +101,7 @@ void GuiMenu::openSoundSettings()
transitions.push_back("PCM");
transitions.push_back("Speaker");
transitions.push_back("Master");
for(auto it = transitions.begin(); it != transitions.end(); it++)
for(auto it = transitions.cbegin(); it != transitions.cend(); it++)
vol_dev->add(*it, *it, Settings::getInstance()->getString("AudioDevice") == *it);
s->addWithLabel("AUDIO DEVICE", vol_dev);
s->addSaveFunc([vol_dev] {
@ -141,7 +141,7 @@ void GuiMenu::openSoundSettings()
// USB audio
devices.push_back("alsa:hw:0,0");
devices.push_back("alsa:hw:1,0");
for (auto it = devices.begin(); it != devices.end(); it++)
for (auto it = devices.cbegin(); it != devices.cend(); it++)
omx_audio_dev->add(*it, *it, Settings::getInstance()->getString("OMXAudioDev") == *it);
s->addWithLabel("OMX PLAYER AUDIO DEVICE", omx_audio_dev);
s->addSaveFunc([omx_audio_dev] {
@ -162,7 +162,7 @@ void GuiMenu::openUISettings()
//UI mode
auto UImodeSelection = std::make_shared< OptionListComponent<std::string> >(mWindow, "UI MODE", false);
std::vector<std::string> UImodes = ViewController::get()->getUIModes();
for (auto it = UImodes.begin(); it != UImodes.end(); it++)
for (auto it = UImodes.cbegin(); it != UImodes.cend(); it++)
UImodeSelection->add(*it, *it, Settings::getInstance()->getString("UIMode") == *it);
s->addWithLabel("UI MODE", UImodeSelection);
Window* window = mWindow;
@ -220,7 +220,7 @@ void GuiMenu::openUISettings()
transitions.push_back("fade");
transitions.push_back("slide");
transitions.push_back("instant");
for(auto it = transitions.begin(); it != transitions.end(); it++)
for(auto it = transitions.cbegin(); it != transitions.cend(); it++)
transition_style->add(*it, *it, Settings::getInstance()->getString("TransitionStyle") == *it);
s->addWithLabel("TRANSITION STYLE", transition_style);
s->addSaveFunc([transition_style] {
@ -239,12 +239,12 @@ void GuiMenu::openUISettings()
if(!themeSets.empty())
{
auto selectedSet = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(selectedSet == themeSets.end())
selectedSet = themeSets.begin();
std::map<std::string, ThemeSet>::const_iterator selectedSet = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(selectedSet == themeSets.cend())
selectedSet = themeSets.cbegin();
auto theme_set = std::make_shared< OptionListComponent<std::string> >(mWindow, "THEME SET", false);
for(auto it = themeSets.begin(); it != themeSets.end(); it++)
for(auto it = themeSets.cbegin(); it != themeSets.cend(); it++)
theme_set->add(it->first, it->first, it == selectedSet);
s->addWithLabel("THEME SET", theme_set);
@ -272,7 +272,7 @@ void GuiMenu::openUISettings()
styles.push_back("basic");
styles.push_back("detailed");
styles.push_back("video");
for (auto it = styles.begin(); it != styles.end(); it++)
for (auto it = styles.cbegin(); it != styles.cend(); it++)
gamelist_style->add(*it, *it, Settings::getInstance()->getString("GamelistViewStyle") == *it);
s->addWithLabel("GAMELIST VIEW STYLE", gamelist_style);
s->addSaveFunc([gamelist_style] {
@ -287,7 +287,7 @@ void GuiMenu::openUISettings()
// Optionally start in selected system
auto systemfocus_list = std::make_shared< OptionListComponent<std::string> >(mWindow, "START ON SYSTEM", false);
systemfocus_list->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
for (auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
{
if ("retropie" != (*it)->getName())
{
@ -326,7 +326,7 @@ void GuiMenu::openOtherSettings()
modes.push_back("default");
modes.push_back("enhanced");
modes.push_back("instant");
for (auto it = modes.begin(); it != modes.end(); it++)
for (auto it = modes.cbegin(); it != modes.cend(); it++)
power_saver->add(*it, *it, Settings::getInstance()->getString("PowerSaverMode") == *it);
s->addWithLabel("POWER SAVER MODES", power_saver);
s->addSaveFunc([this, power_saver] {

View file

@ -47,7 +47,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
mGrid.setEntry(mList, Vector2i(0, 1), true, true);
// populate list
for(auto iter = mdd.begin(); iter != mdd.end(); iter++)
for(auto iter = mdd.cbegin(); iter != mdd.cend(); iter++)
{
std::shared_ptr<GuiComponent> ed;

View file

@ -74,7 +74,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
GuiScraperMulti::~GuiScraperMulti()
{
// view type probably changed (basic -> detailed)
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
ViewController::get()->reloadGameListView(*it, false);
}

View file

@ -23,7 +23,7 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
//add systems (all with a platformid specified selected)
mSystems = std::make_shared< OptionListComponent<SystemData*> >(mWindow, "SCRAPE THESE SYSTEMS", true);
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
{
if(!(*it)->hasPlatformId(PlatformIds::PLATFORM_IGNORE))
mSystems->add((*it)->getFullName(), *it, !(*it)->getPlatformIds().empty());
@ -43,7 +43,7 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
void GuiScraperStart::pressedStart()
{
std::vector<SystemData*> sys = mSystems->getSelectedObjects();
for(auto it = sys.begin(); it != sys.end(); it++)
for(auto it = sys.cbegin(); it != sys.cend(); it++)
{
if((*it)->getPlatformIds().empty())
{
@ -76,10 +76,10 @@ void GuiScraperStart::start()
std::queue<ScraperSearchParams> GuiScraperStart::getSearches(std::vector<SystemData*> systems, GameFilterFunc selector)
{
std::queue<ScraperSearchParams> queue;
for(auto sys = systems.begin(); sys != systems.end(); sys++)
for(auto sys = systems.cbegin(); sys != systems.cend(); sys++)
{
std::vector<FileData*> games = (*sys)->getRootFolder()->getFilesRecursive(GAME);
for(auto game = games.begin(); game != games.end(); game++)
for(auto game = games.cbegin(); game != games.cend(); game++)
{
if(selector((*sys), (*game)))
{

View file

@ -25,7 +25,7 @@ void GuiScreensaverOptions::save()
if(!mSaveFuncs.size())
return;
for(auto it = mSaveFuncs.begin(); it != mSaveFuncs.end(); it++)
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)();
Settings::getInstance()->saveFile();

View file

@ -25,7 +25,7 @@ void GuiSettings::save()
if(!mSaveFuncs.size())
return;
for(auto it = mSaveFuncs.begin(); it != mSaveFuncs.end(); it++)
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)();
Settings::getInstance()->saveFile();

View file

@ -37,7 +37,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
info_type.push_back("always");
info_type.push_back("start & end");
info_type.push_back("never");
for(auto it = info_type.begin(); it != info_type.end(); it++)
for(auto it = info_type.cbegin(); it != info_type.cend(); it++)
ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it);
addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info);
addSaveFunc([ss_info, this] { Settings::getInstance()->setString("ScreenSaverGameInfo", ss_info->getSelected()); });

View file

@ -104,11 +104,11 @@ void thegamesdb_generate_scraper_requests(const ScraperSearchParams& params, std
// because TheGamesDB API either sucks or I don't know how to use it properly...
std::string urlBase = path;
auto& platforms = params.system->getPlatformIds();
for(auto platformIt = platforms.begin(); platformIt != platforms.end(); platformIt++)
for(auto platformIt = platforms.cbegin(); platformIt != platforms.cend(); platformIt++)
{
path = urlBase;
auto mapIt = gamesdb_platformid_map.find(*platformIt);
if(mapIt != gamesdb_platformid_map.end())
if(mapIt != gamesdb_platformid_map.cend())
{
path += "&platform=";
path += HttpReq::urlEncode(mapIt->second);

View file

@ -26,7 +26,7 @@ std::unique_ptr<ScraperSearchHandle> startScraperSearch(const ScraperSearchParam
std::vector<std::string> getScraperList()
{
std::vector<std::string> list;
for(auto it = scraper_request_funcs.begin(); it != scraper_request_funcs.end(); it++)
for(auto it = scraper_request_funcs.cbegin(); it != scraper_request_funcs.cend(); it++)
{
list.push_back(it->first);
}
@ -142,8 +142,8 @@ void MDResolveHandle::update()
if(mStatus == ASYNC_DONE || mStatus == ASYNC_ERROR)
return;
auto it = mFuncs.begin();
while(it != mFuncs.end())
auto it = mFuncs.cbegin();
while(it != mFuncs.cend())
{
if(it->first->status() == ASYNC_ERROR)
{

View file

@ -29,7 +29,7 @@ void SystemView::populate()
{
mEntries.clear();
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
{
const std::shared_ptr<ThemeData>& theme = (*it)->getTheme();

View file

@ -48,7 +48,7 @@ void ViewController::goToStart()
auto requestedSystem = Settings::getInstance()->getString("StartupSystem");
if("" != requestedSystem && "retropie" != requestedSystem)
{
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++){
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++){
if ((*it)->getName() == requestedSystem)
{
goToGameList(*it);
@ -62,7 +62,7 @@ void ViewController::goToStart()
int ViewController::getSystemId(SystemData* system)
{
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
return std::find(sysVec.begin(), sysVec.end(), system) - sysVec.begin();
return std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin();
}
void ViewController::goToSystemView(SystemData* system)
@ -188,7 +188,7 @@ void ViewController::playViewTransition()
void ViewController::onFileChanged(FileData* file, FileChangeType change)
{
auto it = mGameListViews.find(file->getSystem());
if(it != mGameListViews.end())
if(it != mGameListViews.cend())
it->second->onFileChanged(file, change);
}
@ -249,7 +249,7 @@ void ViewController::removeGameListView(SystemData* system)
{
//if we already made one, return that one
auto exists = mGameListViews.find(system);
if(exists != mGameListViews.end())
if(exists != mGameListViews.cend())
{
exists->second.reset();
mGameListViews.erase(system);
@ -260,7 +260,7 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
{
//if we already made one, return that one
auto exists = mGameListViews.find(system);
if(exists != mGameListViews.end())
if(exists != mGameListViews.cend())
return exists->second;
//if we didn't, make it, remember it, and return it
@ -282,7 +282,7 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
if (selectedViewType == AUTOMATIC)
{
std::vector<FileData*> files = system->getRootFolder()->getFilesRecursive(GAME | FOLDER);
for (auto it = files.begin(); it != files.end(); it++)
for (auto it = files.cbegin(); it != files.cend(); it++)
{
if (themeHasVideoView && !(*it)->getVideoPath().empty())
{
@ -318,7 +318,7 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
view->setTheme(system->getTheme());
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
int id = std::find(sysVec.begin(), sysVec.end(), system) - sysVec.begin();
int id = std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin();
view->setPosition(id * (float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight() * 2);
addChild(view.get());
@ -386,7 +386,7 @@ void ViewController::render(const Transform4x4f& parentTrans)
getSystemListView()->render(trans);
// draw gamelists
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
{
// clipping
Vector3f guiStart = it->second->getPosition();
@ -410,7 +410,7 @@ void ViewController::render(const Transform4x4f& parentTrans)
void ViewController::preload()
{
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
for(auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it++)
{
(*it)->getIndex()->resetFilters();
getGameListView(*it);
@ -419,7 +419,7 @@ void ViewController::preload()
void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
{
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
{
if(it->second.get() == view)
{
@ -452,7 +452,7 @@ void ViewController::reloadAll()
{
// clear all gamelistviews
std::map<SystemData*, FileData*> cursorMap;
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
for(auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++)
{
cursorMap[it->first] = it->second->getCursor();
}
@ -460,7 +460,7 @@ void ViewController::reloadAll()
// load themes, create gamelistviews and reset filters
for(auto it = cursorMap.begin(); it != cursorMap.end(); it++)
for(auto it = cursorMap.cbegin(); it != cursorMap.cend(); it++)
{
it->first->loadTheme();
it->first->getIndex()->resetFilters();

View file

@ -44,7 +44,7 @@ void BasicGameListView::populateList(const std::vector<FileData*>& files)
mHeaderText.setText(mRoot->getSystem()->getFullName());
if (files.size() > 0)
{
for(auto it = files.begin(); it != files.end(); it++)
for(auto it = files.cbegin(); it != files.cend(); it++)
{
mList.add((*it)->getName(), *it, ((*it)->getType() == FOLDER));
}
@ -109,9 +109,9 @@ void BasicGameListView::remove(FileData *game, bool deleteFile)
if (getCursor() == game) // Select next element in list, or prev if none
{
std::vector<FileData*> siblings = parent->getChildrenListToDisplay();
auto gameIter = std::find(siblings.begin(), siblings.end(), game);
unsigned int gamePos = std::distance(siblings.begin(), gameIter);
if (gameIter != siblings.end())
auto gameIter = std::find(siblings.cbegin(), siblings.cend(), game);
unsigned int gamePos = std::distance(siblings.cbegin(), gameIter);
if (gameIter != siblings.cend())
{
if ((gamePos + 1) < siblings.size())
{

View file

@ -214,9 +214,9 @@ void DetailedGameListView::updateInfoPanel()
comps.push_back(&mImage);
comps.push_back(&mDescription);
std::vector<TextComponent*> labels = getMDLabels();
comps.insert(comps.end(), labels.begin(), labels.end());
comps.insert(comps.cend(), labels.cbegin(), labels.cend());
for(auto it = comps.begin(); it != comps.end(); it++)
for(auto it = comps.cbegin(); it != comps.cend(); it++)
{
GuiComponent* comp = *it;
// an animation is playing

View file

@ -37,7 +37,7 @@ bool GridGameListView::input(InputConfig* config, Input input)
void GridGameListView::populateList(const std::vector<FileData*>& files)
{
mGrid.clear();
for(auto it = files.begin(); it != files.end(); it++)
for(auto it = files.cbegin(); it != files.cend(); it++)
{
mGrid.add((*it)->getName(), (*it)->getThumbnailPath(), *it);
}

View file

@ -272,9 +272,9 @@ void VideoGameListView::updateInfoPanel()
comps.push_back(&mDescription);
comps.push_back(&mImage);
std::vector<TextComponent*> labels = getMDLabels();
comps.insert(comps.end(), labels.begin(), labels.end());
comps.insert(comps.cend(), labels.cbegin(), labels.cend());
for(auto it = comps.begin(); it != comps.end(); it++)
for(auto it = comps.cbegin(); it != comps.cend(); it++)
{
GuiComponent* comp = *it;
// an animation is playing

View file

@ -125,7 +125,7 @@ void AudioManager::unregisterSound(std::shared_ptr<Sound> & sound)
if(sSoundVector.at(i) == sound)
{
sSoundVector[i]->stop();
sSoundVector.erase(sSoundVector.begin() + i);
sSoundVector.erase(sSoundVector.cbegin() + i);
return;
}
}

View file

@ -185,7 +185,7 @@ void GuiComponent::removeChild(GuiComponent* cmp)
cmp->setParent(NULL);
for(auto i = mChildren.begin(); i != mChildren.end(); i++)
for(auto i = mChildren.cbegin(); i != mChildren.cend(); i++)
{
if(*i == cmp)
{
@ -235,7 +235,7 @@ unsigned char GuiComponent::getOpacity() const
void GuiComponent::setOpacity(unsigned char opacity)
{
mOpacity = opacity;
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
for(auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
{
(*it)->setOpacity(opacity);
}
@ -281,7 +281,7 @@ std::string GuiComponent::getValue() const
void GuiComponent::textInput(const char* text)
{
for(auto iter = mChildren.begin(); iter != mChildren.end(); iter++)
for(auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
{
(*iter)->textInput(text);
}

View file

@ -72,14 +72,14 @@ void InputConfig::mapInput(const std::string& name, Input input)
void InputConfig::unmapInput(const std::string& name)
{
auto it = mNameMap.find(toLower(name));
if(it != mNameMap.end())
if(it != mNameMap.cend())
mNameMap.erase(it);
}
bool InputConfig::getInputByName(const std::string& name, Input* result)
{
auto it = mNameMap.find(toLower(name));
if(it != mNameMap.end())
if(it != mNameMap.cend())
{
*result = it->second;
return true;
@ -115,8 +115,8 @@ std::vector<std::string> InputConfig::getMappedTo(Input input)
{
std::vector<std::string> maps;
typedef std::map<std::string, Input>::iterator it_type;
for(it_type iterator = mNameMap.begin(); iterator != mNameMap.end(); iterator++)
typedef std::map<std::string, Input>::const_iterator it_type;
for(it_type iterator = mNameMap.cbegin(); iterator != mNameMap.cend(); iterator++)
{
Input chk = iterator->second;
@ -188,8 +188,8 @@ void InputConfig::writeToXML(pugi::xml_node& parent)
cfg.append_attribute("deviceGUID") = mDeviceGUID.c_str();
typedef std::map<std::string, Input>::iterator it_type;
for(it_type iterator = mNameMap.begin(); iterator != mNameMap.end(); iterator++)
typedef std::map<std::string, Input>::const_iterator it_type;
for(it_type iterator = mNameMap.cbegin(); iterator != mNameMap.cend(); iterator++)
{
if(!iterator->second.configured)
continue;

View file

@ -121,7 +121,7 @@ void InputManager::removeJoystickByJoystickID(SDL_JoystickID joyId)
// close the joystick
auto joyIt = mJoysticks.find(joyId);
if(joyIt != mJoysticks.end())
if(joyIt != mJoysticks.cend())
{
SDL_JoystickClose(joyIt->second);
mJoysticks.erase(joyIt);
@ -135,19 +135,19 @@ void InputManager::deinit()
if(!initialized())
return;
for(auto iter = mJoysticks.begin(); iter != mJoysticks.end(); iter++)
for(auto iter = mJoysticks.cbegin(); iter != mJoysticks.cend(); iter++)
{
SDL_JoystickClose(iter->second);
}
mJoysticks.clear();
for(auto iter = mInputConfigs.begin(); iter != mInputConfigs.end(); iter++)
for(auto iter = mInputConfigs.cbegin(); iter != mInputConfigs.cend(); iter++)
{
delete iter->second;
}
mInputConfigs.clear();
for(auto iter = mPrevAxisValues.begin(); iter != mPrevAxisValues.end(); iter++)
for(auto iter = mPrevAxisValues.cbegin(); iter != mPrevAxisValues.cend(); iter++)
{
delete[] iter->second;
}
@ -453,7 +453,7 @@ bool InputManager::initialized() const
int InputManager::getNumConfiguredDevices()
{
int num = 0;
for(auto it = mInputConfigs.begin(); it != mInputConfigs.end(); it++)
for(auto it = mInputConfigs.cbegin(); it != mInputConfigs.cend(); it++)
{
if(it->second->isConfigured())
num++;
@ -477,7 +477,7 @@ std::string InputManager::getDeviceGUIDString(int deviceId)
return CEC_GUID_STRING;
auto it = mJoysticks.find(deviceId);
if(it == mJoysticks.end())
if(it == mJoysticks.cend())
{
LOG(LogError) << "getDeviceGUIDString - deviceId " << deviceId << " not found!";
return "something went horribly wrong";

View file

@ -132,10 +132,10 @@ void Settings::setDefaults()
template <typename K, typename V>
void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const char* type)
{
for(auto iter = map.begin(); iter != map.end(); iter++)
for(auto iter = map.cbegin(); iter != map.cend(); iter++)
{
// key is on the "don't save" list, so don't save it
if(std::find(settings_dont_save.begin(), settings_dont_save.end(), iter->first) != settings_dont_save.end())
if(std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), iter->first) != settings_dont_save.cend())
continue;
pugi::xml_node node = doc.append_child(type);
@ -155,7 +155,7 @@ void Settings::saveFile()
saveMap<std::string, float>(doc, mFloatMap, "float");
//saveMap<std::string, std::string>(doc, mStringMap, "string");
for(auto iter = mStringMap.begin(); iter != mStringMap.end(); iter++)
for(auto iter = mStringMap.cbegin(); iter != mStringMap.cend(); iter++)
{
pugi::xml_node node = doc.append_child("string");
node.append_attribute("name").set_value(iter->first.c_str());
@ -193,7 +193,7 @@ void Settings::loadFile()
//Print a warning message if the setting we're trying to get doesn't already exist in the map, then return the value in the map.
#define SETTINGS_GETSET(type, mapName, getMethodName, setMethodName) type Settings::getMethodName(const std::string& name) \
{ \
if(mapName.find(name) == mapName.end()) \
if(mapName.find(name) == mapName.cend()) \
{ \
LOG(LogError) << "Tried to use unset setting " << name << "!"; \
} \

View file

@ -10,7 +10,7 @@ std::map< std::string, std::shared_ptr<Sound> > Sound::sMap;
std::shared_ptr<Sound> Sound::get(const std::string& path)
{
auto it = sMap.find(path);
if(it != sMap.end())
if(it != sMap.cend())
return it->second;
std::shared_ptr<Sound> sound = std::shared_ptr<Sound>(new Sound(path));

View file

@ -215,7 +215,7 @@ void ThemeData::loadFile(std::map<std::string, std::string> sysDataMap, const st
mViews.clear();
mVariables.clear();
mVariables.insert(sysDataMap.begin(), sysDataMap.end());
mVariables.insert(sysDataMap.cbegin(), sysDataMap.cend());
pugi::xml_document doc;
pugi::xml_parse_result res = doc.load_file(path.c_str());
@ -286,7 +286,7 @@ void ThemeData::parseFeatures(const pugi::xml_node& root)
const std::string supportedAttr = node.attribute("supported").as_string();
if (std::find(sSupportedFeatures.begin(), sSupportedFeatures.end(), supportedAttr) != sSupportedFeatures.end())
if (std::find(sSupportedFeatures.cbegin(), sSupportedFeatures.cend(), supportedAttr) != sSupportedFeatures.cend())
{
parseViews(node);
}
@ -335,7 +335,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff);
if (std::find(sSupportedViews.begin(), sSupportedViews.end(), viewKey) != sSupportedViews.end())
if (std::find(sSupportedViews.cbegin(), sSupportedViews.cend(), viewKey) != sSupportedViews.cend())
{
ThemeView& view = mViews.insert(std::pair<std::string, ThemeView>(viewKey, ThemeView())).first->second;
parseView(node, view);
@ -355,7 +355,7 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
throw error << "Element of type \"" << node.name() << "\" missing \"name\" attribute!";
auto elemTypeIt = sElementMap.find(node.name());
if(elemTypeIt == sElementMap.end())
if(elemTypeIt == sElementMap.cend())
throw error << "Unknown element of type \"" << node.name() << "\"!";
const char* delim = " \t\r\n,";
@ -371,7 +371,7 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
parseElement(node, elemTypeIt->second,
view.elements.insert(std::pair<std::string, ThemeElement>(elemKey, ThemeElement())).first->second);
if(std::find(view.orderedKeys.begin(), view.orderedKeys.end(), elemKey) == view.orderedKeys.end())
if(std::find(view.orderedKeys.cbegin(), view.orderedKeys.cend(), elemKey) == view.orderedKeys.cend())
view.orderedKeys.push_back(elemKey);
}
}
@ -389,7 +389,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::map<std::str
for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling())
{
auto typeIt = typeMap.find(node.name());
if(typeIt == typeMap.end())
if(typeIt == typeMap.cend())
throw error << "Unknown property type \"" << node.name() << "\" (for element of type " << root.name() << ").";
std::string str = resolvePlaceholders(node.text().as_string());
@ -457,17 +457,17 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::map<std::str
bool ThemeData::hasView(const std::string& view)
{
auto viewIt = mViews.find(view);
return (viewIt != mViews.end());
return (viewIt != mViews.cend());
}
const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view, const std::string& element, const std::string& expectedType) const
{
auto viewIt = mViews.find(view);
if(viewIt == mViews.end())
if(viewIt == mViews.cend())
return NULL; // not found
auto elemIt = viewIt->second.elements.find(element);
if(elemIt == viewIt->second.elements.end()) return NULL;
if(elemIt == viewIt->second.elements.cend()) return NULL;
if(elemIt->second.type != expectedType && !expectedType.empty())
{
@ -509,10 +509,10 @@ std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData
std::vector<GuiComponent*> comps;
auto viewIt = theme->mViews.find(view);
if(viewIt == theme->mViews.end())
if(viewIt == theme->mViews.cend())
return comps;
for(auto it = viewIt->second.orderedKeys.begin(); it != viewIt->second.orderedKeys.end(); it++)
for(auto it = viewIt->second.orderedKeys.cbegin(); it != viewIt->second.orderedKeys.cend(); it++)
{
ThemeElement& elem = viewIt->second.elements.at(*it);
if(elem.extra)
@ -572,11 +572,11 @@ fs::path ThemeData::getThemeFromCurrentSet(const std::string& system)
return "";
}
auto set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set == themeSets.end())
std::map<std::string, ThemeSet>::const_iterator set = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if(set == themeSets.cend())
{
// currently selected theme set is missing, so just pick the first available set
set = themeSets.begin();
set = themeSets.cbegin();
Settings::getInstance()->setString("ThemeSet", set->first);
}

View file

@ -58,7 +58,7 @@ public:
inline void setFiles(const std::deque<boost::filesystem::path>& deque)
{
*this << "from theme \"" << deque.front().string() << "\"\n";
for(auto it = deque.begin() + 1; it != deque.end(); it++)
for(auto it = deque.cbegin() + 1; it != deque.cend(); it++)
*this << " (from included file \"" << (*it).string() << "\")\n";
*this << " ";
}
@ -96,7 +96,7 @@ public:
template<typename T>
T get(const std::string& prop) const { return boost::get<T>(properties.at(prop)); }
inline bool has(const std::string& prop) const { return (properties.find(prop) != properties.end()); }
inline bool has(const std::string& prop) const { return (properties.find(prop) != properties.cend()); }
};
private:

View file

@ -276,7 +276,7 @@ std::string vectorToCommaString(std::vector<std::string> stringVector)
std::string out = "";
std::sort(stringVector.begin(), stringVector.end());
// from a vector of system names get comma separated string
for(std::vector<std::string>::iterator it = stringVector.begin() ; it != stringVector.end() ; it++ )
for(std::vector<std::string>::const_iterator it = stringVector.cbegin() ; it != stringVector.cend() ; it++ )
{
out = out + (out == "" ? "" : ",") + (*it);
}

View file

@ -41,13 +41,13 @@ void Window::pushGui(GuiComponent* gui)
void Window::removeGui(GuiComponent* gui)
{
for(auto i = mGuiStack.begin(); i != mGuiStack.end(); i++)
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
{
if(*i == gui)
{
i = mGuiStack.erase(i);
if(i == mGuiStack.end() && mGuiStack.size()) // we just popped the stack and the stack is not empty
if(i == mGuiStack.cend() && mGuiStack.size()) // we just popped the stack and the stack is not empty
{
mGuiStack.back()->updateHelpPrompts();
mGuiStack.back()->topWindow(true);
@ -99,7 +99,7 @@ bool Window::init(unsigned int width, unsigned int height)
void Window::deinit()
{
// Hide all GUI elements on uninitialisation - this disable
for(auto i = mGuiStack.begin(); i != mGuiStack.end(); i++)
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
{
(*i)->onHide();
}
@ -332,14 +332,14 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpSt
std::map<std::string, bool> inputSeenMap;
std::map<std::string, int> mappedToSeenMap;
for(auto it = prompts.begin(); it != prompts.end(); it++)
for(auto it = prompts.cbegin(); it != prompts.cend(); it++)
{
// only add it if the same icon hasn't already been added
if(inputSeenMap.emplace(it->first, true).second)
{
// this symbol hasn't been seen yet, what about the action name?
auto mappedTo = mappedToSeenMap.find(it->second);
if(mappedTo != mappedToSeenMap.end())
if(mappedTo != mappedToSeenMap.cend())
{
// yes, it has!
@ -404,7 +404,7 @@ void Window::onWake()
bool Window::isProcessing()
{
return count_if(mGuiStack.begin(), mGuiStack.end(), [](GuiComponent* c) { return c->isProcessing(); }) > 0;
return count_if(mGuiStack.cbegin(), mGuiStack.cend(), [](GuiComponent* c) { return c->isProcessing(); }) > 0;
}
void Window::startScreenSaver()
@ -412,7 +412,7 @@ void Window::startScreenSaver()
if (mScreenSaver && !mRenderScreenSaver)
{
// Tell the GUI components the screensaver is starting
for(auto i = mGuiStack.begin(); i != mGuiStack.end(); i++)
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
(*i)->onScreenSaverActivate();
mScreenSaver->startScreenSaver();
@ -428,7 +428,7 @@ void Window::startScreenSaver()
mRenderScreenSaver = false;
// Tell the GUI components the screensaver has stopped
for(auto i = mGuiStack.begin(); i != mGuiStack.end(); i++)
for(auto i = mGuiStack.cbegin(); i != mGuiStack.cend(); i++)
(*i)->onScreenSaverDeactivate();
}
}

View file

@ -44,7 +44,7 @@ void AnimatedImageComponent::reset()
void AnimatedImageComponent::onSizeChanged()
{
for(auto it = mFrames.begin(); it != mFrames.end(); it++)
for(auto it = mFrames.cbegin(); it != mFrames.cend(); it++)
{
it->first->setResize(mSize.x(), mSize.y());
}

View file

@ -107,7 +107,7 @@ void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp, const Ve
bool ComponentGrid::removeEntry(const std::shared_ptr<GuiComponent>& comp)
{
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
if(it->component == comp)
{
@ -155,7 +155,7 @@ void ComponentGrid::updateSeparators()
Vector2f pos;
Vector2f size;
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
if(!it->border && !drawAll)
continue;
@ -200,17 +200,17 @@ void ComponentGrid::updateSeparators()
void ComponentGrid::onSizeChanged()
{
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
updateCellComponent(*it);
updateSeparators();
}
ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y)
const ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y) const
{
assert(x >= 0 && x < mGridSize.x() && y >= 0 && y < mGridSize.y());
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
int xmin = it->pos.x();
int xmax = xmin + it->dim.x();
@ -226,7 +226,7 @@ ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y)
bool ComponentGrid::input(InputConfig* config, Input input)
{
GridEntry* cursorEntry = getCellAt(mCursor);
const GridEntry* cursorEntry = getCellAt(mCursor);
if(cursorEntry && cursorEntry->component->input(config, input))
return true;
@ -258,7 +258,7 @@ void ComponentGrid::resetCursor()
if(!mCells.size())
return;
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
if(it->canFocus)
{
@ -276,7 +276,7 @@ bool ComponentGrid::moveCursor(Vector2i dir)
const Vector2i origCursor = mCursor;
GridEntry* currentCursorEntry = getCellAt(mCursor);
const GridEntry* currentCursorEntry = getCellAt(mCursor);
Vector2i searchAxis(dir.x() == 0, dir.y() == 0);
@ -286,7 +286,7 @@ bool ComponentGrid::moveCursor(Vector2i dir)
Vector2i curDirPos = mCursor;
GridEntry* cursorEntry;
const GridEntry* cursorEntry;
//spread out on search axis+
while(mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y()
&& mCursor.x() >= 0 && mCursor.y() >= 0)
@ -326,29 +326,29 @@ bool ComponentGrid::moveCursor(Vector2i dir)
void ComponentGrid::onFocusLost()
{
GridEntry* cursorEntry = getCellAt(mCursor);
const GridEntry* cursorEntry = getCellAt(mCursor);
if(cursorEntry)
cursorEntry->component->onFocusLost();
}
void ComponentGrid::onFocusGained()
{
GridEntry* cursorEntry = getCellAt(mCursor);
const GridEntry* cursorEntry = getCellAt(mCursor);
if(cursorEntry)
cursorEntry->component->onFocusGained();
}
bool ComponentGrid::cursorValid()
{
GridEntry* e = getCellAt(mCursor);
const GridEntry* e = getCellAt(mCursor);
return (e != NULL && e->canFocus);
}
void ComponentGrid::update(int deltaTime)
{
// update ALL THE THINGS
GridEntry* cursorEntry = getCellAt(mCursor);
for(auto it = mCells.begin(); it != mCells.end(); it++)
const GridEntry* cursorEntry = getCellAt(mCursor);
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
if(it->updateType == UPDATE_ALWAYS || (it->updateType == UPDATE_WHEN_SELECTED && cursorEntry == &(*it)))
it->component->update(deltaTime);
@ -384,14 +384,14 @@ void ComponentGrid::render(const Transform4x4f& parentTrans)
void ComponentGrid::textInput(const char* text)
{
GridEntry* selectedEntry = getCellAt(mCursor);
const GridEntry* selectedEntry = getCellAt(mCursor);
if(selectedEntry != NULL && selectedEntry->canFocus)
selectedEntry->component->textInput(text);
}
void ComponentGrid::onCursorMoved(Vector2i from, Vector2i to)
{
GridEntry* cell = getCellAt(from);
const GridEntry* cell = getCellAt(from);
if(cell)
cell->component->onFocusLost();
@ -404,7 +404,7 @@ void ComponentGrid::onCursorMoved(Vector2i from, Vector2i to)
void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
{
for(auto it = mCells.begin(); it != mCells.end(); it++)
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
if(it->component == comp)
{
@ -422,13 +422,13 @@ void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
GridEntry* e = getCellAt(mCursor);
const GridEntry* e = getCellAt(mCursor);
if(e)
prompts = e->component->getHelpPrompts();
bool canScrollVert = mGridSize.y() > 1;
bool canScrollHoriz = mGridSize.x() > 1;
for(auto it = prompts.begin(); it != prompts.end(); it++)
for(auto it = prompts.cbegin(); it != prompts.cend(); it++)
{
if(it->first == "up/down/left/right")
{

View file

@ -57,7 +57,7 @@ public:
inline std::shared_ptr<GuiComponent> getSelectedComponent()
{
GridEntry* e = getCellAt(mCursor);
const GridEntry* e = getCellAt(mCursor);
if(e)
return e->component;
else
@ -110,8 +110,8 @@ private:
void updateCellComponent(const GridEntry& cell);
void updateSeparators();
GridEntry* getCellAt(int x, int y);
inline GridEntry* getCellAt(const Vector2i& pos) { return getCellAt(pos.x(), pos.y()); }
const GridEntry* getCellAt(int x, int y) const;
inline const GridEntry* getCellAt(const Vector2i& pos) const { return getCellAt(pos.x(), pos.y()); }
Vector2i mGridSize;

View file

@ -20,7 +20,7 @@ void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
this->add(e);
for(auto it = mEntries.back().data.elements.begin(); it != mEntries.back().data.elements.end(); it++)
for(auto it = mEntries.back().data.elements.cbegin(); it != mEntries.back().data.elements.cend(); it++)
addChild(it->component.get());
updateElementSize(mEntries.back().data);
@ -35,7 +35,7 @@ void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
void ComponentList::onSizeChanged()
{
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
updateElementSize(it->data);
updateElementPosition(it->data);
@ -99,7 +99,7 @@ void ComponentList::update(int deltaTime)
if(size())
{
// update our currently selected row
for(auto it = mEntries.at(mCursor).data.elements.begin(); it != mEntries.at(mCursor).data.elements.end(); it++)
for(auto it = mEntries.at(mCursor).data.elements.cbegin(); it != mEntries.at(mCursor).data.elements.cend(); it++)
it->component->update(deltaTime);
}
}
@ -119,7 +119,7 @@ void ComponentList::onCursorChanged(const CursorState& state)
// this is terribly inefficient but we don't know what we came from so...
if(size())
{
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
it->data.elements.back().component->onFocusLost();
mEntries.at(mCursor).data.elements.back().component->onFocusGained();
@ -181,7 +181,7 @@ void ComponentList::render(const Transform4x4f& parentTrans)
{
auto& entry = mEntries.at(i);
drawAll = !mFocused || i != (unsigned int)mCursor;
for(auto it = entry.data.elements.begin(); it != entry.data.elements.end(); it++)
for(auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++)
{
if(drawAll || it->invert_when_selected)
{
@ -213,7 +213,7 @@ void ComponentList::render(const Transform4x4f& parentTrans)
Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
for(auto it = drawAfterCursor.begin(); it != drawAfterCursor.end(); it++)
for(auto it = drawAfterCursor.cbegin(); it != drawAfterCursor.cend(); it++)
(*it)->render(trans);
// reset matrix if one of these components changed it
@ -249,7 +249,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const
float ComponentList::getTotalRowHeight() const
{
float height = 0;
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
height += getRowHeight(it->data);
}
@ -260,7 +260,7 @@ float ComponentList::getTotalRowHeight() const
void ComponentList::updateElementPosition(const ComponentListRow& row)
{
float yOffset = 0;
for(auto it = mEntries.begin(); it != mEntries.end() && &it->data != &row; it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend() && &it->data != &row; it++)
{
yOffset += getRowHeight(it->data);
}
@ -284,7 +284,7 @@ void ComponentList::updateElementSize(const ComponentListRow& row)
float width = mSize.x() - TOTAL_HORIZONTAL_PADDING_PX;
std::vector< std::shared_ptr<GuiComponent> > resizeVec;
for(auto it = row.elements.begin(); it != row.elements.end(); it++)
for(auto it = row.elements.cbegin(); it != row.elements.cend(); it++)
{
if(it->resize_width)
resizeVec.push_back(it->component);
@ -294,7 +294,7 @@ void ComponentList::updateElementSize(const ComponentListRow& row)
// redistribute the "unused" width equally among the components with resize_width set to true
width = width / resizeVec.size();
for(auto it = resizeVec.begin(); it != resizeVec.end(); it++)
for(auto it = resizeVec.cbegin(); it != resizeVec.cend(); it++)
{
(*it)->setSize(width, (*it)->getSize().y());
}
@ -318,7 +318,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
if(size() > 1)
{
bool addMovePrompt = true;
for(auto it = prompts.begin(); it != prompts.end(); it++)
for(auto it = prompts.cbegin(); it != prompts.cend(); it++)
{
if(it->first == "up/down" || it->first == "up/down/left/right")
{

View file

@ -68,7 +68,7 @@ void HelpComponent::updateGrid()
float width = 0;
const float height = round(font->getLetterHeight() * 1.25f);
for(auto it = mPrompts.begin(); it != mPrompts.end(); it++)
for(auto it = mPrompts.cbegin(); it != mPrompts.cend(); it++)
{
auto icon = std::make_shared<ImageComponent>(mWindow);
icon->setImage(getIconTexture(it->first.c_str()));
@ -101,11 +101,11 @@ void HelpComponent::updateGrid()
std::shared_ptr<TextureResource> HelpComponent::getIconTexture(const char* name)
{
auto it = mIconCache.find(name);
if(it != mIconCache.end())
if(it != mIconCache.cend())
return it->second;
auto pathLookup = ICON_PATH_MAP.find(name);
if(pathLookup == ICON_PATH_MAP.end())
if(pathLookup == ICON_PATH_MAP.cend())
{
LOG(LogError) << "Unknown help icon \"" << name << "\"!";
return nullptr;

View file

@ -129,21 +129,21 @@ public:
return mEntries.at(mCursor).object;
}
void setCursor(typename std::vector<Entry>::iterator& it)
void setCursor(typename std::vector<Entry>::const_iterator& it)
{
assert(it != mEntries.end());
mCursor = it - mEntries.begin();
assert(it != mEntries.cend());
mCursor = it - mEntries.cbegin();
onCursorChanged(CURSOR_STOPPED);
}
// returns true if successful (select is in our list), false if not
bool setCursor(const UserData& obj)
{
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
if((*it).object == obj)
{
mCursor = it - mEntries.begin();
mCursor = it - mEntries.cbegin();
onCursorChanged(CURSOR_STOPPED);
return true;
}
@ -160,7 +160,7 @@ public:
bool remove(const UserData& obj)
{
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
if((*it).object == obj)
{
@ -175,9 +175,9 @@ public:
inline int size() const { return mEntries.size(); }
protected:
void remove(typename std::vector<Entry>::iterator& it)
void remove(typename std::vector<Entry>::const_iterator& it)
{
if(mCursor > 0 && it - mEntries.begin() <= mCursor)
if(mCursor > 0 && it - mEntries.cbegin() <= mCursor)
{
mCursor--;
onCursorChanged(CURSOR_STOPPED);

View file

@ -62,7 +62,7 @@ private:
Vector2f squareSize(32, 32);
// calc biggest square size
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
Vector2f chkSize = getSquareSize(it->data.texture);
if(chkSize.x() > squareSize.x())

View file

@ -219,7 +219,7 @@ public:
std::vector<T> getSelectedObjects()
{
std::vector<T> ret;
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
if(it->selected)
ret.push_back(it->object);
@ -298,7 +298,7 @@ private:
mParent->onSizeChanged();
}else{
// display currently selected + l/r cursors
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
{
if(it->selected)
{

View file

@ -29,7 +29,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
{
mAcceleratorFunc = mButtons.front()->getPressedFunc();
}else{
for(auto it = mButtons.begin(); it != mButtons.end(); it++)
for(auto it = mButtons.cbegin(); it != mButtons.cend(); it++)
{
if(strToUpper((*it)->getText()) == "OK" || strToUpper((*it)->getText()) == "NO")
{

View file

@ -39,10 +39,10 @@ void Font::initLibrary()
size_t Font::getMemUsage() const
{
size_t memUsage = 0;
for(auto it = mTextures.begin(); it != mTextures.end(); it++)
for(auto it = mTextures.cbegin(); it != mTextures.cend(); it++)
memUsage += it->textureSize.x() * it->textureSize.y() * 4;
for(auto it = mFaceCache.begin(); it != mFaceCache.end(); it++)
for(auto it = mFaceCache.cbegin(); it != mFaceCache.cend(); it++)
memUsage += it->second->data.length;
return memUsage;
@ -52,8 +52,8 @@ size_t Font::getTotalMemUsage()
{
size_t total = 0;
auto it = sFontMap.begin();
while(it != sFontMap.end())
auto it = sFontMap.cbegin();
while(it != sFontMap.cend())
{
if(it->second.expired())
{
@ -105,7 +105,7 @@ std::shared_ptr<Font> Font::get(int size, const std::string& path)
std::pair<std::string, int> def(canonicalPath.empty() ? getDefaultPath() : canonicalPath, size);
auto foundFont = sFontMap.find(def);
if(foundFont != sFontMap.end())
if(foundFont != sFontMap.cend())
{
if(!foundFont->second.expired())
return foundFont->second.lock();
@ -284,7 +284,7 @@ FT_Face Font::getFaceForChar(unsigned int id)
{
auto fit = mFaceCache.find(i);
if(fit == mFaceCache.end()) // doesn't exist yet
if(fit == mFaceCache.cend()) // doesn't exist yet
{
// i == 0 -> mPath
// otherwise, take from fallbackFonts
@ -299,7 +299,7 @@ FT_Face Font::getFaceForChar(unsigned int id)
}
// nothing has a valid glyph - return the "real" face so we get a "missing" character
return mFaceCache.begin()->second->face;
return mFaceCache.cbegin()->second->face;
}
void Font::clearFaceCache()
@ -311,7 +311,7 @@ Font::Glyph* Font::getGlyph(unsigned int id)
{
// is it already loaded?
auto it = mGlyphMap.find(id);
if(it != mGlyphMap.end())
if(it != mGlyphMap.cend())
return &it->second;
// nope, need to make a glyph
@ -376,7 +376,7 @@ void Font::rebuildTextures()
}
// reupload the texture data
for(auto it = mGlyphMap.begin(); it != mGlyphMap.end(); it++)
for(auto it = mGlyphMap.cbegin(); it != mGlyphMap.cend(); it++)
{
FT_Face face = getFaceForChar(it->first);
FT_GlyphSlot glyphSlot = face->glyph;
@ -406,7 +406,7 @@ void Font::renderTextCache(TextCache* cache)
return;
}
for(auto it = cache->vertexLists.begin(); it != cache->vertexLists.end(); it++)
for(auto it = cache->vertexLists.cbegin(); it != cache->vertexLists.cend(); it++)
{
assert(*it->textureIdPtr != 0);
@ -675,7 +675,7 @@ TextCache* Font::buildTextCache(const std::string& text, Vector2f offset, unsign
cache->metrics = { sizeText(text, lineSpacing) };
unsigned int i = 0;
for(auto it = vertMap.begin(); it != vertMap.end(); it++)
for(auto it = vertMap.cbegin(); it != vertMap.cend(); it++)
{
TextCache::VertexList& vertList = cache->vertexLists.at(i);
@ -698,8 +698,8 @@ TextCache* Font::buildTextCache(const std::string& text, float offsetX, float of
void TextCache::setColor(unsigned int color)
{
for(auto it = vertexLists.begin(); it != vertexLists.end(); it++)
Renderer::buildGLColorArray(it->colors.data(), color, it->verts.size());
for(auto it = vertexLists.cbegin(); it != vertexLists.cend(); it++)
Renderer::buildGLColorArray((GLubyte*)(it->colors.data()), color, it->verts.size());
}
std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem, unsigned int properties, const std::shared_ptr<Font>& orig)

View file

@ -27,7 +27,7 @@ const ResourceData ResourceManager::getFileData(const std::string& path) const
{
//check if its embedded
if(res2hMap.find(path) != res2hMap.end())
if(res2hMap.find(path) != res2hMap.cend())
{
//it is
Res2hEntry embeddedEntry = res2hMap.find(path)->second;
@ -70,7 +70,7 @@ ResourceData ResourceManager::loadFile(const std::string& path) const
bool ResourceManager::fileExists(const std::string& path) const
{
//if it exists as an embedded file, return true
if(res2hMap.find(path) != res2hMap.end())
if(res2hMap.find(path) != res2hMap.cend())
return true;
return fs::exists(path);
@ -78,8 +78,8 @@ bool ResourceManager::fileExists(const std::string& path) const
void ResourceManager::unloadAll()
{
auto iter = mReloadables.begin();
while(iter != mReloadables.end())
auto iter = mReloadables.cbegin();
while(iter != mReloadables.cend())
{
if(!iter->expired())
{
@ -93,8 +93,8 @@ void ResourceManager::unloadAll()
void ResourceManager::reloadAll()
{
auto iter = mReloadables.begin();
while(iter != mReloadables.end())
auto iter = mReloadables.cbegin();
while(iter != mReloadables.cend())
{
if(!iter->expired())
{

View file

@ -29,7 +29,7 @@ std::shared_ptr<TextureData> TextureDataManager::add(const TextureResource* key,
remove(key);
std::shared_ptr<TextureData> data(new TextureData(tiled));
mTextures.push_front(data);
mTextureLookup[key] = mTextures.begin();
mTextureLookup[key] = mTextures.cbegin();
return data;
}
@ -37,7 +37,7 @@ void TextureDataManager::remove(const TextureResource* key)
{
// Find the entry in the list
auto it = mTextureLookup.find(key);
if (it != mTextureLookup.end())
if (it != mTextureLookup.cend())
{
// Remove the list entry
mTextures.erase((*it).second);
@ -52,7 +52,7 @@ std::shared_ptr<TextureData> TextureDataManager::get(const TextureResource* key)
// move it to the top
std::shared_ptr<TextureData> tex;
auto it = mTextureLookup.find(key);
if (it != mTextureLookup.end())
if (it != mTextureLookup.cend())
{
tex = *(*it).second;
// Remove the list entry
@ -60,7 +60,7 @@ std::shared_ptr<TextureData> TextureDataManager::get(const TextureResource* key)
// Put it at the top
mTextures.push_front(tex);
// Store it back in the lookup
mTextureLookup[key] = mTextures.begin();
mTextureLookup[key] = mTextures.cbegin();
// Make sure it's loaded or queued for loading
load(tex);
@ -109,7 +109,7 @@ void TextureDataManager::load(std::shared_ptr<TextureData> tex, bool block)
size_t size = TextureResource::getTotalMemUsage();
size_t max_texture = (size_t)Settings::getInstance()->getInt("MaxVRAM") * 1024 * 1024;
for (auto it = mTextures.rbegin(); it != mTextures.rend(); ++it)
for (auto it = mTextures.crbegin(); it != mTextures.crend(); ++it)
{
if (size < max_texture)
break;
@ -187,7 +187,7 @@ void TextureLoader::load(std::shared_ptr<TextureData> textureData)
std::unique_lock<std::mutex> lock(mMutex);
// Remove it from the queue if it is already there
auto td = mTextureDataLookup.find(textureData.get());
if (td != mTextureDataLookup.end())
if (td != mTextureDataLookup.cend())
{
mTextureDataQ.erase((*td).second);
mTextureDataLookup.erase(td);
@ -195,7 +195,7 @@ void TextureLoader::load(std::shared_ptr<TextureData> textureData)
// Put it on the start of the queue as we want the newly requested textures to load first
mTextureDataQ.push_front(textureData);
mTextureDataLookup[textureData.get()] = mTextureDataQ.begin();
mTextureDataLookup[textureData.get()] = mTextureDataQ.cbegin();
mEvent.notify_one();
}
}
@ -205,7 +205,7 @@ void TextureLoader::remove(std::shared_ptr<TextureData> textureData)
// Just remove it from the queue so we don't attempt to load it
std::unique_lock<std::mutex> lock(mMutex);
auto td = mTextureDataLookup.find(textureData.get());
if (td != mTextureDataLookup.end())
if (td != mTextureDataLookup.cend())
{
mTextureDataQ.erase((*td).second);
mTextureDataLookup.erase(td);

View file

@ -28,7 +28,7 @@ private:
void threadProc();
std::list<std::shared_ptr<TextureData> > mTextureDataQ;
std::map<TextureData*, std::list<std::shared_ptr<TextureData> >::iterator > mTextureDataLookup;
std::map<TextureData*, std::list<std::shared_ptr<TextureData> >::const_iterator > mTextureDataLookup;
std::thread* mThread;
std::mutex mMutex;
@ -79,7 +79,7 @@ public:
private:
std::list<std::shared_ptr<TextureData> > mTextures;
std::map<const TextureResource*, std::list<std::shared_ptr<TextureData> >::iterator > mTextureLookup;
std::map<const TextureResource*, std::list<std::shared_ptr<TextureData> >::const_iterator > mTextureLookup;
std::shared_ptr<TextureData> mBlank;
TextureLoader* mLoader;
};

View file

@ -114,7 +114,7 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path, b
TextureKeyType key(canonicalPath, tile);
auto foundTexture = sTextureMap.find(key);
if(foundTexture != sTextureMap.end())
if(foundTexture != sTextureMap.cend())
{
if(!foundTexture->second.expired())
return foundTexture->second.lock();