cachefilter.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. class PackageMatcher {
  16. public:
  17. virtual bool operator() (pkgCache::PkgIterator const &Pkg) { return false; };
  18. virtual bool operator() (pkgCache::GrpIterator const &Grp) { return false; };
  19. virtual bool operator() (pkgCache::VerIterator const &Ver) { return false; };
  20. virtual ~PackageMatcher() {};
  21. };
  22. // PackageNameMatchesRegEx /*{{{*/
  23. class PackageNameMatchesRegEx : public PackageMatcher {
  24. /** \brief dpointer placeholder (for later in case we need it) */
  25. void *d;
  26. regex_t* pattern;
  27. public:
  28. PackageNameMatchesRegEx(std::string const &Pattern);
  29. virtual bool operator() (pkgCache::PkgIterator const &Pkg);
  30. virtual bool operator() (pkgCache::GrpIterator const &Grp);
  31. ~PackageNameMatchesRegEx();
  32. };
  33. /*}}}*/
  34. // PackageNameMatchesFnmatch /*{{{*/
  35. class PackageNameMatchesFnmatch : public PackageMatcher{
  36. /** \brief dpointer placeholder (for later in case we need it) */
  37. void *d;
  38. const std::string Pattern;
  39. public:
  40. PackageNameMatchesFnmatch(std::string const &Pattern)
  41. : Pattern(Pattern) {};
  42. virtual bool operator() (pkgCache::PkgIterator const &Pkg);
  43. virtual bool operator() (pkgCache::GrpIterator const &Grp);
  44. ~PackageNameMatchesFnmatch() {};
  45. };
  46. /*}}}*/
  47. // PackageArchitectureMatchesSpecification /*{{{*/
  48. /** \class PackageArchitectureMatchesSpecification
  49. \brief matching against architecture specification strings
  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. Examples: i386, mipsel, linux-any, any-amd64, any */
  54. class PackageArchitectureMatchesSpecification : public PackageMatcher {
  55. std::string literal;
  56. std::string complete;
  57. bool isPattern;
  58. /** \brief dpointer placeholder (for later in case we need it) */
  59. void *d;
  60. public:
  61. /** \brief matching against architecture specification strings
  62. *
  63. * @param pattern is the architecture specification string
  64. * @param isPattern defines if the given \b pattern is a
  65. * architecture specification pattern to match others against
  66. * or if it is the fixed string and matched against patterns
  67. */
  68. PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern = true);
  69. bool operator() (char const * const &arch);
  70. virtual bool operator() (pkgCache::PkgIterator const &Pkg);
  71. virtual bool operator() (pkgCache::VerIterator const &Ver);
  72. ~PackageArchitectureMatchesSpecification();
  73. };
  74. /*}}}*/
  75. }
  76. }
  77. #endif