versionmatch.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: versionmatch.h,v 1.4 2001/05/29 03:07:12 jgg Exp $
  4. /* ######################################################################
  5. Version Matching
  6. This module takes a matching string and a type and locates the version
  7. record that satisfies the constraint described by the matching string.
  8. Version: 1.2*
  9. Release: o=Debian,v=2.1*,c=main
  10. Release: v=2.1*
  11. Release: a=testing
  12. Release: n=squeeze
  13. Release: *
  14. Origin: ftp.debian.org
  15. Release may be a complex type that can specify matches for any of:
  16. Version (v= with prefix)
  17. Origin (o=)
  18. Archive (a=) eg, unstable, testing, stable
  19. Codename (n=) e.g. etch, lenny, squeeze, sid
  20. Label (l=)
  21. Component (c=)
  22. Binary Architecture (b=)
  23. If there are no equals signs in the string then it is scanned in short
  24. form - if it starts with a number it is Version otherwise it is an
  25. Archive or a Codename.
  26. Release may be a '*' to match all releases.
  27. ##################################################################### */
  28. /*}}}*/
  29. #ifndef PKGLIB_VERSIONMATCH_H
  30. #define PKGLIB_VERSIONMATCH_H
  31. #include <apt-pkg/pkgcache.h>
  32. #include <apt-pkg/cacheiterators.h>
  33. #include <string>
  34. #ifndef APT_8_CLEANER_HEADERS
  35. using std::string;
  36. #endif
  37. class pkgVersionMatch
  38. {
  39. // Version Matching
  40. std::string VerStr;
  41. bool VerPrefixMatch;
  42. // Release Matching
  43. std::string RelVerStr;
  44. bool RelVerPrefixMatch;
  45. std::string RelOrigin;
  46. std::string RelRelease;
  47. std::string RelCodename;
  48. std::string RelArchive;
  49. std::string RelLabel;
  50. std::string RelComponent;
  51. std::string RelArchitecture;
  52. bool MatchAll;
  53. // Origin Matching
  54. std::string OrSite;
  55. public:
  56. enum MatchType {None = 0,Version,Release,Origin} Type;
  57. bool MatchVer(const char *A,std::string B,bool Prefix) APT_PURE;
  58. static bool ExpressionMatches(const char *pattern, const char *string);
  59. static bool ExpressionMatches(const std::string& pattern, const char *string);
  60. bool FileMatch(pkgCache::PkgFileIterator File);
  61. pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg);
  62. bool VersionMatches(pkgCache::VerIterator Ver);
  63. pkgVersionMatch(std::string Data,MatchType Type);
  64. };
  65. #endif