version.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: version.h,v 1.7 2001/05/14 05:58:33 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. using std::string;
  23. class pkgVersioningSystem
  24. {
  25. public:
  26. // Global list of VS's
  27. static pkgVersioningSystem **GlobalList;
  28. static unsigned long GlobalListLen;
  29. static pkgVersioningSystem *GetVS(const char *Label);
  30. const char *Label;
  31. // Compare versions..
  32. virtual int DoCmpVersion(const char *A,const char *Aend,
  33. const char *B,const char *Bend) = 0;
  34. virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) = 0;
  35. virtual int DoCmpReleaseVer(const char *A,const char *Aend,
  36. const char *B,const char *Bend) = 0;
  37. virtual string UpstreamVersion(const char *A) = 0;
  38. // See if the given VS is compatible with this one..
  39. virtual bool TestCompatibility(pkgVersioningSystem const &Against)
  40. {return this == &Against;};
  41. // Shortcuts
  42. inline int CmpVersion(const char *A, const char *B)
  43. {
  44. return DoCmpVersion(A,A+strlen(A),B,B+strlen(B));
  45. };
  46. inline int CmpVersion(string A,string B)
  47. {
  48. return DoCmpVersion(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());
  49. };
  50. inline int CmpReleaseVer(const char *A, const char *B)
  51. {
  52. return DoCmpReleaseVer(A,A+strlen(A),B,B+strlen(B));
  53. };
  54. inline int CmpReleaseVer(string A,string B)
  55. {
  56. return DoCmpReleaseVer(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());
  57. };
  58. pkgVersioningSystem();
  59. virtual ~pkgVersioningSystem() {};
  60. };
  61. #ifdef APT_COMPATIBILITY
  62. #include <apt-pkg/debversion.h>
  63. #endif
  64. #endif