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