]>
cygwin.com Git - cygwin-apps/setup.git/blob - PackageSpecification.cc
56a4d2b93c623f92f59cc9a5abcbb0cef73179a4
2 * Copyright (c) 2002, Robert Collins.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
17 static const char *cvsid
= "\n%%% $Id$\n";
20 #include "PackageSpecification.h"
21 #include "package_version.h"
23 PackageSpecification::PackageSpecification (String
const &packageName
)
24 : _packageName (packageName
) , _operator (0), _version ()
29 PackageSpecification::packageName () const
35 PackageSpecification::setOperator (_operators
const &anOperator
)
37 _operator
= &anOperator
;
41 PackageSpecification::setVersion (String
const &aVersion
)
47 PackageSpecification::satisfies (packageversion
const &aPackage
) const
49 if (_packageName
.casecompare (aPackage
.Name()) != 0)
51 if (_operator
&& _version
.size()
52 && !_operator
->satisfies (aPackage
.Canonical_version (), _version
))
58 PackageSpecification::serialise () const
63 PackageSpecification
&
64 PackageSpecification::operator= (PackageSpecification
const &rhs
)
66 _packageName
= rhs
._packageName
;
71 operator << (std::ostream
&os
, PackageSpecification
const &spec
)
73 os
<< spec
._packageName
;
75 os
<< " " << spec
._operator
->caption() << " " << spec
._version
;
79 const PackageSpecification::_operators
PackageSpecification::Equals(0);
80 const PackageSpecification::_operators
PackageSpecification::LessThan(1);
81 const PackageSpecification::_operators
PackageSpecification::MoreThan(2);
82 const PackageSpecification::_operators
PackageSpecification::LessThanEquals(3);
83 const PackageSpecification::_operators
PackageSpecification::MoreThanEquals(4);
86 PackageSpecification::_operators::caption () const
101 // Pacify GCC: (all case options are checked above)
102 return "Unknown operator";
106 PackageSpecification::_operators::satisfies (String
const &lhs
, String
const &rhs
) const
111 return lhs
.casecompare (rhs
) == 0;
113 return lhs
.casecompare (rhs
) < 0;
115 return lhs
.casecompare (rhs
) > 0;
117 return lhs
.casecompare (rhs
) <= 0;
119 return lhs
.casecompare (rhs
) >= 0;
This page took 0.041592 seconds and 5 git commands to generate.