]> git.saurik.com Git - apt.git/blame - apt-pkg/prettyprinters.cc
factor out Pkg/DepIterator prettyprinters into own header
[apt.git] / apt-pkg / prettyprinters.cc
CommitLineData
84573326
DK
1// Description /*{{{*/
2/* ######################################################################
3
4 Provide pretty printers for pkgCache structs like PkgIterator
5
6 ##################################################################### */
7 /*}}}*/
8// Include Files /*{{{*/
9#include <config.h>
10
11#include <apt-pkg/depcache.h>
12#include <apt-pkg/prettyprinters.h>
13
14#include <ostream>
15#include <string>
16
17 /*}}}*/
18
19std::ostream& operator<<(std::ostream& os, const APT::PrettyPkg& pp) /*{{{*/
20{
21 if (pp.Pkg.end() == true)
22 return os << "invalid package";
23
24 std::string current = (pp.Pkg.CurVersion() == 0 ? "none" : pp.Pkg.CurVersion());
25 std::string candidate = (*pp.DepCache)[pp.Pkg].CandVersion;
26 std::string newest = (pp.Pkg.VersionList().end() ? "none" : pp.Pkg.VersionList().VerStr());
27
28 os << pp.Pkg.Name() << " [ " << pp.Pkg.Arch() << " ] < " << current;
29 if (current != candidate)
30 os << " -> " << candidate;
31 if ( newest != "none" && candidate != newest)
32 os << " | " << newest;
33 if (pp.Pkg->VersionList == 0)
34 os << " > ( none )";
35 else
36 os << " > ( " << (pp.Pkg.VersionList().Section()==0?"unknown":pp.Pkg.VersionList().Section()) << " )";
37 return os;
38}
39 /*}}}*/
40std::ostream& operator<<(std::ostream& os, const APT::PrettyDep& pd) /*{{{*/
41{
42 if (unlikely(pd.Dep.end() == true))
43 return os << "invalid dependency";
44
45 pkgCache::PkgIterator P = pd.Dep.ParentPkg();
46 pkgCache::PkgIterator T = pd.Dep.TargetPkg();
47
48 os << (P.end() ? "invalid pkg" : P.FullName(false)) << " " << pd.Dep.DepType()
49 << " on " << APT::PrettyPkg(pd.DepCache, T);
50
51 if (pd.Dep->Version != 0)
52 os << " (" << pd.Dep.CompType() << " " << pd.Dep.TargetVer() << ")";
53
54 return os;
55}
56 /*}}}*/