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 class PackageMatcher
{
20 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
) { return false; };
21 virtual bool operator() (pkgCache::GrpIterator
const &Grp
) { return false; };
22 virtual bool operator() (pkgCache::VerIterator
const &Ver
) { return false; };
24 virtual ~PackageMatcher() {};
27 // PackageNameMatchesRegEx /*{{{*/
28 class PackageNameMatchesRegEx
: public PackageMatcher
{
29 /** \brief dpointer placeholder (for later in case we need it) */
33 PackageNameMatchesRegEx(std::string
const &Pattern
);
34 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
35 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
36 virtual ~PackageNameMatchesRegEx();
39 // PackageNameMatchesFnmatch /*{{{*/
40 class PackageNameMatchesFnmatch
: public PackageMatcher
{
41 /** \brief dpointer placeholder (for later in case we need it) */
43 const std::string Pattern
;
45 PackageNameMatchesFnmatch(std::string
const &Pattern
)
46 : Pattern(Pattern
) {};
47 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
48 virtual bool operator() (pkgCache::GrpIterator
const &Grp
);
49 virtual ~PackageNameMatchesFnmatch() {};
52 // PackageArchitectureMatchesSpecification /*{{{*/
53 /** \class PackageArchitectureMatchesSpecification
54 \brief matching against architecture specification strings
56 The strings are of the format <kernel>-<cpu> where either component,
57 or the whole string, can be the wildcard "any" as defined in
58 debian-policy ยง11.1 "Architecture specification strings".
60 Examples: i386, mipsel, linux-any, any-amd64, any */
61 class PackageArchitectureMatchesSpecification
: public PackageMatcher
{
65 /** \brief dpointer placeholder (for later in case we need it) */
68 /** \brief matching against architecture specification strings
70 * @param pattern is the architecture specification string
71 * @param isPattern defines if the given \b pattern is a
72 * architecture specification pattern to match others against
73 * or if it is the fixed string and matched against patterns
75 PackageArchitectureMatchesSpecification(std::string
const &pattern
, bool const isPattern
= true);
76 bool operator() (char const * const &arch
);
77 virtual bool operator() (pkgCache::PkgIterator
const &Pkg
);
78 virtual bool operator() (pkgCache::VerIterator
const &Ver
);
79 virtual ~PackageArchitectureMatchesSpecification();