]>
Commit | Line | Data |
---|---|---|
aa1e3b4d RC |
1 | /* |
2 | * Copyright (c) 2002, Robert Collins. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Robert Collins <rbtcollins@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #ifndef _PACKAGESPECIFICATION_H_ | |
17 | #define _PACKAGESPECIFICATION_H_ | |
18 | ||
19 | /* To parse this file */ | |
20 | #include "String++.h" | |
21 | #include <iosfwd> | |
22 | class packageversion; | |
23 | ||
24 | /* Describe a package - i.e. we need version 5 of apt */ | |
25 | ||
26 | class PackageSpecification | |
27 | { | |
28 | public: | |
29 | PackageSpecification () : _packageName (), _operator(0) {} | |
30 | PackageSpecification (String const &packageName); | |
31 | ~PackageSpecification () {} | |
32 | ||
33 | class _operators; | |
34 | ||
35 | String const& packageName() const; | |
36 | void setOperator (_operators const &); | |
37 | void setVersion (String const &); | |
38 | ||
39 | bool satisfies (packageversion const &) const; | |
40 | String serialise () const; | |
41 | ||
42 | PackageSpecification &operator= (PackageSpecification const &); | |
43 | ||
44 | friend std::ostream &operator << (std::ostream &, PackageSpecification const &); | |
45 | ||
46 | class _operators | |
47 | { | |
48 | public: | |
49 | _operators ():_value (0) {}; | |
50 | _operators (int aInt) { | |
51 | _value = aInt; | |
52 | if (_value < 0 || _value > 4) | |
53 | _value = 0; | |
54 | } | |
55 | _operators & operator ++ (); | |
56 | bool operator == (_operators const &rhs) { return _value == rhs._value; } | |
57 | bool operator != (_operators const &rhs) { return _value != rhs._value; } | |
58 | const char *caption () const; | |
64cd7f94 | 59 | bool satisfies (String const &lhs, String const &rhs) const; |
aa1e3b4d RC |
60 | private: |
61 | int _value; | |
62 | }; | |
63 | static const _operators Equals; | |
64 | static const _operators LessThan; | |
65 | static const _operators MoreThan; | |
66 | static const _operators LessThanEquals; | |
67 | static const _operators MoreThanEquals; | |
68 | ||
69 | private: | |
70 | PackageSpecification (PackageSpecification const &); | |
71 | ||
72 | String _packageName; /* foobar */ | |
73 | _operators const * _operator; /* >= */ | |
74 | String _version; /* 1.20 */ | |
75 | }; | |
76 | ||
77 | std::ostream & | |
78 | operator << (std::ostream &os, PackageSpecification const &); | |
79 | ||
80 | #endif /* _PACKAGESPECIFICATION_H_ */ |