version.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: version.h,v 1.6 2001/02/20 07:03:17 jgg Exp $
  4. /* ######################################################################
  5. Version - Versioning system..
  6. The versioning system represents how versions are compared, represented
  7. and how dependencies are evaluated. As a general rule versioning
  8. systems are not compatible unless specifically allowed by the
  9. TestCompatibility query.
  10. The versions are stored in a global list of versions, but that is just
  11. so that they can be queried when someone does 'apt-get -v'.
  12. pkgSystem provides the proper means to access the VS for the active
  13. system.
  14. ##################################################################### */
  15. /*}}}*/
  16. #ifndef PKGLIB_VERSION_H
  17. #define PKGLIB_VERSION_H
  18. #ifdef __GNUG__
  19. #pragma interface "apt-pkg/version.h"
  20. #endif
  21. #include <string>
  22. class pkgVersioningSystem
  23. {
  24. public:
  25. // Global list of VS's
  26. static pkgVersioningSystem **GlobalList;
  27. static unsigned long GlobalListLen;
  28. static pkgVersioningSystem *GetVS(const char *Label);
  29. const char *Label;
  30. // Compare versions..
  31. virtual int DoCmpVersion(const char *A,const char *Aend,
  32. const char *B,const char *Bend) = 0;
  33. virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) = 0;
  34. virtual int DoCmpReleaseVer(const char *A,const char *Aend,
  35. const char *B,const char *Bend) = 0;
  36. virtual string UpstreamVersion(const char *A) = 0;
  37. // See if the given VS is compatible with this one..
  38. virtual bool TestCompatibility(pkgVersioningSystem const &Against)
  39. {return this == &Against;};
  40. // Shortcuts
  41. inline int CmpVersion(const char *A, const char *B)
  42. {
  43. return DoCmpVersion(A,A+strlen(A),B,B+strlen(B));
  44. };
  45. inline int CmpVersion(string A,string B)
  46. {
  47. return DoCmpVersion(A.begin(),A.end(),B.begin(),B.end());
  48. };
  49. inline int CmpReleaseVer(const char *A, const char *B)
  50. {
  51. return DoCmpReleaseVer(A,A+strlen(A),B,B+strlen(B));
  52. };
  53. inline int CmpReleaseVer(string A,string B)
  54. {
  55. return DoCmpReleaseVer(A.begin(),A.end(),B.begin(),B.end());
  56. };
  57. pkgVersioningSystem();
  58. virtual ~pkgVersioningSystem() {};
  59. };
  60. #ifdef APT_COMPATIBILITY
  61. #include <apt-pkg/debversion.h>
  62. #endif
  63. #endif