1 #ifndef APT_PRIVATE_CACHESET_H
2 #define APT_PRIVATE_CACHESET_H
4 #include <apt-pkg/cacheset.h>
5 #include <apt-pkg/macros.h>
7 #include <apt-private/private-output.h>
18 struct VersionSortDescriptionLocality
/*{{{*/
20 bool operator () (const pkgCache::VerIterator
&v_lhs
,
21 const pkgCache::VerIterator
&v_rhs
)
23 pkgCache::DescFile
const *A
= nullptr;
24 pkgCache::DescFile
const *B
= nullptr;
25 if (v_lhs
->DescriptionList
!= 0)
26 A
= v_lhs
.TranslatedDescription().FileList();
27 if (v_rhs
->DescriptionList
!= 0)
28 B
= v_rhs
.TranslatedDescription().FileList();
30 if (A
== nullptr && B
== nullptr)
39 if (A
->File
== B
->File
)
40 return A
->Offset
< B
->Offset
;
42 return A
->File
< B
->File
;
46 // sorted by locality which makes iterating much faster
47 typedef APT::VersionContainer
<
48 std::set
<pkgCache::VerIterator
,
49 VersionSortDescriptionLocality
> > LocalitySortedVersionSet
;
53 virtual bool operator () (const pkgCache::PkgIterator
&/*P*/) {
57 // FIXME: add default argument for OpProgress (or overloaded function)
58 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
59 APT::VersionContainerInterface
* const vci
,
61 OpProgress
* const progress
);
62 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
63 APT::VersionContainerInterface
* const vci
,
64 OpProgress
* const progress
);
67 // CacheSetHelper saving virtual packages /*{{{*/
68 class CacheSetHelperVirtuals
: public APT::CacheSetHelper
{
70 APT::PackageSet virtualPkgs
;
72 virtual pkgCache::VerIterator
canNotGetVersion(enum CacheSetHelper::VerSelector
const select
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
73 virtual void canNotFindVersion(enum CacheSetHelper::VerSelector
const select
, APT::VersionContainerInterface
* vci
, pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
74 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
76 CacheSetHelperVirtuals(bool const ShowErrors
= true, GlobalError::MsgType
const &ErrorType
= GlobalError::NOTICE
);
80 // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
81 class CacheSetHelperAPTGet
: public APT::CacheSetHelper
{
82 /** \brief stream message should be printed to */
84 /** \brief were things like Task or RegEx used to select packages? */
87 APT::PackageSet virtualPkgs
;
90 std::list
<std::pair
<pkgCache::VerIterator
, std::string
> > selectedByRelease
;
92 explicit CacheSetHelperAPTGet(std::ostream
&out
);
94 virtual void showTaskSelection(pkgCache::PkgIterator
const &Pkg
, std::string
const &pattern
) APT_OVERRIDE
;
95 virtual void showFnmatchSelection(pkgCache::PkgIterator
const &Pkg
, std::string
const &pattern
) APT_OVERRIDE
;
96 virtual void showRegExSelection(pkgCache::PkgIterator
const &Pkg
, std::string
const &pattern
) APT_OVERRIDE
;
97 virtual void showSelectedVersion(pkgCache::PkgIterator
const &/*Pkg*/, pkgCache::VerIterator
const Ver
,
98 std::string
const &ver
, bool const /*verIsRel*/) APT_OVERRIDE
;
99 bool showVirtualPackageErrors(pkgCacheFile
&Cache
);
101 virtual pkgCache::VerIterator
canNotFindCandidateVer(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
102 virtual pkgCache::VerIterator
canNotFindNewestVer(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
) APT_OVERRIDE
;
103 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
105 APT::VersionSet
tryVirtualPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
,
106 CacheSetHelper::VerSelector
const select
);
108 inline bool allPkgNamedExplicitly() const { return explicitlyNamed
; }