#include <string.h>
#include <unistd.h>
#include <stdio.h>
-#include <iostream>
+
+#include <array>
#include <limits>
#include <string>
using std::string;
// we could use pkgCache::DepType and ::Priority, but these would be localized strings…
-const char * const PrioMap[] = {0, "important", "required", "standard",
- "optional", "extra"};
-const char * const DepMap[] = {"", "Depends", "Pre-Depends", "Suggests",
- "Recommends" , "Conflicts", "Replaces",
- "Obsoletes", "Breaks", "Enhances"};
+constexpr char const * const PrioMap[] = {
+ nullptr, "important", "required", "standard",
+ "optional", "extra"
+};
+constexpr char const * const DepMap[] = {
+ nullptr, "Depends", "Pre-Depends", "Suggests",
+ "Recommends" , "Conflicts", "Replaces",
+ "Obsoletes", "Breaks", "Enhances"
+};
// WriteOkay - varaidic helper to easily Write to a FileFd /*{{{*/
static bool WriteOkay_fn(FileFd &) { return true; }
// WriteScenarioDependency /*{{{*/
static void WriteScenarioDependency( FILE* output, pkgCache::VerIterator const &Ver)
{
- std::string dependencies[pkgCache::Dep::Enhances + 1];
+ std::array<std::string, _count(DepMap)> dependencies;
bool orGroup = false;
for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep)
{
else
orGroup = false;
}
- for (int i = 1; i < pkgCache::Dep::Enhances + 1; ++i)
+ for (size_t i = 1; i < dependencies.size(); ++i)
if (dependencies[i].empty() == false)
fprintf(output, "%s: %s\n", DepMap[i], dependencies[i].c_str()+2);
string provides;
}
static bool WriteScenarioDependency(FileFd &output, pkgCache::VerIterator const &Ver)
{
- std::string dependencies[pkgCache::Dep::Enhances + 1];
+ std::array<std::string, _count(DepMap)> dependencies;
bool orGroup = false;
for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep)
{
orGroup = false;
}
bool Okay = output.Failed() == false;
- for (int i = 1; i < pkgCache::Dep::Enhances + 1; ++i)
+ for (size_t i = 1; i < dependencies.size(); ++i)
if (dependencies[i].empty() == false)
WriteOkay(Okay, output, "\n", DepMap[i], ": ", dependencies[i]);
string provides;
pkgCache::VerIterator const &Ver,
APT::PackageSet const &pkgset)
{
- std::string dependencies[pkgCache::Dep::Enhances + 1];
+ std::array<std::string, _count(DepMap)> dependencies;
bool orGroup = false;
for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep)
{
else
orGroup = false;
}
- for (int i = 1; i < pkgCache::Dep::Enhances + 1; ++i)
+ for (size_t i = 1; i < dependencies.size(); ++i)
if (dependencies[i].empty() == false)
fprintf(output, "%s: %s\n", DepMap[i], dependencies[i].c_str());
string provides;
pkgCache::VerIterator const &Ver,
APT::PackageSet const &pkgset)
{
- std::string dependencies[pkgCache::Dep::Enhances + 1];
+ std::array<std::string, _count(DepMap)> dependencies;
bool orGroup = false;
for (pkgCache::DepIterator Dep = Ver.DependsList(); Dep.end() == false; ++Dep)
{
orGroup = false;
}
bool Okay = output.Failed() == false;
- for (int i = 1; i < pkgCache::Dep::Enhances + 1; ++i)
+ for (size_t i = 1; i < dependencies.size(); ++i)
if (dependencies[i].empty() == false)
WriteOkay(Okay, output, "\n", DepMap[i], ": ", dependencies[i]);
string provides;