LibPkg
dependency.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 //
3 // Copyright 2003-2020 Graham Shaw
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_DEPENDENCY
18 #define LIBPKG_DEPENDENCY
19 
20 #include <vector>
21 #include <string>
22 
23 #include "libpkg/version.h"
24 
25 namespace pkg {
26 
27 using std::string;
28 
36 {
37 public:
41  {
59  };
60 
61  class parse_error;
62 private:
64  string _pkgname;
65 
67  relation_type _relation;
68 
70  pkg::version _version;
71 public:
76  dependency();
77 
84  const pkg::version& version);
85 
90  dependency(string::const_iterator first,string::const_iterator last);
91 
95  dependency(const string& depstr);
96 
98  ~dependency();
99 
103  operator string() const;
104 
108  const string& pkgname() const
109  { return _pkgname; }
110 
115  { return _relation; }
116 
120  const pkg::version& version() const
121  { return _version; }
122 
128  bool matches(const string& pkgname,const pkg::version& pkgvrsn) const;
129 private:
134  void parse(string::const_iterator first,string::const_iterator last);
135 };
136 
139  public std::runtime_error
140 {
141 public:
145  parse_error(const char* message);
146 };
147 
153 void parse_dependency_alt_list(string::const_iterator first,
154  string::const_iterator last,std::vector<dependency>* out);
155 
161 void parse_dependency_list(string::const_iterator first,
162  string::const_iterator last,std::vector<std::vector<dependency> >* out);
163 
164 }; /* namespace pkg */
165 
166 #endif
An exception class for reporting parse errors.
Definition: dependency.h:138
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
bool matches(const string &pkgname, const pkg::version &pkgvrsn) const
Test whether dependency is satisfied by a given package/version.
Definition: dependency.cc:93
A class to represent a package dependency.
Definition: dependency.h:35
relation_type
An enumerated type to specify a relational operator for comparing versions.
Definition: dependency.h:40
void parse_dependency_list(string::const_iterator first, string::const_iterator last, std::vector< std::vector< dependency > > *out)
Parse dependency list.
Definition: dependency.cc:261
A relational operator that is true when the first version is earlier than the second.
Definition: dependency.h:49
A relational operator that is true when the first version is later than the second.
Definition: dependency.h:58
A relational operator that is always true.
Definition: dependency.h:43
A relational operator that is true when the first version is earlier or equal to the second...
Definition: dependency.h:55
const string & pkgname() const
Get package name.
Definition: dependency.h:108
relation_type relation() const
Get relational operator.
Definition: dependency.h:114
A class to represent a package version.
Definition: version.h:32
~dependency()
Destroy dependency.
Definition: dependency.cc:45
void parse_dependency_alt_list(string::const_iterator first, string::const_iterator last, std::vector< dependency > *out)
Parse dependency alternatives list.
Definition: dependency.cc:221
A relational operator that is true when the first version is later or equal to the second...
Definition: dependency.h:52
A relational operator that is true when two versions are equal.
Definition: dependency.h:46
const pkg::version & version() const
Get version.
Definition: dependency.h:120
dependency()
Construct dependency with default value.
Definition: dependency.cc:23

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)