libzypp 17.38.6
solvablespec.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
14#ifndef ZYPP_NG_SAT_SOLVABLESPEC_H_INCLUDED
15#define ZYPP_NG_SAT_SOLVABLESPEC_H_INCLUDED
16
17#include <zypp/ng/idstring.h>
21
22#include <unordered_set>
23
24namespace zyppng::sat {
25
26 class Pool;
27 class PreparedPool;
28 class Solvable;
29
55 {
56 public:
57 SolvableSpec() = default;
58 ~SolvableSpec() = default;
59
60 SolvableSpec( const SolvableSpec & ) = default;
61 SolvableSpec( SolvableSpec && ) = default;
62 SolvableSpec & operator=( const SolvableSpec & ) = default;
64
66 bool empty() const
67 { return _idents.empty() && _provides.empty(); }
68
70 void clear()
71 { _idents.clear(); _provides.clear(); }
72
78
79 void addIdent( IdString ident_r )
80 { if ( !ident_r.empty() ) _idents.insert( std::move(ident_r) ); }
81
82 const IdStringSet & idents() const
83 { return _idents; }
84
86 bool containsIdent( const IdString & ident_r ) const
87 { return _idents.count( ident_r ) != 0; }
88
89
97
98 void addProvides( Capability cap_r )
99 { if ( !cap_r.empty() ) _provides.insert( std::move(cap_r) ); }
100
101 const CapabilitySet & provides() const
102 { return _provides; }
103
105 bool containsProvides( const Capability & cap_r ) const
106 { return _provides.count( cap_r ) != 0; }
107
108
118
119 void parse( std::string_view spec_r );
120
123 void parseFrom( const zypp::InputStream & istr_r );
124
126 template <class TIterator>
127 void parseFrom( TIterator begin, TIterator end )
128 { for ( ; begin != end; ++begin ) parse( *begin ); }
129
131 void splitParseFrom( std::string_view multispec_r );
133
144 bool contains( Pool & pool_r, const Solvable & solv_r ) const;
145
146 private:
149 };
150
175 {
176 public:
177 using SolvIdSet = std::unordered_set<detail::SolvableIdType>;
178
180 EvaluatedSolvableSpec( PreparedPool & pp_r, const SolvableSpec & spec_r );
181
186
188 bool empty() const
189 { return _ids.empty(); }
190
192 bool contains( const Solvable & solv_r ) const;
193
195 const SolvIdSet & ids() const
196 { return _ids; }
197
198 private:
200 };
201
202} // namespace zyppng::sat
203
204#endif // ZYPP_NG_SAT_SOLVABLESPEC_H_INCLUDED
Access to the sat-pools string space.
Definition IdString.h:55
constexpr bool empty() const
Whether the string is empty.
Definition IdString.h:99
Helper to create and pass std::istream.
Definition inputstream.h:57
A sat capability.
Definition capability.h:74
bool empty() const
Whether the Capability is empty.
Definition capability.h:195
bool contains(const Solvable &solv_r) const
O(1) membership test — no pool access required.
EvaluatedSolvableSpec(EvaluatedSolvableSpec &&)=default
EvaluatedSolvableSpec & operator=(const EvaluatedSolvableSpec &)=default
EvaluatedSolvableSpec(const EvaluatedSolvableSpec &)=default
const SolvIdSet & ids() const
Direct access to the resolved id set (e.g.
EvaluatedSolvableSpec(PreparedPool &pp_r, const SolvableSpec &spec_r)
Construct by evaluating spec_r against pp_r.
EvaluatedSolvableSpec & operator=(EvaluatedSolvableSpec &&)=default
bool empty() const
Whether no solvable matched the spec at construction time.
std::unordered_set< detail::SolvableIdType > SolvIdSet
Orchestrator for a libsolv pool instance.
Definition pool.h:37
A move-only, non-owning view of a Pool that guarantees the whatprovides index is valid.
A pure data container describing a set of solvables by ident and/or provides.
void parse(std::string_view spec_r)
Parse and add a single spec entry.
bool empty() const
Whether the spec has no idents and no provides tokens.
bool containsIdent(const IdString &ident_r) const
Whether ident_r has been added to the spec (for introspection/tests).
SolvableSpec(const SolvableSpec &)=default
void parseFrom(const zypp::InputStream &istr_r)
Parse and add specs from istr_r (one per line; #-comments and empty lines are skipped automatically).
const CapabilitySet & provides() const
const IdStringSet & idents() const
void addIdent(IdString ident_r)
Add ident_r to the ident set.
void parseFrom(TIterator begin, TIterator end)
Parse and add specs from an iterator range of string-like values.
SolvableSpec(SolvableSpec &&)=default
bool contains(Pool &pool_r, const Solvable &solv_r) const
Test whether a single Solvable matches this spec.
SolvableSpec & operator=(SolvableSpec &&)=default
bool containsProvides(const Capability &cap_r) const
Whether cap_r has been added to the spec (for introspection/tests).
void addProvides(Capability cap_r)
Add cap_r to the provides set.
SolvableSpec & operator=(const SolvableSpec &)=default
void splitParseFrom(std::string_view multispec_r)
Split multispec_r on ',', ' ', '\t' and parse each token.
void clear()
Reset to empty state.
A Solvable object within the sat Pool.
Definition solvable.h:65
std::unordered_set< IdString > IdStringSet
Definition IdString.h:37
This file contains private API, this might break at any time between releases.
std::unordered_set< Capability > CapabilitySet
Definition capability.h:35