]> cygwin.com Git - cygwin-apps/setup.git/blob - PackageSpecification.cc
(IniDBBuilderPackage::process_src): Streamline and split out
[cygwin-apps/setup.git] / PackageSpecification.cc
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 #if 0
17 static const char *cvsid = "\n%%% $Id$\n";
18 #endif
19
20 #include "PackageSpecification.h"
21 #include "package_version.h"
22
23 PackageSpecification::PackageSpecification (String const &packageName)
24 : _packageName (packageName) , _operator (0), _version ()
25 {
26 }
27
28 String const&
29 PackageSpecification::packageName () const
30 {
31 return _packageName;
32 }
33
34 void
35 PackageSpecification::setOperator (_operators const &anOperator)
36 {
37 _operator = &anOperator;
38 }
39
40 void
41 PackageSpecification::setVersion (String const &aVersion)
42 {
43 _version = aVersion;
44 }
45
46 bool
47 PackageSpecification::satisfies (packageversion const &aPackage) const
48 {
49 return false;
50 }
51
52 String
53 PackageSpecification::serialise () const
54 {
55 return _packageName;
56 }
57
58 PackageSpecification &
59 PackageSpecification::operator= (PackageSpecification const &rhs)
60 {
61 _packageName = rhs._packageName;
62 return *this;
63 }
64
65 std::ostream &
66 operator << (std::ostream &os, PackageSpecification const &spec)
67 {
68 os << spec._packageName;
69 if (spec._operator)
70 os << " " << spec._operator->caption() << " " << spec._version;
71 return os;
72 }
73
74 const PackageSpecification::_operators PackageSpecification::Equals(0);
75 const PackageSpecification::_operators PackageSpecification::LessThan(1);
76 const PackageSpecification::_operators PackageSpecification::MoreThan(2);
77 const PackageSpecification::_operators PackageSpecification::LessThanEquals(3);
78 const PackageSpecification::_operators PackageSpecification::MoreThanEquals(4);
79
80 char const *
81 PackageSpecification::_operators::caption () const
82 {
83 switch (_value)
84 {
85 case 0:
86 return "==";
87 case 1:
88 return "<";
89 case 2:
90 return ">";
91 case 3:
92 return "<=";
93 case 4:
94 return ">=";
95 }
96 // Pacify GCC: (all case options are checked above)
97 return "Unknown operator";
98 }
This page took 0.044856 seconds and 6 git commands to generate.