]> cygwin.com Git - cygwin-apps/setup.git/blob - PackageSpecification.h
Backport some changes from trunk.
[cygwin-apps/setup.git] / PackageSpecification.h
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 SETUP_PACKAGESPECIFICATION_H
17 #define SETUP_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;
59 bool satisfies (String const &lhs, String const &rhs) const;
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 String _packageName; /* foobar */
71 _operators const * _operator; /* >= */
72 String _version; /* 1.20 */
73 };
74
75 std::ostream &
76 operator << (std::ostream &os, PackageSpecification const &);
77
78 #endif /* SETUP_PACKAGESPECIFICATION_H */
This page took 0.037213 seconds and 5 git commands to generate.