]> git.saurik.com Git - apt.git/blame - apt-private/private-output.h
releasing package apt version 1.1~exp16
[apt.git] / apt-private / private-output.h
CommitLineData
b9179170
MV
1#ifndef APT_PRIVATE_OUTPUT_H
2#define APT_PRIVATE_OUTPUT_H
3
a0c19a21 4#include <apt-pkg/configuration.h>
453b82a3 5#include <apt-pkg/pkgcache.h>
63ff4208 6#include <apt-pkg/macros.h>
b9179170 7
a0c19a21 8#include <functional>
b9179170
MV
9#include <fstream>
10#include <string>
d9e518c6 11#include <iostream>
b9179170 12
b9179170
MV
13// forward declaration
14class pkgCacheFile;
15class CacheFile;
b9179170
MV
16class pkgDepCache;
17class pkgRecords;
18
19
63ff4208
DK
20APT_PUBLIC extern std::ostream c0out;
21APT_PUBLIC extern std::ostream c1out;
22APT_PUBLIC extern std::ostream c2out;
23APT_PUBLIC extern std::ofstream devnull;
24APT_PUBLIC extern unsigned int ScreenWidth;
b9179170 25
d9e518c6 26APT_PUBLIC bool InitOutput(std::basic_streambuf<char> * const out = std::cout.rdbuf());
63ff4208
DK
27
28void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
1a68655d
DK
29 pkgCache::VerIterator const &V, std::ostream &out,
30 std::string const &format);
b9179170
MV
31
32
0c8b6001 33// helper to describe global state
d39d7f88
DK
34APT_PUBLIC void ShowBroken(std::ostream &out, CacheFile &Cache, bool const Now);
35APT_PUBLIC void ShowBroken(std::ostream &out, pkgCacheFile &Cache, bool const Now);
63ff4208 36
9112f777 37template<class Container, class PredicateC, class DisplayP, class DisplayV> APT_PUBLIC bool ShowList(std::ostream &out, std::string const &Title,
a0c19a21 38 Container const &cont,
9112f777
DK
39 PredicateC Predicate,
40 DisplayP PkgDisplay,
41 DisplayV VerboseDisplay)
a0c19a21
DK
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}
a0c19a21 91
b9179170
MV
92void ShowNew(std::ostream &out,CacheFile &Cache);
93void ShowDel(std::ostream &out,CacheFile &Cache);
94void ShowKept(std::ostream &out,CacheFile &Cache);
95void ShowUpgraded(std::ostream &out,CacheFile &Cache);
96bool ShowDowngraded(std::ostream &out,CacheFile &Cache);
97bool ShowHold(std::ostream &out,CacheFile &Cache);
98
99bool ShowEssential(std::ostream &out,CacheFile &Cache);
100
101void Stats(std::ostream &out, pkgDepCache &Dep);
102
103// prompting
104bool YnPrompt(bool Default=true);
105bool AnalPrompt(const char *Text);
106
9112f777
DK
107std::string PrettyFullName(pkgCache::PkgIterator const &Pkg);
108std::string CandidateVersion(pkgCacheFile * const Cache, pkgCache::PkgIterator const &Pkg);
109std::function<std::string(pkgCache::PkgIterator const &)> CandidateVersion(pkgCacheFile * const Cache);
110std::string CurrentToCandidateVersion(pkgCacheFile * const Cache, pkgCache::PkgIterator const &Pkg);
111std::function<std::string(pkgCache::PkgIterator const &)> CurrentToCandidateVersion(pkgCacheFile * const Cache);
112std::string EmptyString(pkgCache::PkgIterator const &);
113bool AlwaysTrue(pkgCache::PkgIterator const &);
a0c19a21 114
b9179170 115#endif