LibPkg
dependency.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright © 2003-2005 Graham Shaw.
3 // Distribution and use are subject to the GNU Lesser General Public License,
4 // a copy of which may be found in the file !LibPkg.Copyright.
5 
6 #ifndef LIBPKG_DEPENDENCY
7 #define LIBPKG_DEPENDENCY
8 
9 #include <vector>
10 #include <string>
11 
12 #include "libpkg/version.h"
13 
14 namespace pkg {
15 
16 using std::string;
17 
25 {
26 public:
30  {
48  };
49 
50  class parse_error;
51 private:
53  string _pkgname;
54 
56  relation_type _relation;
57 
59  pkg::version _version;
60 public:
65  dependency();
66 
73  const pkg::version& version);
74 
79  dependency(string::const_iterator first,string::const_iterator last);
80 
84  dependency(const string& depstr);
85 
87  ~dependency();
88 
92  operator string() const;
93 
97  const string& pkgname() const
98  { return _pkgname; }
99 
104  { return _relation; }
105 
109  const pkg::version& version() const
110  { return _version; }
111 
117  bool matches(const string& pkgname,const pkg::version& pkgvrsn) const;
118 private:
123  void parse(string::const_iterator first,string::const_iterator last);
124 };
125 
128  public std::runtime_error
129 {
130 public:
134  parse_error(const char* message);
135 };
136 
142 void parse_dependency_alt_list(string::const_iterator first,
143  string::const_iterator last,std::vector<dependency>* out);
144 
150 void parse_dependency_list(string::const_iterator first,
151  string::const_iterator last,std::vector<std::vector<dependency> >* out);
152 
153 }; /* namespace pkg */
154 
155 #endif
An exception class for reporting parse errors.
Definition: dependency.h:127
bool matches(const string &pkgname, const pkg::version &pkgvrsn) const
Test whether dependency is satisfied by a given package/version.
Definition: dependency.cc:82
relation_type relation() const
Get relational operator.
Definition: dependency.h:103
A class to represent a package dependency.
Definition: dependency.h:24
relation_type
An enumerated type to specify a relational operator for comparing versions.
Definition: dependency.h:29
void parse_dependency_list(string::const_iterator first, string::const_iterator last, std::vector< std::vector< dependency > > *out)
Parse dependency list.
Definition: dependency.cc:250
A relational operator that is true when the first version is earlier than the second.
Definition: dependency.h:38
A relational operator that is true when the first version is later than the second.
Definition: dependency.h:47
A relational operator that is always true.
Definition: dependency.h:32
A relational operator that is true when the first version is earlier or equal to the second...
Definition: dependency.h:44
A class to represent a package version.
Definition: version.h:21
~dependency()
Destroy dependency.
Definition: dependency.cc:34
parse_error(const char *message)
Construct parse error.
Definition: dependency.cc:206
void parse_dependency_alt_list(string::const_iterator first, string::const_iterator last, std::vector< dependency > *out)
Parse dependency alternatives list.
Definition: dependency.cc:210
A relational operator that is true when the first version is later or equal to the second...
Definition: dependency.h:41
A relational operator that is true when two versions are equal.
Definition: dependency.h:35
const pkg::version & version() const
Get version.
Definition: dependency.h:109
const string & pkgname() const
Get package name.
Definition: dependency.h:97
dependency()
Construct dependency with default value.
Definition: dependency.cc:12

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)