From 84573326f41dd09b914b8374548e7ee7c93d0439 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 28 Apr 2016 09:22:55 +0200 Subject: factor out Pkg/DepIterator prettyprinters into own header The old prettyprinters have only access to the struct they pretty print, which isn't enough usually as we want to know for a package also a bit of state information like which version is the candidate. We therefore need to pull the DepCache into context and hence use a temporary struct which is printed instead of the iterator itself. --- apt-pkg/prettyprinters.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 apt-pkg/prettyprinters.h (limited to 'apt-pkg/prettyprinters.h') diff --git a/apt-pkg/prettyprinters.h b/apt-pkg/prettyprinters.h new file mode 100644 index 000000000..4af0ecebd --- /dev/null +++ b/apt-pkg/prettyprinters.h @@ -0,0 +1,37 @@ +#ifndef APT_PRETTYPRINTERS_H +#define APT_PRETTYPRINTERS_H +#include +#include + +class pkgDepCache; + +namespace APT { + +/** helper to format PkgIterator for easier printing in debug messages. + * + * The actual text generated is subject to change without prior notice + * and should NOT be used as part of a general user interface. + */ +struct PrettyPkg +{ + pkgDepCache const * const DepCache; + pkgCache::PkgIterator const Pkg; + PrettyPkg(pkgDepCache const * const depcache, pkgCache::PkgIterator const &pkg) APT_NONNULL(2) : DepCache(depcache), Pkg(pkg) {} +}; +/** helper to format DepIterator for easier printing in debug messages. + * + * The actual text generated is subject to change without prior notice + * and should NOT be used as part of a general user interface. + */ +struct PrettyDep +{ + pkgDepCache const * const DepCache; + pkgCache::DepIterator const Dep; + PrettyDep(pkgDepCache const * const depcache, pkgCache::DepIterator const &dep) APT_NONNULL(2) : DepCache(depcache), Dep(dep) {} +}; + +} +std::ostream& operator<<(std::ostream& os, const APT::PrettyPkg& pp); +std::ostream& operator<<(std::ostream& os, const APT::PrettyDep& pd); + +#endif -- cgit v1.2.3