]>
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 | ||
c93bc6d0 MB |
16 | #ifndef SETUP_PACKAGESPECIFICATION_H |
17 | #define SETUP_PACKAGESPECIFICATION_H | |
aa1e3b4d | 18 | |
aa1e3b4d | 19 | #include <iosfwd> |
08678720 | 20 | #include "String++.h" |
aa1e3b4d RC |
21 | class packageversion; |
22 | ||
23 | /* Describe a package - i.e. we need version 5 of apt */ | |
24 | ||
25 | class PackageSpecification | |
26 | { | |
27 | public: | |
28 | PackageSpecification () : _packageName (), _operator(0) {} | |
08678720 | 29 | PackageSpecification (const std::string& packageName); |
aa1e3b4d RC |
30 | ~PackageSpecification () {} |
31 | ||
32 | class _operators; | |
33 | ||
08678720 | 34 | const std::string& packageName() const; |
aa1e3b4d | 35 | void setOperator (_operators const &); |
08678720 | 36 | void setVersion (const std::string& ); |
aa1e3b4d RC |
37 | |
38 | bool satisfies (packageversion const &) const; | |
08678720 | 39 | std::string serialise () const; |
aa1e3b4d RC |
40 | |
41 | PackageSpecification &operator= (PackageSpecification const &); | |
42 | ||
43 | friend std::ostream &operator << (std::ostream &, PackageSpecification const &); | |
44 | ||
45 | class _operators | |
46 | { | |
47 | public: | |
48 | _operators ():_value (0) {}; | |
49 | _operators (int aInt) { | |
50 | _value = aInt; | |
51 | if (_value < 0 || _value > 4) | |
52 | _value = 0; | |
53 | } | |
54 | _operators & operator ++ (); | |
55 | bool operator == (_operators const &rhs) { return _value == rhs._value; } | |
56 | bool operator != (_operators const &rhs) { return _value != rhs._value; } | |
57 | const char *caption () const; | |
08678720 | 58 | bool satisfies (const std::string& lhs, const std::string& rhs) const; |
aa1e3b4d RC |
59 | private: |
60 | int _value; | |
61 | }; | |
62 | static const _operators Equals; | |
63 | static const _operators LessThan; | |
64 | static const _operators MoreThan; | |
65 | static const _operators LessThanEquals; | |
66 | static const _operators MoreThanEquals; | |
67 | ||
68 | private: | |
08678720 | 69 | std::string _packageName; /* foobar */ |
aa1e3b4d | 70 | _operators const * _operator; /* >= */ |
08678720 | 71 | std::string _version; /* 1.20 */ |
aa1e3b4d RC |
72 | }; |
73 | ||
74 | std::ostream & | |
75 | operator << (std::ostream &os, PackageSpecification const &); | |
76 | ||
c93bc6d0 | 77 | #endif /* SETUP_PACKAGESPECIFICATION_H */ |