Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
[ntk/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>
10
11#include <string>
12
13#include <regex.h>
14 /*}}}*/
15namespace APT {
16namespace CacheFilter {
b9179170 17
dd4d9729
MV
18#define PACKAGE_MATCHER_ABI_COMPAT 1
19#ifdef PACKAGE_MATCHER_ABI_COMPAT
20
21// PackageNameMatchesRegEx /*{{{*/
22class PackageNameMatchesRegEx {
23 /** \brief dpointer placeholder (for later in case we need it) */
24 void *d;
25 regex_t* pattern;
26public:
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;
38public:
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 */
55class 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;
61public:
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
b9179170
MV
78class 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
9ba5aa3b 87// PackageNameMatchesRegEx /*{{{*/
b9179170 88class PackageNameMatchesRegEx : public PackageMatcher {
be9b62f7
MV
89 /** \brief dpointer placeholder (for later in case we need it) */
90 void *d;
9ba5aa3b
DK
91 regex_t* pattern;
92public:
93 PackageNameMatchesRegEx(std::string const &Pattern);
b9179170
MV
94 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
95 virtual bool operator() (pkgCache::GrpIterator const &Grp);
314a3f88 96 virtual ~PackageNameMatchesRegEx();
9ba5aa3b
DK
97};
98 /*}}}*/
b9179170 99// PackageNameMatchesFnmatch /*{{{*/
dd4d9729 100 class PackageNameMatchesFnmatch : public PackageMatcher{
b9179170
MV
101 /** \brief dpointer placeholder (for later in case we need it) */
102 void *d;
103 const std::string Pattern;
104public:
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);
314a3f88 109 virtual ~PackageNameMatchesFnmatch() {};
b9179170
MV
110};
111 /*}}}*/
424ff669
DK
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 */
b9179170 121class PackageArchitectureMatchesSpecification : public PackageMatcher {
424ff669
DK
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;
127public:
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);
b9179170
MV
137 virtual bool operator() (pkgCache::PkgIterator const &Pkg);
138 virtual bool operator() (pkgCache::VerIterator const &Ver);
314a3f88 139 virtual ~PackageArchitectureMatchesSpecification();
424ff669 140};
dd4d9729 141#endif
424ff669 142 /*}}}*/
9ba5aa3b
DK
143}
144}
145#endif