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>
10 #include <apt-pkg/cacheiterators.h>
17 namespace CacheFilter
{
19 #define PACKAGE_MATCHER_ABI_COMPAT 1
20 #ifdef PACKAGE_MATCHER_ABI_COMPAT
22 // PackageNameMatchesRegEx /*{{{*/
23 class PackageNameMatchesRegEx
{
24 /** \brief dpointer placeholder (for later in case we need it) */
28 PackageNameMatchesRegEx(std::string
const &Pattern
);
29 bool operator() (pkgCache::PkgIterator
const &Pkg
);
30 bool operator() (pkgCache::GrpIterator
const &Grp
);
31 ~PackageNameMatchesRegEx();
34 // PackageNameMatchesFnmatch /*{{{*/
35 class PackageNameMatchesFnmatch
{
36 /** \brief dpointer placeholder (for later in case we need it) */
38 const std::string Pattern
;
40 PackageNameMatchesFnmatch(std::string
const &Pattern
)
41 : Pattern(Pattern
) {};
42 bool operator() (pkgCache::PkgIterator
const &Pkg
);
43 bool operator() (pkgCache::GrpIterator
const &Grp
);
44 ~PackageNameMatchesFnmatch() {};
47 // PackageArchitectureMatchesSpecification /*{{{*/
48 /** \class PackageArchitectureMatchesSpecification
49 \brief matching against architecture specification strings
51 The strings are of the format \<kernel\>-\<cpu\> where either component,
52 or the whole string, can be the wildcard "any" as defined in
53 debian-policy §11.1 "Architecture specification strings".
55 Examples: i386, mipsel, linux-any, any-amd64, any */
56 class PackageArchitectureMatchesSpecification
{
60 /** \brief dpointer placeholder (for later in case we need it) */
63 /** \brief matching against architecture specification strings
65 * @param pattern is the architecture specification string
66 * @param isPattern defines if the given \b pattern is a
67 * architecture specification pattern to match others against
68 * or if it is the fixed string and matched against patterns
70 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
71 bool operator() (char const * const &arch
);
72 bool operator() (pkgCache::PkgIterator
const &Pkg
);
73 bool operator() (pkgCache::VerIterator
const &Ver
);
74 ~PackageArchitectureMatchesSpecification();
79 class PackageMatcher
{
81 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
) { return false; };
82 virtual bool operator() (pkgCache::GrpIterator
const &Grp
) { return false; };
83 virtual bool operator() (pkgCache::VerIterator
const &Ver
) { return false; };
85 virtual ~PackageMatcher() {};
88 // PackageNameMatchesRegEx /*{{{*/
89 class PackageNameMatchesRegEx
: public PackageMatcher
{
90 /** \brief dpointer placeholder (for later in case we need it) */
94 PackageNameMatchesRegEx(std::string
const &Pattern
);
95 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
96 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
97 virtual ~PackageNameMatchesRegEx();
100 // PackageNameMatchesFnmatch /*{{{*/
101 class PackageNameMatchesFnmatch
: public PackageMatcher
{
102 /** \brief dpointer placeholder (for later in case we need it) */
104 const std::string Pattern
;
106 PackageNameMatchesFnmatch(std::string
const &Pattern
)
107 : Pattern(Pattern
) {};
108 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
109 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
110 virtual ~PackageNameMatchesFnmatch() {};
113 // PackageArchitectureMatchesSpecification /*{{{*/
114 /** \class PackageArchitectureMatchesSpecification
115 \brief matching against architecture specification strings
117 The strings are of the format <kernel>-<cpu> where either component,
118 or the whole string, can be the wildcard "any" as defined in
119 debian-policy §11.1 "Architecture specification strings".
121 Examples: i386, mipsel, linux-any, any-amd64, any */
122 class PackageArchitectureMatchesSpecification
: public PackageMatcher
{
124 std::string complete
;
126 /** \brief dpointer placeholder (for later in case we need it) */
129 /** \brief matching against architecture specification strings
131 * @param pattern is the architecture specification string
132 * @param isPattern defines if the given \b pattern is a
133 * architecture specification pattern to match others against
134 * or if it is the fixed string and matched against patterns
136 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
137 bool operator() (char const * const &arch
);
138 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
139 virtual bool operator() (pkgCache::VerIterator
const &Ver
);
140 virtual ~PackageArchitectureMatchesSpecification();