Cupt
relation.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
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 *
6 * (version 3 or above) as published by the Free Software Foundation. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_CACHE_RELATION_SEEN
19 #define CUPT_CACHE_RELATION_SEEN
20 
22 
23 #include <cupt/common.hpp>
24 
25 namespace cupt {
26 namespace cache {
27 
29 struct CUPT_API Relation
30 {
31  private:
32  CUPT_LOCAL const char* p_parseVersionPart(const char*, const char*);
33  CUPT_LOCAL const char* p_parseRelationSymbols(const char*, const char*);
34  CUPT_LOCAL const char* p_parsePackagePart(const char*, const char*);
35  CUPT_LOCAL const char* __init(const char*, const char*);
36  protected:
37  Relation(pair<const char*, const char*> input, char const* * end);
38  public:
40  struct Types
41  {
43  enum Type { Less, Equal, More, LessOrEqual, MoreOrEqual, LiteralyEqual, None };
45  static const string strings[];
46  };
47  string packageName;
48  string architecture;
49  Types::Type relationType;
50  string versionString;
51 
53 
57  explicit Relation(pair< const char*, const char* > input);
58  Relation(Relation&&) = default;
59  Relation(const Relation&) = default;
60  Relation& operator=(Relation&&) = default;
61  Relation& operator=(const Relation&) = default;
63  virtual ~Relation();
65  string toString() const;
67 
74  bool isSatisfiedBy(const string& otherVersionString) const;
76 
80  bool operator==(const Relation& other) const;
81 };
82 
84 struct CUPT_API ArchitecturedRelation: public Relation
85 {
86  private:
87  CUPT_LOCAL const char* p_parseArchitectures(const char*, const char*);
88  CUPT_LOCAL const char* p_parseProfiles(const char*, const char*);
89  CUPT_LOCAL void __init(const char*, const char*, const char*);
90  public:
91  vector<string> architectureFilters;
92  vector<vector<string>> buildProfiles;
93 
95 
100  explicit ArchitecturedRelation(pair< const char*, const char* > input);
103  ArchitecturedRelation& operator=(ArchitecturedRelation&&) = default;
104  ArchitecturedRelation& operator=(const ArchitecturedRelation&) = default;
105  string toString() const;
106 };
107 
109 struct CUPT_API RelationExpression: public vector< Relation >
110 {
111  private:
112  CUPT_LOCAL void __init(const char*, const char*);
113  public:
115  string toString() const;
117  string getHashString() const;
119 
124 
127  explicit RelationExpression(const string& input);
129 
133  explicit RelationExpression(pair< const char*, const char* > input);
135  RelationExpression(const RelationExpression&) = default;
136  RelationExpression& operator=(RelationExpression&&) = default;
137  RelationExpression& operator=(const RelationExpression&) = default;
139  virtual ~RelationExpression();
140 };
141 
143 struct CUPT_API ArchitecturedRelationExpression: public vector< ArchitecturedRelation >
144 {
145  private:
146  CUPT_LOCAL void __init(const char*, const char*);
147  public:
149  string toString() const;
151 
156 
159  explicit ArchitecturedRelationExpression(const string& input);
161 
165  explicit ArchitecturedRelationExpression(pair< const char*, const char* > input);
172 };
173 
175 struct CUPT_API RelationLine: public vector< RelationExpression >
176 {
177  private:
178  CUPT_LOCAL void __init(const char*, const char*);
179  public:
181  string toString() const;
183 
186  RelationLine();
188 
191  explicit RelationLine(const string& input);
193 
197  explicit RelationLine(pair< const char*, const char* > input);
198  RelationLine(RelationLine&&) = default;
199  RelationLine(const RelationLine&) = default;
200  RelationLine& operator=(RelationLine&&);
201  RelationLine& operator=(const RelationLine&) = default;
203  virtual ~RelationLine();
204 };
205 
207 struct CUPT_API ArchitecturedRelationLine: public vector< ArchitecturedRelationExpression >
208 {
209  private:
210  CUPT_LOCAL void __init(const char*, const char*);
211  public:
213  string toString() const;
215 
220 
223  explicit ArchitecturedRelationLine(const string& input);
225 
229  explicit ArchitecturedRelationLine(pair< const char*, const char* > input);
233  ArchitecturedRelationLine& operator=(const ArchitecturedRelationLine&) = default;
235 
244  RelationLine toRelationLine(const string& currentArchitecture) const;
246  virtual ~ArchitecturedRelationLine();
247 };
248 
249 }
250 }
251 
252 #endif
253 
cupt::cache::ArchitecturedRelationExpression
group of alternative architectured relation expressions
Definition: relation.hpp:143
cupt::cache::Relation::Types::Type
Type
type
Definition: relation.hpp:43
common.hpp
cupt::cache::ArchitecturedRelationLine
array of architectured relation expressions
Definition: relation.hpp:207
cupt::cache::ArchitecturedRelation
relation with optional architecture filters
Definition: relation.hpp:84
cupt::cache::Relation
relation against certain binary package
Definition: relation.hpp:29
cupt::cache::RelationLine
array of relation expressions
Definition: relation.hpp:175
cupt::cache::Relation::Types
relation type
Definition: relation.hpp:40
cupt::cache::RelationExpression
group of alternative relations
Definition: relation.hpp:109