cachefilter.h 3.0 KB

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