summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nicoletti <dantti12@gmail.com>2012-04-19 11:11:44 -0300
committerDaniel Nicoletti <dantti12@gmail.com>2012-04-19 11:11:44 -0300
commit9faddb39f59c04ce66aa09923e63b412b83e0d15 (patch)
treee7c64867fda02502f76b430079742b16b7ecacdc
parentadafa8447cd9b9326ee0e18a4561c056539fdd6c (diff)
aptcc: use const_iterators to avoid mistakes
-rw-r--r--backends/aptcc/apt-intf.cpp36
-rw-r--r--backends/aptcc/apt-intf.h10
-rw-r--r--backends/aptcc/apt-utils.cpp4
-rw-r--r--backends/aptcc/apt-utils.h2
4 files changed, 26 insertions, 26 deletions
diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index 4f22a88c0..88d93e1a3 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -305,11 +305,11 @@ bool AptIntf::matchPackage(const pkgCache::VerIterator &ver, PkBitfield filters)
return true;
}
-PkgList AptIntf::filterPackages(PkgList &packages, PkBitfield filters)
+PkgList AptIntf::filterPackages(const PkgList &packages, PkBitfield filters)
{
if (filters != 0) {
PkgList ret;
- for (PkgList::iterator i = packages.begin(); i != packages.end(); ++i) {
+ for (PkgList::const_iterator i = packages.begin(); i != packages.end(); ++i) {
if (matchPackage(*i, filters)) {
ret.push_back(*i);
}
@@ -355,7 +355,7 @@ void AptIntf::emitPackages(PkgList &output, PkBitfield filters, PkInfoEnum state
result_equality()),
output.end());
- for (PkgList::iterator it = output.begin(); it != output.end(); ++it) {
+ for (PkgList::const_iterator it = output.begin(); it != output.end(); ++it) {
if (m_cancel) {
break;
}
@@ -377,7 +377,7 @@ void AptIntf::emitRequireRestart(PkgList &output)
result_equality()),
output.end());
- for (PkgList::iterator it = output.begin(); it != output.end(); ++it) {
+ for (PkgList::const_iterator it = output.begin(); it != output.end(); ++it) {
gchar *package_id;
package_id = utilBuildPackageId(*it);
pk_backend_require_restart(m_backend, PK_RESTART_ENUM_SYSTEM, package_id);
@@ -396,7 +396,7 @@ void AptIntf::emitUpdates(PkgList &output, PkBitfield filters)
result_equality()),
output.end());
- for (PkgList::iterator i = output.begin(); i != output.end(); ++i) {
+ for (PkgList::const_iterator i = output.begin(); i != output.end(); ++i) {
if (m_cancel) {
break;
}
@@ -676,7 +676,7 @@ void AptIntf::emitDetails(PkgList &pkgs)
pkgs.erase(unique(pkgs.begin(), pkgs.end(), result_equality()),
pkgs.end());
- for (PkgList::iterator i = pkgs.begin(); i != pkgs.end(); ++i) {
+ for (PkgList::const_iterator i = pkgs.begin(); i != pkgs.end(); ++i) {
if (m_cancel) {
break;
}
@@ -916,9 +916,9 @@ void AptIntf::emitUpdateDetail(const pkgCache::VerIterator &candver)
g_free(package_id);
}
-void AptIntf::emitUpdateDetails(PkgList &pkgs)
+void AptIntf::emitUpdateDetails(const PkgList &pkgs)
{
- for (PkgList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
+ for (PkgList::const_iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
if (m_cancel) {
break;
}
@@ -975,7 +975,7 @@ void AptIntf::getRequires(PkgList &output,
if (parentVer.end() == false) {
PkgList deps;
getDepends(deps, parentVer, false);
- for (PkgList::iterator it = deps.begin(); it != deps.end(); ++it) {
+ for (PkgList::const_iterator it = deps.begin(); it != deps.end(); ++it) {
if (*it == ver) {
if (recursive) {
if (!contains(output, parentPkg)) {
@@ -1054,7 +1054,7 @@ PkgList AptIntf::getPackagesFromGroup(gchar **values)
section = section.substr(found + 1);
// Don't insert virtual packages instead add what it provides
- for (vector<PkGroupEnum>::iterator it = groups.begin();
+ for (vector<PkGroupEnum>::const_iterator it = groups.begin();
it != groups.end();
++it) {
if (*it == get_enum_group(section)) {
@@ -1194,7 +1194,7 @@ PkgList AptIntf::searchPackageFiles(gchar **values)
regfree(&re);
// Resolve the package names now
- for (vector<string>::iterator it = packages.begin();
+ for (vector<string>::const_iterator it = packages.begin();
it != packages.end(); ++it) {
if (m_cancel) {
break;
@@ -1275,7 +1275,7 @@ void AptIntf::providesMimeType(PkgList &output, gchar **values)
regfree(&re);
// resolve the package names
- for (vector<string>::iterator it = packages.begin();
+ for (vector<string>::const_iterator it = packages.begin();
it != packages.end(); ++it) {
if (m_cancel) {
break;
@@ -1631,7 +1631,7 @@ PkgList AptIntf::checkChangedPackages(AptCacheFile &cache, bool emitChanged)
void AptIntf::emitTransactionPackage(string name, PkInfoEnum state)
{
- for (PkgList::iterator it = m_pkgs.begin(); it != m_pkgs.end(); ++it) {
+ for (PkgList::const_iterator it = m_pkgs.begin(); it != m_pkgs.end(); ++it) {
if (it->ParentPkg().Name() == name) {
emitPackage(*it, state);
return;
@@ -2067,10 +2067,10 @@ void AptIntf::refreshCache()
ListUpdate(Stat, *m_cache.GetSourceList());
}
-bool AptIntf::markAutoInstalled(AptCacheFile &cache, PkgList &pkgs, bool flag)
+bool AptIntf::markAutoInstalled(AptCacheFile &cache, const PkgList &pkgs, bool flag)
{
bool ret;
- for(PkgList::iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
+ for(PkgList::const_iterator it = pkgs.begin(); it != pkgs.end(); ++it) {
if (m_cancel) {
break;
}
@@ -2263,7 +2263,7 @@ bool AptIntf::installFile(const gchar *path, bool simulate)
return true;
}
-bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, bool markAuto, bool fixBroken)
+bool AptIntf::runTransaction(const PkgList &install, const PkgList &remove, bool simulate, bool markAuto, bool fixBroken)
{
//cout << "runTransaction" << simulate << remove << endl;
bool withLock = !simulate; // Check to see if we are just simulating,
@@ -2307,7 +2307,7 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
// new scope for the ActionGroup
{
pkgDepCache::ActionGroup group(cache);
- for (PkgList::iterator it = install.begin(); it != install.end(); ++it) {
+ for (PkgList::const_iterator it = install.begin(); it != install.end(); ++it) {
if (m_cancel) {
break;
}
@@ -2326,7 +2326,7 @@ bool AptIntf::runTransaction(PkgList &install, PkgList &remove, bool simulate, b
markAutoInstalled(cache, install, markAuto);
}
- for (PkgList::iterator it = remove.begin(); it != remove.end(); ++it) {
+ for (PkgList::const_iterator it = remove.begin(); it != remove.end(); ++it) {
if (m_cancel) {
break;
}
diff --git a/backends/aptcc/apt-intf.h b/backends/aptcc/apt-intf.h
index 4d80840a2..0f906c047 100644
--- a/backends/aptcc/apt-intf.h
+++ b/backends/aptcc/apt-intf.h
@@ -85,7 +85,7 @@ public:
/**
* Marks the given packages as auto installed
*/
- bool markAutoInstalled(AptCacheFile &cache, PkgList &pkgs, bool flag);
+ bool markAutoInstalled(AptCacheFile &cache, const PkgList &pkgs, bool flag);
/**
* runs a transaction to install/remove/update packages
@@ -95,8 +95,8 @@ public:
* \p simulate should be true, in this case packages with
* what's going to happen will be emitted.
*/
- bool runTransaction(PkgList &install,
- PkgList &remove,
+ bool runTransaction(const PkgList &install,
+ const PkgList &remove,
bool simulate,
bool markAuto,
bool fixBroken);
@@ -168,7 +168,7 @@ public:
/**
* Returns the list of packages with the ones that passed the given filters
*/
- PkgList filterPackages(PkgList &packages, PkBitfield filters);
+ PkgList filterPackages(const PkgList &packages, PkBitfield filters);
/**
* Emits details of the given package
@@ -188,7 +188,7 @@ public:
/**
* Emits update datails for the given list
*/
- void emitUpdateDetails(PkgList &pkgs);
+ void emitUpdateDetails(const PkgList &pkgs);
/**
* Emits the files of a package
diff --git a/backends/aptcc/apt-utils.cpp b/backends/aptcc/apt-utils.cpp
index 3c5e252ab..c24734a5b 100644
--- a/backends/aptcc/apt-utils.cpp
+++ b/backends/aptcc/apt-utils.cpp
@@ -242,9 +242,9 @@ string getBugzillaUrls(const string &changelog)
return ret;
}
-bool contains(PkgList packages, const pkgCache::PkgIterator &pkg)
+bool contains(const PkgList packages, const pkgCache::PkgIterator &pkg)
{
- for (PkgList::iterator it = packages.begin(); it != packages.end(); ++it) {
+ for (PkgList::const_iterator it = packages.begin(); it != packages.end(); ++it) {
if (it->ParentPkg() == pkg) {
return true;
}
diff --git a/backends/aptcc/apt-utils.h b/backends/aptcc/apt-utils.h
index 1dd00c9c8..514737456 100644
--- a/backends/aptcc/apt-utils.h
+++ b/backends/aptcc/apt-utils.h
@@ -90,7 +90,7 @@ string getBugzillaUrls(const string &changelog);
/**
* Return if the given vector contain a package
*/
-bool contains(PkgList packages, const pkgCache::PkgIterator &pkg);
+bool contains(const PkgList &packages, const pkgCache::PkgIterator &pkg);
/**
* Return if the given string ends with the other