]>
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 /*{{{*/
9 #include <apt-pkg/cachefilter.h>
10 #include <apt-pkg/error.h>
11 #include <apt-pkg/pkgcache.h>
20 namespace CacheFilter
{
21 PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string
const &Pattern
) : d(NULL
) {/*{{{*/
22 pattern
= new regex_t
;
23 int const Res
= regcomp(pattern
, Pattern
.c_str(), REG_EXTENDED
| REG_ICASE
| REG_NOSUB
);
30 regerror(Res
, pattern
, Error
, sizeof(Error
));
31 _error
->Error(_("Regex compilation error - %s"), Error
);
34 bool PackageNameMatchesRegEx::operator() (pkgCache::PkgIterator
const &Pkg
) {/*{{{*/
35 if (unlikely(pattern
== NULL
))
38 return regexec(pattern
, Pkg
.Name(), 0, 0, 0) == 0;
41 bool PackageNameMatchesRegEx::operator() (pkgCache::GrpIterator
const &Grp
) {/*{{{*/
42 if (unlikely(pattern
== NULL
))
45 return regexec(pattern
, Grp
.Name(), 0, 0, 0) == 0;
48 PackageNameMatchesRegEx::~PackageNameMatchesRegEx() { /*{{{*/