diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2018-01-31 17:28:28 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2018-01-31 21:06:10 +0100 |
commit | b3122f5b208591505db552513976fe830317c02f (patch) | |
tree | 4dae763e25b3a82d259b2de5ed5247740d9b8207 | |
parent | a46006ded2e84e09774d570796277b3f831b3aee (diff) |
C++: automatically determine iterator typescxx-future
Having to specify the type of an iterator is annoying and does not
really add clarity to the code. With C++11 we can use "auto"
instead and in some cases remove helper typedefs.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
41 files changed, 119 insertions, 121 deletions
diff --git a/src/backends/activesync/ActiveSyncCalendarSource.cpp b/src/backends/activesync/ActiveSyncCalendarSource.cpp index 5d11d86d..df3f94ae 100644 --- a/src/backends/activesync/ActiveSyncCalendarSource.cpp +++ b/src/backends/activesync/ActiveSyncCalendarSource.cpp @@ -298,7 +298,7 @@ std::string ActiveSyncCalendarSource::getDescription(const string &luid) ActiveSyncCalendarSource::Event &ActiveSyncCalendarSource::findItem(const std::string &easid) { - EventCache::iterator it = m_cache.find(easid); + auto it = m_cache.find(easid); if (it == m_cache.end()) { throwError(SE_HERE, STATUS_NOT_FOUND, "merged event not found: " + easid); } @@ -444,7 +444,7 @@ SyncSourceRaw::InsertItemResult ActiveSyncCalendarSource::insertItem(const std:: // our caller didn't. std::string knownSubID = callerSubID; if (easid.empty()) { - EventCache::iterator it = m_cache.findByUID(newEvent->m_uid); + auto it = m_cache.findByUID(newEvent->m_uid); if (it != m_cache.end()) { easid = it->first; knownSubID = subid; @@ -458,7 +458,7 @@ SyncSourceRaw::InsertItemResult ActiveSyncCalendarSource::insertItem(const std:: InsertItemResult res = ActiveSyncSource::insertItem("", item); easid = res.m_luid; - EventCache::iterator it = m_cache.find(res.m_luid); + auto it = m_cache.find(res.m_luid); if (it != m_cache.end()) { // merge into existing Event Event &event = loadItem(*it->second); diff --git a/src/backends/activesync/ActiveSyncSource.cpp b/src/backends/activesync/ActiveSyncSource.cpp index 3e02ebbc..b301535d 100644 --- a/src/backends/activesync/ActiveSyncSource.cpp +++ b/src/backends/activesync/ActiveSyncSource.cpp @@ -192,7 +192,7 @@ std::string ActiveSyncSource::lookupFolder(const std::string &folder) { } // Lookup folder name - FolderPaths::const_iterator entry = m_folderPaths.find(key); + auto entry = m_folderPaths.find(key); if (entry != m_folderPaths.end()) { return entry->second; } @@ -523,7 +523,7 @@ SyncSourceSerialize::InsertItemResult ActiveSyncSource::insertItem(const std::st void ActiveSyncSource::readItem(const std::string &luid, std::string &item) { // return straight from cache? - std::map<std::string, std::string>::iterator it = m_items.find(luid); + auto it = m_items.find(luid); if (it == m_items.end()) { // no, must fetch EASItemPtr tmp(eas_item_info_new(), "EasItem"); diff --git a/src/backends/evolution/EvolutionCalendarSource.cpp b/src/backends/evolution/EvolutionCalendarSource.cpp index 2def786c..8cf33250 100644 --- a/src/backends/evolution/EvolutionCalendarSource.cpp +++ b/src/backends/evolution/EvolutionCalendarSource.cpp @@ -58,7 +58,7 @@ void EvolutionCalendarSource::LUIDs::eraseLUID(const ItemID &id) { iterator it = find(id.m_uid); if (it != end()) { - set<string>::iterator it2 = it->second.find(id.m_rid); + auto it2 = it->second.find(id.m_rid); if (it2 != it->second.end()) { it->second.erase(it2); if (it->second.empty()) { @@ -694,7 +694,7 @@ EvolutionCalendarSource::InsertItemResult EvolutionCalendarSource::insertItem(co // Therefore we have to use CALOBJ_MOD_ALL, but that removes // children. bool hasChildren = false; - LUIDs::const_iterator it = m_allLUIDs.find(id.m_uid); + auto it = m_allLUIDs.find(id.m_uid); if (it != m_allLUIDs.end()) { for (const string &rid: it->second) { if (!rid.empty()) { @@ -788,7 +788,7 @@ EvolutionCalendarSource::ICalComps_t EvolutionCalendarSource::removeEvents(const { ICalComps_t events; - LUIDs::const_iterator it = m_allLUIDs.find(uid); + auto it = m_allLUIDs.find(uid); if (it != m_allLUIDs.end()) { for (const string &rid: it->second) { ItemID id(uid, rid); diff --git a/src/backends/evolution/EvolutionContactSource.cpp b/src/backends/evolution/EvolutionContactSource.cpp index ba282d0d..0901be8a 100644 --- a/src/backends/evolution/EvolutionContactSource.cpp +++ b/src/backends/evolution/EvolutionContactSource.cpp @@ -538,7 +538,7 @@ void EvolutionContactSource::invalidateCachedContact(const std::string &luid) void EvolutionContactSource::invalidateCachedContact(std::shared_ptr<ContactCache> &cache, const std::string &luid) { if (cache) { - ContactCache::iterator it = cache->find(luid); + auto it = cache->find(luid); if (it != cache->end()) { SE_LOG_DEBUG(getDisplayName(), "reading: remove contact %s from cache because of remove or update", luid.c_str()); // If we happen to read that contact (unlikely), it'll be @@ -600,7 +600,7 @@ bool EvolutionContactSource::getContactFromCache(const string &luid, EContact ** checkCacheForError(m_contactCache); // Does the cache cover our item? - ContactCache::const_iterator it = m_contactCache->find(luid); + auto it = m_contactCache->find(luid); if (it == m_contactCache->end()) { if (m_contactCacheNext) { SE_LOG_DEBUG(getDisplayName(), "reading: not in cache, try cache %s", @@ -686,7 +686,7 @@ std::shared_ptr<ContactCache> EvolutionContactSource::startReading(const std::st const Items_t &items = getAllItems(); const Items_t &newItems = getNewItems(); const Items_t &updatedItems = getUpdatedItems(); - Items_t::const_iterator it = items.find(luid); + auto it = items.find(luid); // Always read the requested item, even if not found in item list? if (mode == START) { @@ -718,7 +718,7 @@ std::shared_ptr<ContactCache> EvolutionContactSource::startReading(const std::st break; } case READ_SELECTED_ITEMS: { - ReadAheadItems::const_iterator it = boost::find(std::make_pair(m_nextLUIDs.begin(), m_nextLUIDs.end()), luid); + auto it = boost::find(std::make_pair(m_nextLUIDs.begin(), m_nextLUIDs.end()), luid); // Always read the requested item, even if not found in item list? if (mode == START) { uids[0] = &luid; @@ -910,7 +910,7 @@ void EvolutionContactSource::flushItemChanges() // always valid here. SE_LOG_DEBUG(getDisplayName(), "batch add of %d contacts completed", (int)batched->size()); m_numRunningOperations--; - PendingContainer_t::iterator it = (*batched).begin(); + auto it = (*batched).begin(); GSList *uid = uids; while (it != (*batched).end() && uid) { SE_LOG_DEBUG((*it)->m_name, "completed: %s", @@ -957,7 +957,7 @@ void EvolutionContactSource::flushItemChanges() try { SE_LOG_DEBUG(getDisplayName(), "batch update of %d contacts completed", (int)batched->size()); m_numRunningOperations--; - PendingContainer_t::iterator it = (*batched).begin(); + auto it = (*batched).begin(); while (it != (*batched).end()) { SE_LOG_DEBUG((*it)->m_name, "completed: %s", success ? "<<successfully>>" : diff --git a/src/backends/goa/goa.cpp b/src/backends/goa/goa.cpp index 9877ff61..2794a987 100644 --- a/src/backends/goa/goa.cpp +++ b/src/backends/goa/goa.cpp @@ -116,16 +116,16 @@ std::shared_ptr<GOAAccount> GOAManager::lookupAccount(const std::string &usernam } SE_LOG_DEBUG(NULL, "GOA object %s implements %s", path.c_str(), boost::join(interfaceKeys, ", ").c_str()); - Interfaces::const_iterator it = interfaces.find(GOA_ACCOUNT_INTERFACE); + auto it = interfaces.find(GOA_ACCOUNT_INTERFACE); if (it != interfaces.end()) { const Properties &properties = it->second; - Properties::const_iterator id = properties.find(GOA_ACCOUNT_ID); - Properties::const_iterator presentationID = properties.find(GOA_ACCOUNT_PRESENTATION_IDENTITY); + auto id = properties.find(GOA_ACCOUNT_ID); + auto presentationID = properties.find(GOA_ACCOUNT_PRESENTATION_IDENTITY); if (id != properties.end() && presentationID != properties.end()) { const std::string &idStr = boost::get<std::string>(id->second); const std::string &presentationIDStr = boost::get<std::string>(presentationID->second); - Properties::const_iterator provider = properties.find(GOA_ACCOUNT_PROVIDER_NAME); + auto provider = properties.find(GOA_ACCOUNT_PROVIDER_NAME); std::string description = StringPrintf("%s, %s = %s", provider == properties.end() ? "???" : boost::get<std::string>(provider->second).c_str(), presentationIDStr.c_str(), diff --git a/src/backends/maemo/MaemoCalendarSource.cpp b/src/backends/maemo/MaemoCalendarSource.cpp index fce6c832..0349c0ee 100644 --- a/src/backends/maemo/MaemoCalendarSource.cpp +++ b/src/backends/maemo/MaemoCalendarSource.cpp @@ -278,7 +278,7 @@ TrackingSyncSource::InsertItemResult MaemoCalendarSource::insertItem(const strin throwError(SE_HERE, string("no events in ical: ") + item); } } - vector< CComponent * >::iterator it = comps.begin(); + vector< CComponent * auto it = comps.begin(); if (comps.size() > 1) { for (; it != comps.end(); ++it) { delete (*it); diff --git a/src/backends/pbap/PbapSyncSource.cpp b/src/backends/pbap/PbapSyncSource.cpp index 9e6713a0..beb10ae3 100644 --- a/src/backends/pbap/PbapSyncSource.cpp +++ b/src/backends/pbap/PbapSyncSource.cpp @@ -365,7 +365,7 @@ void PbapSession::propChangedCb(const GDBusCXX::Path_t &path, { // Called for a path which matches the current session, so we know // that the signal is for our transfer. Only need to check the status. - Params::const_iterator it = changed.find("Status"); + auto it = changed.find("Status"); if (it != changed.end()) { std::string status = boost::get<std::string>(it->second); SE_LOG_DEBUG(NULL, "OBEXD transfer %s: %s", @@ -661,7 +661,7 @@ void PbapSession::initSession(const std::string &address, const std::string &for continue; } - Properties::const_iterator entry = + auto entry = std::find_if(m_filterFields.begin(), m_filterFields.end(), [&prop] (const std::string &other) { return boost::iequals(other, prop, std::locale()); }); @@ -715,7 +715,7 @@ std::shared_ptr<PullAll> PbapSession::startPullAll(const PullParams &pullParams) if (filter.empty()) { filter = supportedProperties(); } - for (Properties::iterator it = filter.begin(); + for (auto it = filter.begin(); it != filter.end(); ++it) { if (*it == "PHOTO") { @@ -907,7 +907,7 @@ void PbapSession::continuePullAll(PullAll &state) void PbapSession::checkForError() { - Transfers::const_iterator it = m_transfers.find(m_currentTransfer); + auto it = m_transfers.find(m_currentTransfer); if (it != m_transfers.end()) { if (!it->second.m_transferErrorCode.empty()) { m_parent.throwError(SE_HERE, StringPrintf("%s: %s", @@ -920,7 +920,7 @@ void PbapSession::checkForError() Timespec PbapSession::transferComplete() const { Timespec res; - Transfers::const_iterator it = m_transfers.find(m_currentTransfer); + auto it = m_transfers.find(m_currentTransfer); if (it != m_transfers.end()) { res = it->second.m_transferComplete; } diff --git a/src/backends/qtcontacts/QtContactsSource.cpp b/src/backends/qtcontacts/QtContactsSource.cpp index 69f29942..f3210369 100644 --- a/src/backends/qtcontacts/QtContactsSource.cpp +++ b/src/backends/qtcontacts/QtContactsSource.cpp @@ -154,7 +154,7 @@ public: QStringList content; content << detail.definitionName(); // <detail> QVariantMap fields = detail.variantValues(); - for (QVariantMap::const_iterator entry = fields.begin(); + for (auto entry = fields.begin(); entry != fields.end(); ++entry) { const QString &fieldName = entry.key(); @@ -237,7 +237,7 @@ public: // detail name available? if (content.size() > 0) { const QString &detailName = content[0]; - QMap<QString, QContactDetailDefinition>::const_iterator it = m_details.constFind(detailName); + auto it = m_details.constFind(detailName); // detail still exists? if (it != m_details.constEnd()) { const QContactDetailDefinition &definition = *it; @@ -273,9 +273,8 @@ public: } // skip fields which are (no longer) valid, have wrong type or wrong value - QMap<QString, QContactDetailFieldDefinition> fields = definition.fields(); - QMap<QString, QContactDetailFieldDefinition>::const_iterator it2 = - fields.constFind(fieldName); + auto fields = definition.fields(); + auto it2 = fields.constFind(fieldName); if (it2 != fields.constEnd()) { if (it2->dataType() == value.type()) { QVariantList allowed = it2->allowableValues(); diff --git a/src/backends/tdepim/TDEPIMAddressBookSource.cpp b/src/backends/tdepim/TDEPIMAddressBookSource.cpp index df993166..6e33c30e 100644 --- a/src/backends/tdepim/TDEPIMAddressBookSource.cpp +++ b/src/backends/tdepim/TDEPIMAddressBookSource.cpp @@ -107,7 +107,7 @@ TQString TDEPIMAddressBookSource::lastModifiedNormalized(TDEABC::Addressee &e) // { // if ( m_categories.isEmpty() ) return true; // no filter defined -> match all // -// for (TQStringList::const_iterator it = list.begin(); it != list.end(); ++it ) { +// for (auto it = list.begin(); it != list.end(); ++it ) { // if ( m_categories.contains(*it) ) return true; // } // return false; // not found @@ -224,7 +224,7 @@ TrackingSyncSource::InsertItemResult TDEPIMAddressBookSource::insertItem(const s // not contain that category, add the filter-categories so that the address will be // found again on the next sync // if ( ! hasCategory(addressee.categories()) ) { -// for (TQStringList::const_iterator it = categories.begin(); it != categories.end(); ++it ) +// for (auto it = categories.begin(); it != categories.end(); ++it ) // addressee.insertCategory(*it); // } diff --git a/src/backends/webdav/CalDAVSource.cpp b/src/backends/webdav/CalDAVSource.cpp index fd9cbf0c..e6173c20 100644 --- a/src/backends/webdav/CalDAVSource.cpp +++ b/src/backends/webdav/CalDAVSource.cpp @@ -169,9 +169,9 @@ void CalDAVSource::updateAllSubItems(SubRevisionMap_t &revisions) } // remove obsolete entries - SubRevisionMap_t::iterator it = revisions.begin(); + auto it = revisions.begin(); while (it != revisions.end()) { - SubRevisionMap_t::iterator next = it; + auto next = it; ++next; if (items.find(it->first) == items.end()) { revisions.erase(it); @@ -185,7 +185,7 @@ void CalDAVSource::updateAllSubItems(SubRevisionMap_t &revisions) m_cache.m_initialized = false; std::list<std::string> mustRead; for (const StringPair &item: items) { - SubRevisionMap_t::iterator it = revisions.find(item.first); + auto it = revisions.find(item.first); if (it == revisions.end() || it->second.m_revision != item.second) { // read current information below @@ -479,7 +479,7 @@ SubSyncSource::SubItemResult CalDAVSource::insertSubItem(const std::string &luid std::string davLUID = luid; std::string knownSubID = callerSubID; if (davLUID.empty()) { - EventCache::iterator it = m_cache.findByUID(newEvent->m_UID); + auto it = m_cache.findByUID(newEvent->m_UID); if (it != m_cache.end()) { davLUID = it->first; knownSubID = subid; @@ -519,7 +519,7 @@ SubSyncSource::SubItemResult CalDAVSource::insertSubItem(const std::string &luid subres.m_subid = subid; subres.m_revision = res.m_revision; - EventCache::iterator it = m_cache.find(res.m_luid); + auto it = m_cache.find(res.m_luid); if (it != m_cache.end()) { // merge into existing Event Event &event = loadItem(*it->second); @@ -837,7 +837,7 @@ void CalDAVSource::Event::unescapeRecurrenceID(std::string &data) std::string CalDAVSource::removeSubItem(const string &davLUID, const std::string &subid) { - EventCache::iterator it = m_cache.find(davLUID); + auto it = m_cache.find(davLUID); if (it == m_cache.end()) { // gone already throwError(SE_HERE, STATUS_NOT_FOUND, "deleting item: " + davLUID); @@ -947,7 +947,7 @@ std::string CalDAVSource::removeSubItem(const string &davLUID, const std::string void CalDAVSource::removeMergedItem(const std::string &davLUID) { - EventCache::iterator it = m_cache.find(davLUID); + auto it = m_cache.find(davLUID); if (it == m_cache.end()) { // gone already, no need to do anything SE_LOG_DEBUG(getDisplayName(), "%s: ignoring request to delete non-existent item", @@ -982,7 +982,7 @@ void CalDAVSource::removeMergedItem(const std::string &davLUID) void CalDAVSource::flushItem(const string &davLUID) { // TODO: currently we always flush immediately, so no need to send data here - EventCache::iterator it = m_cache.find(davLUID); + auto it = m_cache.find(davLUID); if (it != m_cache.end()) { it->second->m_calendar.set(nullptr); } @@ -990,7 +990,7 @@ void CalDAVSource::flushItem(const string &davLUID) std::string CalDAVSource::getSubDescription(const string &davLUID, const string &subid) { - EventCache::iterator it = m_cache.find(davLUID); + auto it = m_cache.find(davLUID); if (it == m_cache.end()) { // unknown item, return empty string for fallback return ""; @@ -1041,7 +1041,7 @@ std::string CalDAVSource::getDescription(const string &luid) CalDAVSource::Event &CalDAVSource::findItem(const std::string &davLUID) { - EventCache::iterator it = m_cache.find(davLUID); + auto it = m_cache.find(davLUID); if (it == m_cache.end()) { throwError(SE_HERE, STATUS_NOT_FOUND, "finding item: " + davLUID); } @@ -1393,7 +1393,7 @@ void CalDAVSource::restoreData(const SyncSource::Operations::ConstBackupInfo &ol bool CalDAVSource::typeMatches(const StringMap &props) const { - StringMap::const_iterator it = props.find("urn:ietf:params:xml:ns:caldav:supported-calendar-component-set"); + auto it = props.find("urn:ietf:params:xml:ns:caldav:supported-calendar-component-set"); if (it != props.end() && it->second.find("<urn:ietf:params:xml:ns:caldavcomp name='VEVENT'></urn:ietf:params:xml:ns:caldavcomp>") != std::string::npos) { return true; diff --git a/src/backends/webdav/CalDAVVxxSource.cpp b/src/backends/webdav/CalDAVVxxSource.cpp index 1a1f53c8..914c97dc 100644 --- a/src/backends/webdav/CalDAVVxxSource.cpp +++ b/src/backends/webdav/CalDAVVxxSource.cpp @@ -34,7 +34,7 @@ bool CalDAVVxxSource::typeMatches(const StringMap &props) const std::string davcomp = StringPrintf("<urn:ietf:params:xml:ns:caldavcomp name='%s'></urn:ietf:params:xml:ns:caldavcomp>", m_content.c_str()); - StringMap::const_iterator it = props.find("urn:ietf:params:xml:ns:caldav:supported-calendar-component-set"); + auto it = props.find("urn:ietf:params:xml:ns:caldav:supported-calendar-component-set"); if (it != props.end() && it->second.find(davcomp) != std::string::npos) { return true; diff --git a/src/backends/webdav/CardDAVSource.cpp b/src/backends/webdav/CardDAVSource.cpp index 18082809..0e6c1b42 100644 --- a/src/backends/webdav/CardDAVSource.cpp +++ b/src/backends/webdav/CardDAVSource.cpp @@ -53,7 +53,7 @@ std::string CardDAVSource::getDescription(const string &luid) void CardDAVSource::readItemInternal(const std::string &luid, std::string &item, bool raw) { if (m_cardDAVCache) { - CardDAVCache::const_iterator it = m_cardDAVCache->find(luid); + auto it = m_cardDAVCache->find(luid); if (it != m_cardDAVCache->end()) { const std::string *data = boost::get<const std::string>(&it->second); if (data) { @@ -113,7 +113,7 @@ std::shared_ptr<CardDAVCache> CardDAVSource::readBatch(const std::string &luid) const Items_t &items = getAllItems(); const Items_t &newItems = getNewItems(); const Items_t &updatedItems = getUpdatedItems(); - Items_t::const_iterator it = items.find(luid); + auto it = items.find(luid); // Always read the requested item, even if not found in item list. luids.push_back(&luid); @@ -223,7 +223,7 @@ std::shared_ptr<CardDAVCache> CardDAVSource::readBatch(const std::string &luid) (*cache)[luid] = result; bool found = false; - for (BatchLUIDs::iterator it = luids.begin(); + for (auto it = luids.begin(); it != luids.end(); ++it) { if (**it == luid) { @@ -314,7 +314,7 @@ void CardDAVSource::getReadAheadOrder(ReadAheadOrder &order, void CardDAVSource::invalidateCachedItem(const std::string &luid) { if (m_cardDAVCache) { - CardDAVCache::iterator it = m_cardDAVCache->find(luid); + auto it = m_cardDAVCache->find(luid); if (it != m_cardDAVCache->end()) { SE_LOG_DEBUG(getDisplayName(), "reading: remove contact %s from cache because of remove or update", luid.c_str()); // If we happen to read that contact (unlikely), it'll be @@ -329,7 +329,7 @@ void CardDAVSource::invalidateCachedItem(const std::string &luid) bool CardDAVSource::typeMatches(const StringMap &props) const { - StringMap::const_iterator it = props.find("DAV::resourcetype"); + auto it = props.find("DAV::resourcetype"); if (it != props.end()) { const std::string &type = it->second; // allow parameters (no closing bracket) diff --git a/src/backends/webdav/WebDAVSource.cpp b/src/backends/webdav/WebDAVSource.cpp index 29fe2b38..a6f5cc7f 100644 --- a/src/backends/webdav/WebDAVSource.cpp +++ b/src/backends/webdav/WebDAVSource.cpp @@ -1239,7 +1239,7 @@ bool WebDAVSource::findCollections(const std::function<bool (const std::string & } if (success) { - Props_t::iterator pathProps = davProps.find(candidate.m_uri.m_path); + auto pathProps = davProps.find(candidate.m_uri.m_path); if (pathProps == davProps.end()) { // No reply for requested path? Happens with Yahoo Calendar server, // which returns information about "/dav" when asked about "/". @@ -2378,7 +2378,7 @@ bool WebDAVSource::isLeafCollection(const StringMap &props) const { // CardDAV and CalDAV both promise to not contain anything // unrelated to them - StringMap::const_iterator it = props.find("DAV::resourcetype"); + auto it = props.find("DAV::resourcetype"); if (it != props.end()) { const std::string &type = it->second; // allow parameters (no closing bracket) diff --git a/src/backends/webdav/WebDAVSourceRegister.cpp b/src/backends/webdav/WebDAVSourceRegister.cpp index 29ffd890..1a80c852 100644 --- a/src/backends/webdav/WebDAVSourceRegister.cpp +++ b/src/backends/webdav/WebDAVSourceRegister.cpp @@ -265,7 +265,7 @@ public: }; config.m_createSourceA = config.m_createSourceB = create; - ConfigProps::const_iterator it = m_props.find(m_type + "/testcases"); + auto it = m_props.find(m_type + "/testcases"); if (it != m_props.end() || (it = m_props.find("testcases")) != m_props.end()) { config.m_testcases = it->second.c_str(); diff --git a/src/dbus/server/auto-sync-manager.cpp b/src/dbus/server/auto-sync-manager.cpp index 56595f8c..3f70b697 100644 --- a/src/dbus/server/auto-sync-manager.cpp +++ b/src/dbus/server/auto-sync-manager.cpp @@ -384,7 +384,7 @@ void AutoSyncManager::sessionStarted(const std::shared_ptr<Session> &session) { // Do we have a task for this config? std::string configName = session->getConfigName(); - PeerMap::iterator it = m_peerMap.find(configName); + auto it = m_peerMap.find(configName); if (it == m_peerMap.end()) { SE_LOG_DEBUG(NULL, "auto sync: ignore running sync %s without config", configName.c_str()); diff --git a/src/dbus/server/bluez-manager.cpp b/src/dbus/server/bluez-manager.cpp index 73debff4..49aefa49 100644 --- a/src/dbus/server/bluez-manager.cpp +++ b/src/dbus/server/bluez-manager.cpp @@ -277,7 +277,7 @@ bool BluezManager::getPnpInfoNamesFromValues(const std::string &vendorValue, std void BluezManager::BluezDevice::discoverServicesCb(const ServiceDict &serviceDict, const string &error) { - ServiceDict::const_iterator iter = serviceDict.begin(); + auto iter = serviceDict.begin(); if(iter != serviceDict.end()) { std::string serviceRecord = (*iter).second; @@ -325,7 +325,7 @@ void BluezManager::BluezDevice::getPropertiesCb(const PropDict &props, const str if(!error.empty()) { SE_LOG_DEBUG(NULL, "Error in calling GetProperties of Interface org.bluez.Device: %s", error.c_str()); } else { - PropDict::const_iterator it = props.find("Name"); + auto it = props.find("Name"); if(it != props.end()) { m_name = boost::get<string>(it->second); } @@ -334,7 +334,7 @@ void BluezManager::BluezDevice::getPropertiesCb(const PropDict &props, const str m_mac = boost::get<string>(it->second); } - PropDict::const_iterator uuids = props.find("UUIDs"); + auto uuids = props.find("UUIDs"); if(uuids != props.end()) { const std::vector<std::string> uuidVec = boost::get<std::vector<std::string> >(uuids->second); checkSyncService(uuidVec); diff --git a/src/dbus/server/client.cpp b/src/dbus/server/client.cpp index 534b2b0f..7a48fdc3 100644 --- a/src/dbus/server/client.cpp +++ b/src/dbus/server/client.cpp @@ -38,7 +38,7 @@ Client::~Client() void Client::detach(Resource *resource) { - for (Resources_t::iterator it = m_resources.begin(); + for (auto it = m_resources.begin(); it != m_resources.end(); ++it) { if (it->get() == resource) { diff --git a/src/dbus/server/client.h b/src/dbus/server/client.h index 32951aa2..2a8c1378 100644 --- a/src/dbus/server/client.h +++ b/src/dbus/server/client.h @@ -97,7 +97,7 @@ public: * it was referenced not at all or multiple times. */ void detachAll(Resource *resource) { - Resources_t::iterator it = m_resources.begin(); + auto it = m_resources.begin(); while (it != m_resources.end()) { if (it->get() == resource) { it = m_resources.erase(it); @@ -117,7 +117,7 @@ public: */ std::shared_ptr<Resource> findResource(Resource *resource) { - for (Resources_t::iterator it = m_resources.begin(); + for (auto it = m_resources.begin(); it != m_resources.end(); ++it) { if (it->get() == resource) { diff --git a/src/dbus/server/connection.cpp b/src/dbus/server/connection.cpp index 410e003b..af489faf 100644 --- a/src/dbus/server/connection.cpp +++ b/src/dbus/server/connection.cpp @@ -173,7 +173,7 @@ void Connection::process(const Caller_t &caller, } // for Bluetooth transports match against mac address. - StringMap::const_iterator id = m_peer.find("id"), + auto id = m_peer.find("id"), trans = m_peer.find("transport"); if (trans != m_peer.end() && id != m_peer.end()) { if (trans->second == "org.openobex.obexd") { diff --git a/src/dbus/server/dbus-sync.cpp b/src/dbus/server/dbus-sync.cpp index 0da5dd55..09280a8e 100644 --- a/src/dbus/server/dbus-sync.cpp +++ b/src/dbus/server/dbus-sync.cpp @@ -85,11 +85,11 @@ DBusSync::DBusSync(const SessionCommon::SyncParams ¶ms, setConfigFilter(false, "", filter); for (const std::string &source: getSyncSources()) { - SessionCommon::SourceFilters_t::const_iterator fit = params.m_sourceFilters.find(source); + auto fit = params.m_sourceFilters.find(source); filter = fit == params.m_sourceFilters.end() ? FilterConfigNode::ConfigFilter() : fit->second; - SessionCommon::SourceModes_t::const_iterator it = params.m_sourceModes.find(source); + auto it = params.m_sourceModes.find(source); if (it != params.m_sourceModes.end()) { filter["sync"] = it->second; } diff --git a/src/dbus/server/presence-status.cpp b/src/dbus/server/presence-status.cpp index 507f435e..274cced3 100644 --- a/src/dbus/server/presence-status.cpp +++ b/src/dbus/server/presence-status.cpp @@ -81,7 +81,7 @@ void PresenceStatus::checkPresence (const string &peer, string& status, std::vec } void PresenceStatus::updateConfigPeers (const std::string &peer, const ReadOperations::Config_t &config) { - ReadOperations::Config_t::const_iterator iter = config.find (""); + auto iter = config.find (""); if (iter != config.end()) { //As a simple approach, just reinitialize the whole STATUSMAP //it will cause later updatePresenceStatus resend all signals diff --git a/src/dbus/server/read-operations.cpp b/src/dbus/server/read-operations.cpp index 6c05a089..2e185b6b 100644 --- a/src/dbus/server/read-operations.cpp +++ b/src/dbus/server/read-operations.cpp @@ -54,7 +54,7 @@ void ReadOperations::getConfigs(bool getTemplates, std::vector<std::string> &con string templName = "Bluetooth_"; templName += peer->m_deviceId; templName += "_"; - std::map<std::string, int>::iterator it = numbers.find(peer->m_deviceId); + auto it = numbers.find(peer->m_deviceId); if(it == numbers.end()) { numbers.insert(std::make_pair(peer->m_deviceId, 1)); templName += "1"; diff --git a/src/dbus/server/server.cpp b/src/dbus/server/server.cpp index 788c92d0..0acec74f 100644 --- a/src/dbus/server/server.cpp +++ b/src/dbus/server/server.cpp @@ -122,7 +122,7 @@ public: void Server::clientGone(Client *c) { - for (Clients_t::iterator it = m_clients.begin(); + for (auto it = m_clients.begin(); it != m_clients.end(); ++it) { if (it->second.get() == c) { @@ -207,7 +207,7 @@ void Server::setNotifications(bool enabled, bool Server::notificationsEnabled() { - for (Clients_t::iterator it = m_clients.begin(); + for (auto it = m_clients.begin(); it != m_clients.end(); ++it) { if (!it->second->getNotificationsEnabled()) { @@ -570,7 +570,7 @@ void Server::run() */ std::shared_ptr<Client> Server::findClient(const Caller_t &ID) { - for (Clients_t::iterator it = m_clients.begin(); + for (auto it = m_clients.begin(); it != m_clients.end(); ++it) { if (it->second->m_ID == ID) { @@ -609,7 +609,7 @@ void Server::enqueue(const std::shared_ptr<Session> &session) { bool idle = isIdle(); - WorkQueue_t::iterator it = m_workQueue.end(); + auto it = m_workQueue.end(); while (it != m_workQueue.begin()) { --it; // skip over dead sessions, they will get cleaned up elsewhere @@ -630,7 +630,7 @@ void Server::enqueue(const std::shared_ptr<Session> &session) void Server::killSessionsAsync(const std::string &peerDeviceID, const SimpleResult &onResult) { - WorkQueue_t::iterator it = m_workQueue.begin(); + auto it = m_workQueue.begin(); while (it != m_workQueue.end()) { std::shared_ptr<Session> session = it->lock(); if (session && session->getPeerDeviceID() == peerDeviceID) { @@ -673,7 +673,7 @@ void Server::dequeue(Session *session) return; } - for (WorkQueue_t::iterator it = m_workQueue.begin(); + for (auto it = m_workQueue.begin(); it != m_workQueue.end(); ++it) { if (it->lock().get() == session) { @@ -858,7 +858,7 @@ void Server::passwordResponse(const InfoReq::InfoMap &response, return; } - InfoReq::InfoMap::const_iterator it = response.find("password"); + auto it = response.find("password"); if (it == response.end()) { // no password provided, user wants to abort session->passwordResponse(false, true, ""); @@ -894,7 +894,7 @@ void Server::infoResponse(const Caller_t &caller, const std::string &state, const std::map<string, string> &response) { - InfoReqMap::iterator it = m_infoReqMap.find(id); + auto it = m_infoReqMap.find(id); // if not found, ignore if (it != m_infoReqMap.end()) { const std::shared_ptr<InfoReq> infoReq = it->second.lock(); @@ -970,7 +970,7 @@ std::shared_ptr<SyncConfig::TemplateDescription> Server::getPeerTempl(const stri { std::string lower = peer; boost::to_lower(lower); - MatchedTemplates::iterator it = m_matchedTempls.find(lower); + auto it = m_matchedTempls.find(lower); if(it != m_matchedTempls.end()) { return it->second; } else { diff --git a/src/dbus/server/session.cpp b/src/dbus/server/session.cpp index 7fe6464e..6280cac5 100644 --- a/src/dbus/server/session.cpp +++ b/src/dbus/server/session.cpp @@ -283,7 +283,7 @@ void Session::setNamedConfig(const std::string &configName, for(it = sources.begin(); it != sources.end(); ++it) { string source = "source/"; source += *it; - ReadOperations::Config_t::const_iterator configIt = config.find(source); + auto configIt = config.find(source); if(configIt == config.end()) { /** if no config for this source, we remove it */ from->removeSyncSource(*it); @@ -600,7 +600,7 @@ void Session::getProgress(int32_t &progress, bool Session::getSyncSourceReport(const std::string &sourceName, SyncSourceReport &report) const { - SyncSourceReports::const_iterator it = m_syncSourceReports.find(sourceName); + auto it = m_syncSourceReports.find(sourceName); if (it != m_syncSourceReports.end()) { report = it->second; return true; @@ -1250,11 +1250,11 @@ void Session::sourceProgress(sysync::TProgressEventEnum type, // Helper will create new source entries by sending a // sysync::PEV_PREPARING with SYNC_NONE. Must fire progress // and status events for such new sources. - SourceProgresses_t::iterator pit = m_sourceProgress.find(sourceName); + auto pit = m_sourceProgress.find(sourceName); bool sourceProgressCreated = pit == m_sourceProgress.end(); SourceProgress &progress = sourceProgressCreated ? m_sourceProgress[sourceName] : pit->second; - SourceStatuses_t::iterator sit = m_sourceStatus.find(sourceName); + auto sit = m_sourceStatus.find(sourceName); bool sourceStatusCreated = sit == m_sourceStatus.end(); SourceStatus &status = sourceStatusCreated ? m_sourceStatus[sourceName] : sit->second; diff --git a/src/gdbusxx/gdbus-cxx-bridge.h b/src/gdbusxx/gdbus-cxx-bridge.h index af55edf6..81ad8eda 100644 --- a/src/gdbusxx/gdbus-cxx-bridge.h +++ b/src/gdbusxx/gdbus-cxx-bridge.h @@ -1762,7 +1762,7 @@ template<class K, class V, class C> struct dbus_traits< std::map<K, V, C> > : pu { g_variant_builder_open(&builder, G_VARIANT_TYPE(getType().c_str())); - for(typename host_type::const_iterator it = dict.begin(); + for(auto it = dict.begin(); it != dict.end(); ++it) { g_variant_builder_open(&builder, G_VARIANT_TYPE(getContainedType().c_str())); @@ -1818,7 +1818,7 @@ template<class C, class V> struct dbus_traits_collection : public dbus_traits_ba { g_variant_builder_open(&builder, G_VARIANT_TYPE(getType().c_str())); - for(typename host_type::const_iterator it = array.begin(); + for(auto it = array.begin(); it != array.end(); ++it) { dbus_traits<V>::append(builder, *it); diff --git a/src/syncevo/Cmdline.cpp b/src/syncevo/Cmdline.cpp index f7a7f602..e8a801b5 100644 --- a/src/syncevo/Cmdline.cpp +++ b/src/syncevo/Cmdline.cpp @@ -1198,7 +1198,7 @@ bool Cmdline::run() { for (const string &source: configuredSources) { std::shared_ptr<PersistentSyncSourceConfig> sourceConfig(to->getSyncSourceConfig(source)); string disable = ""; - set<string>::iterator entry = sources.find(source); + auto entry = sources.find(source); bool selected = entry != sources.end(); if (!m_sources.empty() && @@ -1279,7 +1279,7 @@ bool Cmdline::run() { if (selected) { // user absolutely wants it: enable even if off by default ConfigProps filter = m_props.createSourceFilter(m_server, source); - ConfigProps::const_iterator sync = filter.find("sync"); + auto sync = filter.find("sync"); syncMode = sync == filter.end() ? "two-way" : sync->second; } if (configureContext) { @@ -1503,7 +1503,7 @@ bool Cmdline::run() { total, (unsigned long)m_luids.size())); } } - list<string>::const_iterator luidit = m_luids.begin(); + auto luidit = m_luids.begin(); for (const auto &match: make_iterator_range(boost::make_split_iterator(content, finder))) { string luid; if (m_update) { diff --git a/src/syncevo/FileConfigTree.cpp b/src/syncevo/FileConfigTree.cpp index c4a7654d..989081c9 100644 --- a/src/syncevo/FileConfigTree.cpp +++ b/src/syncevo/FileConfigTree.cpp @@ -92,7 +92,7 @@ void FileConfigTree::remove(const std::string &path) void FileConfigTree::reset() { - for (NodeCache_t::iterator it = m_nodes.begin(); + for (auto it = m_nodes.begin(); it != m_nodes.end(); ++it) { if (it->second.use_count() > 1) { @@ -118,7 +118,7 @@ void FileConfigTree::clearNodes(const std::string &fullpath) * containers like list, vector could work! :( * Below is STL recommended usage. */ - NodeCache_t::iterator erased = it++; + auto erased = it++; if (erased->second.use_count() > 1) { // same check as in reset() SE_THROW(erased->second->getName() + @@ -163,7 +163,7 @@ std::shared_ptr<ConfigNode> FileConfigTree::open(const std::string &path, } std::string fullname = normalizePath(fullpath + "/" + filename); - NodeCache_t::iterator found = m_nodes.find(fullname); + auto found = m_nodes.find(fullname); if (found != m_nodes.end()) { return found->second; } else if(type != other && type != server) { @@ -178,7 +178,7 @@ std::shared_ptr<ConfigNode> FileConfigTree::open(const std::string &path, std::shared_ptr<ConfigNode> FileConfigTree::add(const std::string &path, const std::shared_ptr<ConfigNode> &node) { - NodeCache_t::iterator found = m_nodes.find(path); + auto found = m_nodes.find(path); if (found != m_nodes.end()) { return found->second; } else { diff --git a/src/syncevo/FilterConfigNode.cpp b/src/syncevo/FilterConfigNode.cpp index 814efbd7..cc4e996d 100644 --- a/src/syncevo/FilterConfigNode.cpp +++ b/src/syncevo/FilterConfigNode.cpp @@ -53,7 +53,7 @@ void FilterConfigNode::setFilter(const ConfigFilter &filter) InitStateString FilterConfigNode::readProperty(const std::string &property) const { - ConfigFilter::const_iterator it = m_filter.find(property); + auto it = m_filter.find(property); if (it != m_filter.end()) { return it->second; @@ -66,7 +66,7 @@ void FilterConfigNode::writeProperty(const std::string &property, const InitStateString &value, const std::string &comment) { - ConfigFilter::iterator it = m_filter.find(property); + auto it = m_filter.find(property); if (!m_node.get()) { Exception::throwError(SE_HERE, getName() + ": read-only, setting properties not allowed"); @@ -90,7 +90,7 @@ void FilterConfigNode::readProperties(ConfigProps &props) const void FilterConfigNode::removeProperty(const std::string &property) { - ConfigFilter::iterator it = m_filter.find(property); + auto it = m_filter.find(property); if (!m_node.get()) { Exception::throwError(SE_HERE, getName() + ": read-only, removing properties not allowed"); diff --git a/src/syncevo/GLibSupport.cpp b/src/syncevo/GLibSupport.cpp index a3fb20c4..c9cf5788 100644 --- a/src/syncevo/GLibSupport.cpp +++ b/src/syncevo/GLibSupport.cpp @@ -230,7 +230,7 @@ public: void PendingChecks::runChecks() { DynMutex::Guard guard = m_mutex.lock(); - Checks::iterator it = m_checks.begin(); + auto it = m_checks.begin(); bool removed = false; while (it != m_checks.end()) { bool cont; @@ -244,7 +244,7 @@ void PendingChecks::runChecks() if (!cont) { // Done with this check - Checks::iterator next = it; + auto next = it; ++next; m_checks.erase(it); it = next; diff --git a/src/syncevo/HashConfigNode.h b/src/syncevo/HashConfigNode.h index eb731ce0..3a3c30dd 100644 --- a/src/syncevo/HashConfigNode.h +++ b/src/syncevo/HashConfigNode.h @@ -33,7 +33,7 @@ class HashConfigNode : public ConfigNode { virtual void flush() {} virtual string readProperty(const string &property) const { - std::map<std::string, std::string>::const_iterator it = m_props.find(property); + auto it = m_props.find(property); if (it == m_props.end()) { return ""; } else { diff --git a/src/syncevo/IniConfigNode.cpp b/src/syncevo/IniConfigNode.cpp index 48590eef..85dde284 100644 --- a/src/syncevo/IniConfigNode.cpp +++ b/src/syncevo/IniConfigNode.cpp @@ -218,7 +218,7 @@ void IniFileConfigNode::removeProperty(const std::string &property) { std::string value; - std::list<std::string>::iterator it = m_lines.begin(); + auto it = m_lines.begin(); while (it != m_lines.end()) { const std::string &line = *it; bool isComment; diff --git a/src/syncevo/MapSyncSource.cpp b/src/syncevo/MapSyncSource.cpp index efebc9a1..4af5b6c8 100644 --- a/src/syncevo/MapSyncSource.cpp +++ b/src/syncevo/MapSyncSource.cpp @@ -143,7 +143,7 @@ void MapSyncSource::detectChanges(SyncSourceRevisions::ChangeMode mode) for (const auto &entry: newRevisions) { const std::string &mainid = entry.first; const SubRevisionEntry &ids = entry.second; - SubRevisionMap_t::iterator it = m_revisions.find(entry.first); + auto it = m_revisions.find(entry.first); if (it == m_revisions.end()) { // all sub-items are added for (const std::string &subid: ids.m_subids) { @@ -310,7 +310,7 @@ void MapSyncSource::deleteItem(const string &luid) { StringPair ids = splitLUID(luid); std::string rev = m_sub->removeSubItem(ids.first, ids.second); - SubRevisionMap_t::iterator it = m_revisions.find(ids.first); + auto it = m_revisions.find(ids.first); if (it != m_revisions.end()) { it->second.m_subids.erase(ids.second); if (it->second.m_subids.empty()) { diff --git a/src/syncevo/SyncConfig.cpp b/src/syncevo/SyncConfig.cpp index 1f576ba8..2a90d4fd 100644 --- a/src/syncevo/SyncConfig.cpp +++ b/src/syncevo/SyncConfig.cpp @@ -372,10 +372,10 @@ class ConfigCache template<class M> void purge(M &map) { - typename M::iterator it = map.begin(); + auto it = map.begin(); while (it != map.end()) { if (!it->second.lock()) { - typename M::iterator next = it; + auto next = it; ++next; map.erase(it); it = next; diff --git a/src/syncevo/SyncContext.cpp b/src/syncevo/SyncContext.cpp index bef4269e..1758c04e 100644 --- a/src/syncevo/SyncContext.cpp +++ b/src/syncevo/SyncContext.cpp @@ -553,7 +553,7 @@ public: } stringstream path; path << base.str(); - SeqMap_t::iterator it = dateTimes2Seq.find(path.str()); + auto it = dateTimes2Seq.find(path.str()); if (it != dateTimes2Seq.end()) { path << "-" << (char)('a' + it->second + 1); } @@ -853,7 +853,7 @@ public: if (stat(fullpath.c_str(), &buf)) { Exception::throwError(SE_HERE, fullpath, errno); } - set<ino_t>::iterator it = firstInodes.find(buf.st_ino); + auto it = firstInodes.find(buf.st_ino); if (it == firstInodes.end()) { // second dir has different file return true; @@ -2397,7 +2397,7 @@ string XMLFiles::get(Category category) string XMLFiles::get(const string &file) { string res; - StringMap::const_iterator entry = m_files[MAIN].find(file); + auto entry = m_files[MAIN].find(file); if (entry != m_files[MAIN].end()) { ReadFile(entry->second, res); } diff --git a/src/syncevo/SyncSource.cpp b/src/syncevo/SyncSource.cpp index 845bfe98..dd05f907 100644 --- a/src/syncevo/SyncSource.cpp +++ b/src/syncevo/SyncSource.cpp @@ -288,7 +288,7 @@ RegisterSyncSource::RegisterSyncSource(const string &shortDescr, SourceRegistry ®istry(SyncSource::getSourceRegistry()); // insert sorted by description to have deterministic ordering - for(SourceRegistry::iterator it = registry.begin(); + for(auto it = registry.begin(); it != registry.end(); ++it) { if ((*it)->m_shortDescr > shortDescr) { @@ -1035,7 +1035,7 @@ void ItemCache::reset() string ItemCache::getFilename(Hash_t hash) { - Map_t::const_iterator it = m_hash2counter.find(hash); + auto it = m_hash2counter.find(hash); if (it != m_hash2counter.end()) { stringstream dirname; dirname << m_dirname << "/" << it->second; @@ -1197,7 +1197,7 @@ void SyncSourceRevisions::restoreData(const SyncSource::Operations::ConstBackupI key.clear(); key << counter << "-rev"; string rev = oldBackup.m_node->readProperty(key.str()); - RevisionMap_t::iterator it = revisions.find(uid); + auto it = revisions.find(uid); report.incrementItemStat(report.ITEM_LOCAL, report.ITEM_ANY, report.ITEM_TOTAL); @@ -1593,7 +1593,7 @@ sysync::TSyError SyncSourceAdmin::insertMapItem(sysync::cMapID mID) mapid2entry(mID, key, value); #if 0 - StringMap::iterator it = m_mapping.find(key); + auto it = m_mapping.find(key); if (it != m_mapping.end()) { // error, exists already return sysync::DB_Forbidden; @@ -1612,7 +1612,7 @@ sysync::TSyError SyncSourceAdmin::updateMapItem(sysync::cMapID mID) string key, value; mapid2entry(mID, key, value); - ConfigProps::iterator it = m_mapping.find(key); + auto it = m_mapping.find(key); if (it == m_mapping.end()) { // error, does not exist return sysync::DB_Forbidden; @@ -1627,7 +1627,7 @@ sysync::TSyError SyncSourceAdmin::deleteMapItem(sysync::cMapID mID) string key, value; mapid2entry(mID, key, value); - ConfigProps::iterator it = m_mapping.find(key); + auto it = m_mapping.find(key); if (it == m_mapping.end()) { // error, does not exist return sysync::DB_Forbidden; diff --git a/src/syncevo/SyncSource.h b/src/syncevo/SyncSource.h index 0fa3cceb..9ee64a7d 100644 --- a/src/syncevo/SyncSource.h +++ b/src/syncevo/SyncSource.h @@ -895,7 +895,7 @@ template<typename C, typename A1, typename ...A> class OperationWrapperSwitch<bo OperationExecution exec; // Marking m_pending "volatile" didn't work, find() not defined for that. - typename Pending::iterator it = const_cast<Pending &>(m_pending).find(Converter::toKey(a1)); + auto it = const_cast<Pending &>(m_pending).find(Converter::toKey(a1)); bool continuing = it != m_pending.end(); res = continuing ? sysync::LOCERR_OK : m_pre(dynamic_cast<SyncSource &>(m_source), a1, args...); diff --git a/src/syncevo/lcs.h b/src/syncevo/lcs.h index 28e0b811..53f42990 100644 --- a/src/syncevo/lcs.h +++ b/src/syncevo/lcs.h @@ -227,7 +227,6 @@ void lcs(const T &a, const T &b, ITO out, A access) } // copy result (using intermediate list instead of recursive function call) - typedef std::list< std::pair<size_t, size_t> > indexlist; std::list< std::pair<size_t, size_t> > indices; size_t i = a.size(), j = b.size(); while (i > 0 && j > 0) { @@ -249,7 +248,7 @@ void lcs(const T &a, const T &b, ITO out, A access) } } - for (indexlist::iterator it = indices.begin(); + for (auto it = indices.begin(); it != indices.end(); it++) { *out++ = Entry<typename A::F>(it->first, it->second, access.entry_at(a, it->first - 1)); diff --git a/src/syncevo/util.cpp b/src/syncevo/util.cpp index 86f9a8be..99e8d0d1 100644 --- a/src/syncevo/util.cpp +++ b/src/syncevo/util.cpp @@ -889,7 +889,7 @@ std::vector<std::string> unescapeJoinedString (const std::string& src, char sep) if (!((s1.length() - ((pos == s1.npos) ? 0: pos-1)) &1 )) { s2=""; boost::trim (s1); - for (std::string::iterator i = s1.begin(); i != s1.end(); ++i) { + for (auto i = s1.begin(); i != s1.end(); ++i) { //unescape characters if (*i == '\\') { if(++i == s1.end()) { diff --git a/src/syncevo/util.h b/src/syncevo/util.h index d21ed1a1..28f69813 100644 --- a/src/syncevo/util.h +++ b/src/syncevo/util.h @@ -560,7 +560,7 @@ GetWithDef(const C &map, const typename C::key_type &key, const typename C::mapped_type &def = {}) { - typename C::const_iterator it = map.find(key); + auto it = map.find(key); if (it != map.end()) { return InitState<typename C::mapped_type>(it->second, true); } else { diff --git a/src/syncevolution.cpp b/src/syncevolution.cpp index 742b1e9c..5888009b 100644 --- a/src/syncevolution.cpp +++ b/src/syncevolution.cpp @@ -571,7 +571,7 @@ void RemoteDBusServer::attachSync() if (!error.empty()) { SE_LOG_DEBUG(NULL, "Server.GetVersions(): %s", error.c_str()); } else { - StringMap::const_iterator it = versions.find("version"); + auto it = versions.find("version"); if (it != versions.end() && it->second != VERSION) { SE_LOG_INFO(NULL, @@ -755,7 +755,7 @@ void RemoteDBusServer::updateSessions(const std::string &session, bool active) m_activeSessions.push_back(session); } else { //if inactive, remove it from active list - for(std::vector<std::string>::iterator it = m_activeSessions.begin(); + for(auto it = m_activeSessions.begin(); it != m_activeSessions.end(); ++it) { if(boost::equals(session, *it)) { m_activeSessions.erase(it); @@ -879,10 +879,10 @@ void RemoteSession::executeAsync(const std::vector<std::string> &args) void RemoteSession::setConfigName(const Config_t &config) { - Config_t::const_iterator it = config.find(""); + auto it = config.find(""); if(it != config.end()) { StringMap global = it->second; - StringMap::iterator git = global.find("configName"); + auto git = global.find("configName"); if(git != global.end()) { m_configName = git->second; } @@ -923,7 +923,7 @@ void RemoteSession::infoReq(const std::string &id, if (m_runSync && boost::iequals(session, getPath())) { //only handle password now if (boost::iequals("password", type)) { - std::map<std::string, std::shared_ptr<InfoReq> >::iterator it = m_infoReqs.find(id); + auto it = m_infoReqs.find(id); if (it != m_infoReqs.end()) { it->second->process(id, session, state, handler, type, params); } else { @@ -941,7 +941,7 @@ void RemoteSession::handleInfoReq(const std::string &type, const StringMap ¶ char buffer[256]; std::string descr; - StringMap::const_iterator it = params.find("description"); + auto it = params.find("description"); if (it != params.end()) { descr = it->second; } @@ -962,7 +962,7 @@ void RemoteSession::handleInfoReq(const std::string &type, const StringMap ¶ void RemoteSession::removeInfoReq(const std::string &id) { - std::map<std::string, std::shared_ptr<InfoReq> >::iterator it = m_infoReqs.find(id); + auto it = m_infoReqs.find(id); if (it != m_infoReqs.end()) { m_infoReqs.erase(it); } diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index ec03c69e..6206cff9 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -1047,7 +1047,7 @@ void LocalTests::updateManyItems(const CreateSource &createSource, int startInde } int lastIndex = firstIndex + (numItems >= 1 ? numItems : defNumItems()) - 1; std::string revstring = StringPrintf("REVISION #%d", revision); - std::list<std::string>::const_iterator it = luids.begin(); + auto it = luids.begin(); for (int i = 0; i < offset && it != luids.end(); i++, ++it) {} for (int item = firstIndex; item <= lastIndex && it != luids.end(); @@ -1066,7 +1066,7 @@ void LocalTests::removeManyItems(const CreateSource &createSource, int numItems, TestingSyncSourcePtr source; SOURCE_ASSERT_NO_FAILURE(source.get(), source.reset(createSourceA())); - std::list<std::string>::const_iterator it = luids.begin(); + auto it = luids.begin(); for (int i = 0; i < offset && it != luids.end(); i++, ++it) {} for (int item = 0; item < numItems && it != luids.end(); @@ -2794,7 +2794,7 @@ SyncTests::SyncTests(const std::string &name, ClientTest &cl, std::vector<int> s client(cl) { sourceArray = new int[sourceIndices.size() + 1]; int offset = 0; - for (std::vector<int>::iterator it = sourceIndices.begin(); + for (auto it = sourceIndices.begin(); it != sourceIndices.end(); ++it) { ClientTest::Config config; @@ -6344,7 +6344,7 @@ void SyncTests::doSync(const SyncOptions &options) std::string prefix; prefix.reserve(80); - for (std::list<std::string>::iterator it = logPrefixes.begin(); + for (auto it = logPrefixes.begin(); it != logPrefixes.end(); ++it) { prefix += "."; |