apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

private-output.h
Go to the documentation of this file.
1 #ifndef APT_PRIVATE_OUTPUT_H
2 #define APT_PRIVATE_OUTPUT_H
3 
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/macros.h>
6 #include <apt-pkg/pkgcache.h>
7 
8 #include <fstream>
9 #include <functional>
10 #include <iostream>
11 #include <string>
12 
13 // forward declaration
14 class pkgCacheFile;
15 class CacheFile;
16 class pkgDepCache;
17 class pkgRecords;
18 
19 
20 APT_PUBLIC extern std::ostream c0out;
21 APT_PUBLIC extern std::ostream c1out;
22 APT_PUBLIC extern std::ostream c2out;
23 APT_PUBLIC extern std::ofstream devnull;
24 APT_PUBLIC extern unsigned int ScreenWidth;
25 
26 APT_PUBLIC bool InitOutput(std::basic_streambuf<char> * const out = std::cout.rdbuf());
27 
29  pkgCache::VerIterator const &V, std::ostream &out,
30  std::string const &format);
31 
32 
33 // helper to describe global state
34 APT_PUBLIC void ShowBroken(std::ostream &out, CacheFile &Cache, bool const Now);
35 APT_PUBLIC void ShowBroken(std::ostream &out, pkgCacheFile &Cache, bool const Now);
36 
37 template<class Container, class PredicateC, class DisplayP, class DisplayV> bool ShowList(std::ostream &out, std::string const &Title,
38  Container const &cont,
39  PredicateC Predicate,
40  DisplayP PkgDisplay,
41  DisplayV VerboseDisplay)
42 {
43  size_t const ScreenWidth = (::ScreenWidth > 3) ? ::ScreenWidth - 3 : 0;
44  int ScreenUsed = 0;
45  bool const ShowVersions = _config->FindB("APT::Get::Show-Versions", false);
46  bool printedTitle = false;
47 
48  for (auto const &Pkg: cont)
49  {
50  if (Predicate(Pkg) == false)
51  continue;
52 
53  if (printedTitle == false)
54  {
55  out << Title;
56  printedTitle = true;
57  }
58 
59  if (ShowVersions == true)
60  {
61  out << std::endl << " " << PkgDisplay(Pkg);
62  std::string const verbose = VerboseDisplay(Pkg);
63  if (verbose.empty() == false)
64  out << " (" << verbose << ")";
65  }
66  else
67  {
68  std::string const PkgName = PkgDisplay(Pkg);
69  if (ScreenUsed == 0 || (ScreenUsed + PkgName.length()) >= ScreenWidth)
70  {
71  out << std::endl << " ";
72  ScreenUsed = 0;
73  }
74  else if (ScreenUsed != 0)
75  {
76  out << " ";
77  ++ScreenUsed;
78  }
79  out << PkgName;
80  ScreenUsed += PkgName.length();
81  }
82  }
83 
84  if (printedTitle == true)
85  {
86  out << std::endl;
87  return false;
88  }
89  return true;
90 }
91 
92 void ShowNew(std::ostream &out,CacheFile &Cache);
93 void ShowDel(std::ostream &out,CacheFile &Cache);
94 void ShowKept(std::ostream &out,CacheFile &Cache);
95 void ShowUpgraded(std::ostream &out,CacheFile &Cache);
96 bool ShowDowngraded(std::ostream &out,CacheFile &Cache);
97 bool ShowHold(std::ostream &out,CacheFile &Cache);
98 
99 bool ShowEssential(std::ostream &out,CacheFile &Cache);
100 
101 void Stats(std::ostream &out, pkgDepCache &Dep);
102 
103 // prompting
104 APT_PUBLIC bool YnPrompt(char const *const Question, bool Default = true);
105 bool YnPrompt(char const * const Question, bool const Default, bool const ShowGlobalErrors, std::ostream &c1o, std::ostream &c2o);
106 bool AnalPrompt(std::string const &Question, const char *Text);
107 
108 APT_PUBLIC std::string PrettyFullName(pkgCache::PkgIterator const &Pkg);
109 std::string CandidateVersion(pkgCacheFile * const Cache, pkgCache::PkgIterator const &Pkg);
110 std::function<std::string(pkgCache::PkgIterator const &)> CandidateVersion(pkgCacheFile * const Cache);
111 std::string CurrentToCandidateVersion(pkgCacheFile * const Cache, pkgCache::PkgIterator const &Pkg);
112 std::function<std::string(pkgCache::PkgIterator const &)> CurrentToCandidateVersion(pkgCacheFile * const Cache);
113 std::string EmptyString(pkgCache::PkgIterator const &);
114 bool AlwaysTrue(pkgCache::PkgIterator const &);
115 
116 #endif
bool FindB(const char *Name, bool const &Default=false) const
pkgCache & Cache
Definition: pkgrecords.h:35
Configuration * _config
#define APT_PUBLIC
Definition: macros.h:77
pkgCache - Structure definitions for the cache file
APT_PUBLIC std::string PrettyFullName(pkgCache::PkgIterator const &Pkg)
void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, pkgCache::VerIterator const &V, std::ostream &out, std::string const &format)
bool ShowHold(std::ostream &out, CacheFile &Cache)
APT_PUBLIC std::ostream c1out
void ShowUpgraded(std::ostream &out, CacheFile &Cache)
APT_PUBLIC std::ostream c0out
APT_PUBLIC bool YnPrompt(char const *const Question, bool Default=true)
void ShowNew(std::ostream &out, CacheFile &Cache)
void Stats(std::ostream &out, pkgDepCache &Dep)
bool ShowList(std::ostream &out, std::string const &Title, Container const &cont, PredicateC Predicate, DisplayP PkgDisplay, DisplayV VerboseDisplay)
bool AlwaysTrue(pkgCache::PkgIterator const &)
bool ShowDowngraded(std::ostream &out, CacheFile &Cache)
APT_PUBLIC unsigned int ScreenWidth
std::string CurrentToCandidateVersion(pkgCacheFile *const Cache, pkgCache::PkgIterator const &Pkg)
std::string CandidateVersion(pkgCacheFile *const Cache, pkgCache::PkgIterator const &Pkg)
bool AnalPrompt(std::string const &Question, const char *Text)
APT_PUBLIC std::ostream c2out
void ShowDel(std::ostream &out, CacheFile &Cache)
APT_PUBLIC bool InitOutput(std::basic_streambuf< char > *const out=std::cout.rdbuf())
void ShowKept(std::ostream &out, CacheFile &Cache)
std::string EmptyString(pkgCache::PkgIterator const &)
bool ShowEssential(std::ostream &out, CacheFile &Cache)
APT_PUBLIC std::ofstream devnull
APT_PUBLIC void ShowBroken(std::ostream &out, CacheFile &Cache, bool const Now)