summaryrefslogtreecommitdiff
path: root/apt-pkg/prettyprinters.cc
blob: a736cabf4ee157adf283f3b2a6f8a3eeca0f2e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Description								/*{{{*/
/* ######################################################################

   Provide pretty printers for pkgCache structs like PkgIterator

   ##################################################################### */
									/*}}}*/
// Include Files							/*{{{*/
#include <config.h>

#include <apt-pkg/depcache.h>
#include <apt-pkg/prettyprinters.h>

#include <ostream>
#include <string>

									/*}}}*/

std::ostream& operator<<(std::ostream& os, const APT::PrettyPkg& pp)	/*{{{*/
{
   if (pp.Pkg.end() == true)
      return os << "invalid package";

   std::string current = (pp.Pkg.CurVersion() == 0 ? "none" : pp.Pkg.CurVersion());
   std::string candidate = (*pp.DepCache)[pp.Pkg].CandVersion;
   std::string newest = (pp.Pkg.VersionList().end() ? "none" : pp.Pkg.VersionList().VerStr());

   os << pp.Pkg.Name() << " [ " << pp.Pkg.Arch() << " ] < " << current;
   if (current != candidate)
      os << " -> " << candidate;
   if ( newest != "none" && candidate != newest)
      os << " | " << newest;
   if (pp.Pkg->VersionList == 0)
      os << " > ( none )";
   else
      os << " > ( " << (pp.Pkg.VersionList().Section()==0?"unknown":pp.Pkg.VersionList().Section()) << " )";
   return os;
}
									/*}}}*/
std::ostream& operator<<(std::ostream& os, const APT::PrettyDep& pd)	/*{{{*/
{
   if (unlikely(pd.Dep.end() == true))
      return os << "invalid dependency";

   pkgCache::PkgIterator P = pd.Dep.ParentPkg();
   pkgCache::PkgIterator T = pd.Dep.TargetPkg();

   os << (P.end() ? "invalid pkg" : P.FullName(false)) << " " << pd.Dep.DepType()
	<< " on " << APT::PrettyPkg(pd.DepCache, T);

   if (pd.Dep->Version != 0)
      os << " (" << pd.Dep.CompType() << " " << pd.Dep.TargetVer() << ")";

   return os;
}
									/*}}}*/