]> git.saurik.com Git - apt.git/blame - apt-pkg/cachefilter.h
calculate only expected hashes in methods
[apt.git] / apt-pkg / cachefilter.h
CommitLineData
9ba5aa3b
DK
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/** \file cachefilter.h
4 Collection of functor classes */
5 /*}}}*/
6#ifndef APT_CACHEFILTER_H
7#define APT_CACHEFILTER_H
8// Include Files /*{{{*/
9#include <apt-pkg/pkgcache.h>
453b82a3 10#include <apt-pkg/cacheiterators.h>
9ba5aa3b
DK
11
12#include <string>
3721cb01 13#include <vector>
9ba5aa3b
DK
14
15#include <regex.h>
3721cb01
DK
16
17class pkgCacheFile;
9ba5aa3b
DK
18 /*}}}*/
19namespace APT {
20namespace CacheFilter {
b9179170 21
3721cb01
DK
22class Matcher {
23public:
24 virtual bool operator() (pkgCache::PkgIterator const &/*Pkg*/) = 0;
25 virtual bool operator() (pkgCache::GrpIterator const &/*Grp*/) = 0;
26 virtual bool operator() (pkgCache::VerIterator const &/*Ver*/) = 0;
27 virtual ~Matcher();
b9179170
MV
28};
29
3721cb01
DK
30class PackageMatcher : public Matcher {
31public:
32 virtual bool operator() (pkgCache::PkgIterator const &Pkg) = 0;
33 virtual bool operator() (pkgCache::VerIterator const &Ver) { return (*this)(Ver.ParentPkg()); }
34 virtual bool operator() (pkgCache::GrpIterator const &/*Grp*/) { return false; }
35 virtual ~PackageMatcher();
36};
37
38// Generica like True, False, NOT, AND, OR /*{{{*/
39class TrueMatcher : public Matcher {
40public:
41 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
42 virtual bool operator() (pkgCache::GrpIterator const &Grp);
43 virtual bool operator() (pkgCache::VerIterator const &Ver);
44};
45
46class FalseMatcher : public Matcher {
47public:
48 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
49 virtual bool operator() (pkgCache::GrpIterator const &Grp);
50 virtual bool operator() (pkgCache::VerIterator const &Ver);
51};
52
53class NOTMatcher : public Matcher {
54 Matcher * const matcher;
55public:
56 NOTMatcher(Matcher * const matcher);
57 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
58 virtual bool operator() (pkgCache::GrpIterator const &Grp);
59 virtual bool operator() (pkgCache::VerIterator const &Ver);
60 virtual ~NOTMatcher();
61};
62
63class ANDMatcher : public Matcher {
64 std::vector<Matcher *> matchers;
65public:
66 // 5 ought to be enough for everybody… c++11 variadic templates would be nice
67 ANDMatcher();
68 ANDMatcher(Matcher * const matcher1);
69 ANDMatcher(Matcher * const matcher1, Matcher * const matcher2);
70 ANDMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3);
71 ANDMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4);
72 ANDMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4, Matcher * const matcher5);
73 ANDMatcher& AND(Matcher * const matcher);
74 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
75 virtual bool operator() (pkgCache::GrpIterator const &Grp);
76 virtual bool operator() (pkgCache::VerIterator const &Ver);
77 virtual ~ANDMatcher();
78};
79class ORMatcher : public Matcher {
80 std::vector<Matcher *> matchers;
81public:
82 // 5 ought to be enough for everybody… c++11 variadic templates would be nice
83 ORMatcher();
84 ORMatcher(Matcher * const matcher1);
85 ORMatcher(Matcher * const matcher1, Matcher * const matcher2);
86 ORMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3);
87 ORMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4);
88 ORMatcher(Matcher * const matcher1, Matcher * const matcher2, Matcher * const matcher3, Matcher * const matcher4, Matcher * const matcher5);
89 ORMatcher& OR(Matcher * const matcher);
90 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
91 virtual bool operator() (pkgCache::GrpIterator const &Grp);
92 virtual bool operator() (pkgCache::VerIterator const &Ver);
93 virtual ~ORMatcher();
94};
95 /*}}}*/
96class PackageNameMatchesRegEx : public PackageMatcher { /*{{{*/
9ba5aa3b
DK
97 regex_t* pattern;
98public:
99 PackageNameMatchesRegEx(std::string const &Pattern);
b9179170
MV
100 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
101 virtual bool operator() (pkgCache::GrpIterator const &Grp);
314a3f88 102 virtual ~PackageNameMatchesRegEx();
9ba5aa3b
DK
103};
104 /*}}}*/
3721cb01
DK
105class PackageNameMatchesFnmatch : public PackageMatcher { /*{{{*/
106 const std::string Pattern;
b9179170 107public:
3721cb01
DK
108 PackageNameMatchesFnmatch(std::string const &Pattern);
109 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
b9179170 110 virtual bool operator() (pkgCache::GrpIterator const &Grp);
314a3f88 111 virtual ~PackageNameMatchesFnmatch() {};
b9179170
MV
112};
113 /*}}}*/
3721cb01 114class PackageArchitectureMatchesSpecification : public PackageMatcher { /*{{{*/
424ff669
DK
115/** \class PackageArchitectureMatchesSpecification
116 \brief matching against architecture specification strings
117
118 The strings are of the format <kernel>-<cpu> where either component,
119 or the whole string, can be the wildcard "any" as defined in
120 debian-policy §11.1 "Architecture specification strings".
121
122 Examples: i386, mipsel, linux-any, any-amd64, any */
424ff669
DK
123 std::string literal;
124 std::string complete;
125 bool isPattern;
424ff669
DK
126public:
127 /** \brief matching against architecture specification strings
128 *
129 * @param pattern is the architecture specification string
130 * @param isPattern defines if the given \b pattern is a
131 * architecture specification pattern to match others against
132 * or if it is the fixed string and matched against patterns
133 */
134 PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
135 bool operator() (char const * const &arch);
b9179170 136 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
314a3f88 137 virtual ~PackageArchitectureMatchesSpecification();
424ff669
DK
138};
139 /*}}}*/
3721cb01
DK
140class PackageIsNewInstall : public PackageMatcher { /*{{{*/
141 pkgCacheFile * const Cache;
142public:
143 PackageIsNewInstall(pkgCacheFile * const Cache);
144 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
145 virtual ~PackageIsNewInstall();
146};
147 /*}}}*/
148
9ba5aa3b
DK
149}
150}
151#endif