cachefilter.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <string>
  11. #include <regex.h>
  12. /*}}}*/
  13. namespace APT {
  14. namespace CacheFilter {
  15. // PackageNameMatchesRegEx /*{{{*/
  16. class PackageNameMatchesRegEx {
  17. /** \brief dpointer placeholder (for later in case we need it) */
  18. void *d;
  19. regex_t* pattern;
  20. public:
  21. PackageNameMatchesRegEx(std::string const &Pattern);
  22. bool operator() (pkgCache::PkgIterator const &Pkg);
  23. bool operator() (pkgCache::GrpIterator const &Grp);
  24. ~PackageNameMatchesRegEx();
  25. };
  26. /*}}}*/
  27. // PackageArchitectureMatchesSpecification /*{{{*/
  28. /** \class PackageArchitectureMatchesSpecification
  29. \brief matching against architecture specification strings
  30. The strings are of the format <kernel>-<cpu> where either component,
  31. or the whole string, can be the wildcard "any" as defined in
  32. debian-policy §11.1 "Architecture specification strings".
  33. Examples: i386, mipsel, linux-any, any-amd64, any */
  34. class PackageArchitectureMatchesSpecification {
  35. std::string literal;
  36. std::string complete;
  37. bool isPattern;
  38. /** \brief dpointer placeholder (for later in case we need it) */
  39. void *d;
  40. public:
  41. /** \brief matching against architecture specification strings
  42. *
  43. * @param pattern is the architecture specification string
  44. * @param isPattern defines if the given \b pattern is a
  45. * architecture specification pattern to match others against
  46. * or if it is the fixed string and matched against patterns
  47. */
  48. PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
  49. bool operator() (char const * const &arch);
  50. bool operator() (pkgCache::PkgIterator const &Pkg);
  51. bool operator() (pkgCache::VerIterator const &Ver);
  52. ~PackageArchitectureMatchesSpecification();
  53. };
  54. /*}}}*/
  55. }
  56. }
  57. #endif