]> git.saurik.com Git - apt.git/blame - apt-pkg/cachefilter.h
edsp: use an ID mapping for the internal solver
[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:
6d7122b5 32 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE = 0;
3b302846
DK
33 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE { return (*this)(Ver.ParentPkg()); }
34 virtual bool operator() (pkgCache::GrpIterator const &/*Grp*/) APT_OVERRIDE { return false; }
3721cb01
DK
35 virtual ~PackageMatcher();
36};
37
38// Generica like True, False, NOT, AND, OR /*{{{*/
39class TrueMatcher : public Matcher {
40public:
3b302846
DK
41 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
42 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
43 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE;
3721cb01
DK
44};
45
46class FalseMatcher : public Matcher {
47public:
3b302846
DK
48 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
49 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
50 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE;
3721cb01
DK
51};
52
53class NOTMatcher : public Matcher {
54 Matcher * const matcher;
55public:
e8afd168 56 explicit NOTMatcher(Matcher * const matcher);
3b302846
DK
57 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
58 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
59 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE;
3721cb01
DK
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();
e8afd168 68 explicit ANDMatcher(Matcher * const matcher1);
3721cb01
DK
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);
3b302846
DK
74 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
75 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
76 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE;
3721cb01
DK
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();
e8afd168 84 explicit ORMatcher(Matcher * const matcher1);
3721cb01
DK
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);
3b302846
DK
90 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
91 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
92 virtual bool operator() (pkgCache::VerIterator const &Ver) APT_OVERRIDE;
3721cb01
DK
93 virtual ~ORMatcher();
94};
95 /*}}}*/
96class PackageNameMatchesRegEx : public PackageMatcher { /*{{{*/
9ba5aa3b
DK
97 regex_t* pattern;
98public:
e8afd168 99 explicit PackageNameMatchesRegEx(std::string const &Pattern);
3b302846
DK
100 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
101 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
314a3f88 102 virtual ~PackageNameMatchesRegEx();
9ba5aa3b
DK
103};
104 /*}}}*/
3721cb01
DK
105class PackageNameMatchesFnmatch : public PackageMatcher { /*{{{*/
106 const std::string Pattern;
b9179170 107public:
e8afd168 108 explicit PackageNameMatchesFnmatch(std::string const &Pattern);
3b302846
DK
109 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
110 virtual bool operator() (pkgCache::GrpIterator const &Grp) APT_OVERRIDE;
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
5025879e 118 The strings are of the format <libc>-<kernel>-<cpu> where either component,
424ff669
DK
119 or the whole string, can be the wildcard "any" as defined in
120 debian-policy §11.1 "Architecture specification strings".
121
5025879e 122 Examples: i386, mipsel, musl-linux-amd64, 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);
3b302846 136 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
314a3f88 137 virtual ~PackageArchitectureMatchesSpecification();
424ff669
DK
138};
139 /*}}}*/
3721cb01
DK
140class PackageIsNewInstall : public PackageMatcher { /*{{{*/
141 pkgCacheFile * const Cache;
142public:
e8afd168 143 explicit PackageIsNewInstall(pkgCacheFile * const Cache);
3b302846 144 virtual bool operator() (pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
3721cb01
DK
145 virtual ~PackageIsNewInstall();
146};
147 /*}}}*/
148
9ba5aa3b
DK
149}
150}
151#endif