versionmatch.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <string>
  32. #include <apt-pkg/pkgcache.h>
  33. class pkgVersionMatch
  34. {
  35. // Version Matching
  36. std::string VerStr;
  37. bool VerPrefixMatch;
  38. // Release Matching
  39. std::string RelVerStr;
  40. bool RelVerPrefixMatch;
  41. std::string RelOrigin;
  42. std::string RelRelease;
  43. std::string RelCodename;
  44. std::string RelArchive;
  45. std::string RelLabel;
  46. std::string RelComponent;
  47. std::string RelArchitecture;
  48. bool MatchAll;
  49. // Origin Matching
  50. std::string OrSite;
  51. public:
  52. enum MatchType {None = 0,Version,Release,Origin} Type;
  53. bool MatchVer(const char *A,std::string B,bool Prefix);
  54. bool ExpressionMatches(const char *pattern, const char *string);
  55. bool ExpressionMatches(const std::string& pattern, const char *string);
  56. bool FileMatch(pkgCache::PkgFileIterator File);
  57. pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg);
  58. pkgVersionMatch(std::string Data,MatchType Type);
  59. };
  60. #endif