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 class PackageMatcher
{
21 virtual bool operator() (pkgCache::PkgIterator
const &/*Pkg*/) {
23 virtual bool operator() (pkgCache::GrpIterator
const &/*Grp*/) {
25 virtual bool operator() (pkgCache::VerIterator
const &/*Ver*/) {
28 virtual ~PackageMatcher() {};
31 // PackageNameMatchesRegEx /*{{{*/
32 class PackageNameMatchesRegEx
: public PackageMatcher
{
33 /** \brief dpointer placeholder (for later in case we need it) */
37 PackageNameMatchesRegEx(std::string
const &Pattern
);
38 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
39 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
40 virtual ~PackageNameMatchesRegEx();
43 // PackageNameMatchesFnmatch /*{{{*/
44 class PackageNameMatchesFnmatch
: public PackageMatcher
{
45 /** \brief dpointer placeholder (for later in case we need it) */
47 const std::string Pattern
;
49 PackageNameMatchesFnmatch(std::string
const &Pattern
)
50 : Pattern(Pattern
) {};
51 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
52 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
53 virtual ~PackageNameMatchesFnmatch() {};
56 // PackageArchitectureMatchesSpecification /*{{{*/
57 /** \class PackageArchitectureMatchesSpecification
58 \brief matching against architecture specification strings
60 The strings are of the format <kernel>-<cpu> where either component,
61 or the whole string, can be the wildcard "any" as defined in
62 debian-policy ยง11.1 "Architecture specification strings".
64 Examples: i386, mipsel, linux-any, any-amd64, any */
65 class PackageArchitectureMatchesSpecification
: public PackageMatcher
{
69 /** \brief dpointer placeholder (for later in case we need it) */
72 /** \brief matching against architecture specification strings
74 * @param pattern is the architecture specification string
75 * @param isPattern defines if the given \b pattern is a
76 * architecture specification pattern to match others against
77 * or if it is the fixed string and matched against patterns
79 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
80 bool operator() (char const * const &arch
);
81 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
82 virtual bool operator() (pkgCache::VerIterator
const &Ver
);
83 virtual ~PackageArchitectureMatchesSpecification();