1 // -*- mode: cpp; mode: fold -*-
3 /** \file cachefilter.h
4 Collection of functor classes */
6 #ifndef APT_CACHEFILTER_H
7 #define APT_CACHEFILTER_H
8 // Include Files /*{{{*/
9 #include <apt-pkg/pkgcache.h>
16 namespace CacheFilter
{
18 #define PACKAGE_MATCHER_ABI_COMPAT 1
19 #ifdef PACKAGE_MATCHER_ABI_COMPAT
21 // PackageNameMatchesRegEx /*{{{*/
22 class PackageNameMatchesRegEx
{
23 /** \brief dpointer placeholder (for later in case we need it) */
27 PackageNameMatchesRegEx(std::string
const &Pattern
);
28 bool operator() (pkgCache::PkgIterator
const &Pkg
);
29 bool operator() (pkgCache::GrpIterator
const &Grp
);
30 ~PackageNameMatchesRegEx();
33 // PackageNameMatchesFnmatch /*{{{*/
34 class PackageNameMatchesFnmatch
{
35 /** \brief dpointer placeholder (for later in case we need it) */
37 const std::string Pattern
;
39 PackageNameMatchesFnmatch(std::string
const &Pattern
)
40 : Pattern(Pattern
) {};
41 bool operator() (pkgCache::PkgIterator
const &Pkg
);
42 bool operator() (pkgCache::GrpIterator
const &Grp
);
43 ~PackageNameMatchesFnmatch() {};
46 // PackageArchitectureMatchesSpecification /*{{{*/
47 /** \class PackageArchitectureMatchesSpecification
48 \brief matching against architecture specification strings
50 The strings are of the format <kernel>-<cpu> where either component,
51 or the whole string, can be the wildcard "any" as defined in
52 debian-policy §11.1 "Architecture specification strings".
54 Examples: i386, mipsel, linux-any, any-amd64, any */
55 class PackageArchitectureMatchesSpecification
{
59 /** \brief dpointer placeholder (for later in case we need it) */
62 /** \brief matching against architecture specification strings
64 * @param pattern is the architecture specification string
65 * @param isPattern defines if the given \b pattern is a
66 * architecture specification pattern to match others against
67 * or if it is the fixed string and matched against patterns
69 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
70 bool operator() (char const * const &arch
);
71 bool operator() (pkgCache::PkgIterator
const &Pkg
);
72 bool operator() (pkgCache::VerIterator
const &Ver
);
73 ~PackageArchitectureMatchesSpecification();
78 class PackageMatcher
{
80 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
) { return false; };
81 virtual bool operator() (pkgCache::GrpIterator
const &Grp
) { return false; };
82 virtual bool operator() (pkgCache::VerIterator
const &Ver
) { return false; };
84 virtual ~PackageMatcher() {};
87 // PackageNameMatchesRegEx /*{{{*/
88 class PackageNameMatchesRegEx
: public PackageMatcher
{
89 /** \brief dpointer placeholder (for later in case we need it) */
93 PackageNameMatchesRegEx(std::string
const &Pattern
);
94 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
95 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
96 virtual ~PackageNameMatchesRegEx();
99 // PackageNameMatchesFnmatch /*{{{*/
100 class PackageNameMatchesFnmatch
: public PackageMatcher
{
101 /** \brief dpointer placeholder (for later in case we need it) */
103 const std::string Pattern
;
105 PackageNameMatchesFnmatch(std::string
const &Pattern
)
106 : Pattern(Pattern
) {};
107 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
108 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
109 virtual ~PackageNameMatchesFnmatch() {};
112 // PackageArchitectureMatchesSpecification /*{{{*/
113 /** \class PackageArchitectureMatchesSpecification
114 \brief matching against architecture specification strings
116 The strings are of the format <kernel>-<cpu> where either component,
117 or the whole string, can be the wildcard "any" as defined in
118 debian-policy §11.1 "Architecture specification strings".
120 Examples: i386, mipsel, linux-any, any-amd64, any */
121 class PackageArchitectureMatchesSpecification
: public PackageMatcher
{
123 std::string complete
;
125 /** \brief dpointer placeholder (for later in case we need it) */
128 /** \brief matching against architecture specification strings
130 * @param pattern is the architecture specification string
131 * @param isPattern defines if the given \b pattern is a
132 * architecture specification pattern to match others against
133 * or if it is the fixed string and matched against patterns
135 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
136 bool operator() (char const * const &arch
);
137 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
138 virtual bool operator() (pkgCache::VerIterator
const &Ver
);
139 virtual ~PackageArchitectureMatchesSpecification();