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