]>
git.saurik.com Git - apt.git/blob - apt-pkg/cachefilter.cc
1 // -*- mode: cpp; mode: fold -*-
3 /** \file cachefilter.h
4 Collection of functor classes */
6 // Include Files /*{{{*/
7 #include <apt-pkg/cachefilter.h>
8 #include <apt-pkg/error.h>
9 #include <apt-pkg/pkgcache.h>
18 namespace CacheFilter
{
19 PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string
const &Pattern
) {/*{{{*/
20 pattern
= new regex_t
;
21 int const Res
= regcomp(pattern
, Pattern
.c_str(), REG_EXTENDED
| REG_ICASE
| REG_NOSUB
);
28 regerror(Res
, pattern
, Error
, sizeof(Error
));
29 _error
->Error(_("Regex compilation error - %s"), Error
);
32 bool PackageNameMatchesRegEx::operator() (pkgCache::PkgIterator
const &Pkg
) {/*{{{*/
33 if (unlikely(pattern
== NULL
))
36 return regexec(pattern
, Pkg
.Name(), 0, 0, 0) == 0;
39 bool PackageNameMatchesRegEx::operator() (pkgCache::GrpIterator
const &Grp
) {/*{{{*/
40 if (unlikely(pattern
== NULL
))
43 return regexec(pattern
, Grp
.Name(), 0, 0, 0) == 0;
46 PackageNameMatchesRegEx::~PackageNameMatchesRegEx() { /*{{{*/