]> git.saurik.com Git - apt.git/blob - apt-pkg/cachefilter.h
fix build failure with the new apt-vendors stuff
[apt.git] / apt-pkg / cachefilter.h
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>
10
11 #include <string>
12
13 #include <regex.h>
14 /*}}}*/
15 namespace APT {
16 namespace CacheFilter {
17
18 #define PACKAGE_MATCHER_ABI_COMPAT 1
19 #ifdef PACKAGE_MATCHER_ABI_COMPAT
20
21 // PackageNameMatchesRegEx /*{{{*/
22 class PackageNameMatchesRegEx {
23 /** \brief dpointer placeholder (for later in case we need it) */
24 void *d;
25 regex_t* pattern;
26 public:
27 PackageNameMatchesRegEx(std::string const &Pattern);
28 bool operator() (pkgCache::PkgIterator const &Pkg);
29 bool operator() (pkgCache::GrpIterator const &Grp);
30 ~PackageNameMatchesRegEx();
31 };
32 /*}}}*/
33 // PackageNameMatchesFnmatch /*{{{*/
34 class PackageNameMatchesFnmatch {
35 /** \brief dpointer placeholder (for later in case we need it) */
36 void *d;
37 const std::string Pattern;
38 public:
39 PackageNameMatchesFnmatch(std::string const &Pattern)
40 : Pattern(Pattern) {};
41 bool operator() (pkgCache::PkgIterator const &Pkg);
42 bool operator() (pkgCache::GrpIterator const &Grp);
43 ~PackageNameMatchesFnmatch() {};
44 };
45 /*}}}*/
46 // PackageArchitectureMatchesSpecification /*{{{*/
47 /** \class PackageArchitectureMatchesSpecification
48 \brief matching against architecture specification strings
49
50 The strings are of the format <kernel>-<cpu> where either component,
51 or the whole string, can be the wildcard "any" as defined in
52 debian-policy §11.1 "Architecture specification strings".
53
54 Examples: i386, mipsel, linux-any, any-amd64, any */
55 class PackageArchitectureMatchesSpecification {
56 std::string literal;
57 std::string complete;
58 bool isPattern;
59 /** \brief dpointer placeholder (for later in case we need it) */
60 void *d;
61 public:
62 /** \brief matching against architecture specification strings
63 *
64 * @param pattern is the architecture specification string
65 * @param isPattern defines if the given \b pattern is a
66 * architecture specification pattern to match others against
67 * or if it is the fixed string and matched against patterns
68 */
69 PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
70 bool operator() (char const * const &arch);
71 bool operator() (pkgCache::PkgIterator const &Pkg);
72 bool operator() (pkgCache::VerIterator const &Ver);
73 ~PackageArchitectureMatchesSpecification();
74 };
75
76 #else
77
78 class PackageMatcher {
79 public:
80 virtual bool operator() (pkgCache::PkgIterator const &Pkg) { return false; };
81 virtual bool operator() (pkgCache::GrpIterator const &Grp) { return false; };
82 virtual bool operator() (pkgCache::VerIterator const &Ver) { return false; };
83
84 virtual ~PackageMatcher() {};
85 };
86
87 // PackageNameMatchesRegEx /*{{{*/
88 class PackageNameMatchesRegEx : public PackageMatcher {
89 /** \brief dpointer placeholder (for later in case we need it) */
90 void *d;
91 regex_t* pattern;
92 public:
93 PackageNameMatchesRegEx(std::string const &Pattern);
94 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
95 virtual bool operator() (pkgCache::GrpIterator const &Grp);
96 virtual ~PackageNameMatchesRegEx();
97 };
98 /*}}}*/
99 // PackageNameMatchesFnmatch /*{{{*/
100 class PackageNameMatchesFnmatch : public PackageMatcher{
101 /** \brief dpointer placeholder (for later in case we need it) */
102 void *d;
103 const std::string Pattern;
104 public:
105 PackageNameMatchesFnmatch(std::string const &Pattern)
106 : Pattern(Pattern) {};
107 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
108 virtual bool operator() (pkgCache::GrpIterator const &Grp);
109 virtual ~PackageNameMatchesFnmatch() {};
110 };
111 /*}}}*/
112 // PackageArchitectureMatchesSpecification /*{{{*/
113 /** \class PackageArchitectureMatchesSpecification
114 \brief matching against architecture specification strings
115
116 The strings are of the format <kernel>-<cpu> where either component,
117 or the whole string, can be the wildcard "any" as defined in
118 debian-policy §11.1 "Architecture specification strings".
119
120 Examples: i386, mipsel, linux-any, any-amd64, any */
121 class PackageArchitectureMatchesSpecification : public PackageMatcher {
122 std::string literal;
123 std::string complete;
124 bool isPattern;
125 /** \brief dpointer placeholder (for later in case we need it) */
126 void *d;
127 public:
128 /** \brief matching against architecture specification strings
129 *
130 * @param pattern is the architecture specification string
131 * @param isPattern defines if the given \b pattern is a
132 * architecture specification pattern to match others against
133 * or if it is the fixed string and matched against patterns
134 */
135 PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
136 bool operator() (char const * const &arch);
137 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
138 virtual bool operator() (pkgCache::VerIterator const &Ver);
139 virtual ~PackageArchitectureMatchesSpecification();
140 };
141 #endif
142 /*}}}*/
143 }
144 }
145 #endif