libzypp 17.37.17
PoolQuery.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_POOLQUERY_H
13#define ZYPP_POOLQUERY_H
14
15#include <iosfwd>
16#include <set>
17#include <map>
18
19#include <zypp/base/Regex.h>
20#include <zypp/base/PtrTypes.h>
21#include <zypp/base/Function.h>
22
24#include <zypp/sat/LookupAttr.h>
26#include <zypp/sat/Pool.h>
27
29namespace zypp
30{
31
32 namespace detail
33 {
35 }
36
38 //
39 // CLASS NAME : PoolQuery
40 //
90 class ZYPP_API PoolQuery : public sat::SolvIterMixin<PoolQuery, detail::PoolQueryIterator>
91 {
92 public:
93 using Kinds = std::set<ResKind>;
94 using StrContainer = std::set<std::string>;
95 using AttrRawStrMap = std::map<sat::SolvAttr, StrContainer>;
96
98 using size_type = unsigned int;
99
100 public:
101 using ProcessResolvable = function<bool (const sat::Solvable &)>;
102
103 PoolQuery();
104 ~PoolQuery();
105
108
120 const_iterator begin() const;
121
123 const_iterator end() const;
124
126 bool empty() const;
127
129 size_type size() const;
131
136 void execute(ProcessResolvable fnc);
137
153 void addKind(const ResKind & kind);
154
161 void addRepo(const std::string &repoalias);
162
166 void setComment(const std::string & comment) const;
167
170
175 ALL = 0, // both install filter and uninstall filter bits are 0
178 };
179
181 void setInstalledOnly();
183 void setUninstalledOnly();
185 void setStatusFilterFlags( StatusFilter flags );
186
188
199 void addString(const std::string & value);
200
226 void addAttribute( const sat::SolvAttr & attr, const std::string & value = "" );
227
288
289 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Rel & op, const Edition & edition );
291 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Rel & op, const Edition & edition, const Arch & arch );
293 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Rel & op, const Edition & edition, const Arch & arch, Match::Mode mode );
294
296 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Edition & edition )
297 { addDependency( attr, name, Rel::EQ, edition ); }
298
299 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Edition & edition, const Arch & arch )
300 { addDependency( attr, name, Rel::EQ, edition, arch ); }
301
303 void addDependency( const sat::SolvAttr & attr, const std::string & name )
304 { addDependency( attr, name, Rel::ANY, Edition() ); }
305
306 void addDependency( const sat::SolvAttr & attr, const std::string & name, const Arch & arch )
307 { addDependency( attr, name, Rel::ANY, Edition(), arch ); }
308
310 void addDependency( const sat::SolvAttr & attr, const Rel & op, const Edition & edition )
311 { addDependency( attr, std::string(), op, edition ); }
312
313 void addDependency( const sat::SolvAttr & attr, const Rel & op, const Edition & edition, const Arch & arch )
314 { addDependency( attr, std::string(), op, edition, arch ); }
315
317 void addDependency( const sat::SolvAttr & attr, const Edition & edition )
318 { addDependency( attr, std::string(), Rel::EQ, edition ); }
319
320 void addDependency( const sat::SolvAttr & attr, const Edition & edition, const Arch & arch )
321 { addDependency( attr, std::string(), Rel::EQ, edition, arch ); }
322
324 void addDependency( const sat::SolvAttr & attr )
325 { addDependency( attr, std::string(), Rel::ANY, Edition() ); }
326
327 void addDependency( const sat::SolvAttr & attr, const Arch & arch )
328 { addDependency( attr, std::string(), Rel::ANY, Edition(), arch ); }
329
334 void addDependency( const sat::SolvAttr & attr, Capability cap_r );
336
344 void setEdition(const Edition & edition, const Rel & op = Rel::EQ);
345
352
359 void setCaseSensitive( bool value = true );
360
366 void setFilesMatchFullPath( bool value = true );
368 void setFilesMatchBasename( bool value = true )
369 { setFilesMatchFullPath( !value ); }
370
372 void setMatchExact();
374 void setMatchSubstring();
376 void setMatchGlob();
378 void setMatchRegex();
380 void setMatchWord();
381 //void setLocale(const Locale & locale);
383
386
388 const StrContainer & strings() const;
392 const AttrRawStrMap & attributes() const;
393
394 const StrContainer & attribute(const sat::SolvAttr & attr) const;
395
396 const Kinds & kinds() const;
397
398 const StrContainer & repos() const;
399
400 const std::string & comment() const;
401
402 const Edition edition() const;
403 const Rel editionRel() const;
404
408 bool caseSensitive() const;
409
411 bool filesMatchFullPath() const;
414 { return !filesMatchFullPath(); }
415
416 bool matchExact() const;
417 bool matchSubstring() const;
418 bool matchGlob() const;
419 bool matchRegex() const;
420 bool matchWord() const;
421
426 { return flags().mode(); }
427
428 StatusFilter statusFilterFlags() const;
430
441 bool recover( std::istream &str, char delim = '\n' );
442
452 void serialize( std::ostream &str, char delim = '\n' ) const;
453
455 std::string asString() const;
456
457 bool operator<(const PoolQuery& b) const;
458 bool operator==(const PoolQuery& b) const;
459 bool operator!=(const PoolQuery& b) const { return !(*this == b ); }
460
461 // low level API
462
469 Match flags() const;
470
477 void setFlags( const Match & flags );
478
479 public:
481 void setRequireAll( bool require_all = true ) ZYPP_DEPRECATED;
483 bool requireAll() const ZYPP_DEPRECATED;
484
485 public:
486 class Impl;
487 private:
490 };
491
492
494 std::ostream & operator<<( std::ostream & str, const PoolQuery & obj ) ZYPP_API;
495
497 std::ostream & dumpOn( std::ostream & str, const PoolQuery & obj ) ZYPP_API;
498
500 namespace detail
501 {
502
503 class PoolQueryMatcher;
504
506 //
507 // CLASS NAME : PoolQuery::PoolQueryIterator
508 //
516 class ZYPP_API PoolQueryIterator : public boost::iterator_adaptor<
517 PoolQueryIterator // Derived
518 , sat::LookupAttr::iterator // Base
519 , const sat::Solvable // Value
520 , boost::forward_traversal_tag // CategoryOrTraversal
521 , const sat::Solvable // Reference
522 >
523 {
524 using Matches = std::vector<sat::LookupAttr::iterator>;
525 public:
526 using size_type = Matches::size_type;
527 using matches_iterator = Matches::const_iterator;
528 public:
532
535 : _matcher( matcher_r )
536 { increment(); }
537
583
584 bool matchesEmpty() const { return ! _matcher; }
586 size_type matchesSize() const { return matches().size(); }
588 matches_iterator matchesBegin() const { return matches().begin(); }
590 matches_iterator matchesEnd() const { return matches().end(); }
592
593 private:
594 friend class boost::iterator_core_access;
595
597 { return base_reference().inSolvable(); }
598
599 void increment();
600
601 private:
602 const Matches & matches() const;
603
604 private:
607 };
608
609
611 inline std::ostream & operator<<( std::ostream & str, const PoolQueryIterator & obj )
612 { return str << obj.base(); }
613
615 std::ostream & dumpOn( std::ostream & str, const PoolQueryIterator & obj ) ZYPP_API;
616
618 } //namespace detail
620
623
625} // namespace zypp
627
628#endif // ZYPP_POOLQUERY_H
Architecture.
Definition Arch.h:37
A sat capability.
Definition Capability.h:63
Edition represents [epoch:]version[-release]
Definition Edition.h:61
String matching option flags as used e.g.
Definition StrMatcher.h:33
Mode
Mode flags (mutual exclusive).
Definition StrMatcher.h:41
Meta-data query API.
Definition PoolQuery.h:91
Match flags() const
Free function to get libsolv repo search flags.
Definition PoolQuery.cc:969
void addDependency(const sat::SolvAttr &attr, const Arch &arch)
Definition PoolQuery.h:327
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PoolQuery.h:489
std::ostream & dumpOn(std::ostream &str, const PoolQuery &obj) ZYPP_API
Detailed stream output.
void setComment(const std::string &comment) const
Set an optional comment string describing the purpose of the query.
Definition PoolQuery.cc:879
void addDependency(const sat::SolvAttr &attr, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:320
void execute(ProcessResolvable fnc)
Executes the query with the current settings.
bool empty() const
Whether the result is empty.
void addKind(const ResKind &kind)
Filter by selectable kind.
Definition PoolQuery.cc:876
void setFilesMatchBasename(bool value=true)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition PoolQuery.h:368
bool filesMatchBasename() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition PoolQuery.h:413
unsigned int size_type
Definition PoolQuery.h:98
bool operator!=(const PoolQuery &b) const
Definition PoolQuery.h:459
function< bool(const sat::Solvable &)> ProcessResolvable
Definition PoolQuery.h:101
std::map< sat::SolvAttr, StrContainer > AttrRawStrMap
Definition PoolQuery.h:95
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:299
const std::string & comment() const
bool filesMatchFullPath() const
Whether searching in filelists looks at the full path or just at the basenames.
void addRepo(const std::string &repoalias)
Filter by repo.
Definition PoolQuery.cc:866
Match::Mode matchMode() const
Returns string matching mode as enum.
Definition PoolQuery.h:425
const Edition edition() const
Definition PoolQuery.cc:999
void addDependency(const sat::SolvAttr &attr, const Rel &op, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:313
const_iterator end() const
An iterator pointing to the end of the query result.
Definition PoolQuery.h:621
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Arch &arch)
Definition PoolQuery.h:306
void addDependency(const sat::SolvAttr &attr, const Edition &edition)
Definition PoolQuery.h:317
std::set< std::string > StrContainer
Definition PoolQuery.h:94
size_type size() const
Number of solvables in the query result.
const_iterator begin() const
Query result accessers.
void addDependency(const sat::SolvAttr &attr, const Rel &op, const Edition &edition)
Definition PoolQuery.h:310
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Rel &op, const Edition &edition)
Query "name|global op edition".
Definition PoolQuery.cc:888
detail::PoolQueryIterator const_iterator
Definition PoolQuery.h:97
StatusFilter
Installed status filter setters.
Definition PoolQuery.h:174
void addDependency(const sat::SolvAttr &attr)
Definition PoolQuery.h:324
void setFilesMatchFullPath(bool value=true)
If set (default), look at the full path when searching in filelists.
std::set< ResKind > Kinds
Definition PoolQuery.h:93
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Edition &edition)
Definition PoolQuery.h:296
void addDependency(const sat::SolvAttr &attr, const std::string &name)
Definition PoolQuery.h:303
Resolvable kinds.
Definition ResKind.h:33
PoolQuery iterator as returned by PoolQuery::begin.
Definition PoolQuery.h:523
const Matches & matches() const
sat::Solvable dereference() const
Definition PoolQuery.h:596
size_type matchesSize() const
Number of attribute matches.
Definition PoolQuery.h:586
matches_iterator matchesEnd() const
End of matches.
Definition PoolQuery.h:590
bool matchesEmpty() const
False unless this is the end iterator.
Definition PoolQuery.h:584
shared_ptr< Matches > _matches
Definition PoolQuery.h:606
matches_iterator matchesBegin() const
Begin of matches.
Definition PoolQuery.h:588
Matches::size_type size_type
Definition PoolQuery.h:526
shared_ptr< PoolQueryMatcher > _matcher
Definition PoolQuery.h:605
Matches::const_iterator matches_iterator
Definition PoolQuery.h:527
std::vector< sat::LookupAttr::iterator > Matches
Definition PoolQuery.h:524
std::ostream & operator<<(std::ostream &str, const PoolQueryIterator &obj)
Stream output.
Definition PoolQuery.h:611
PoolQueryIterator()
Default ctor is also end.
Definition PoolQuery.h:530
PoolQueryIterator(const shared_ptr< PoolQueryMatcher > &matcher_r)
\Ref PoolQuery ctor.
Definition PoolQuery.h:534
Solvable attribute keys.
Definition SolvAttr.h:41
Base class providing common iterator types based on a Solvable iterator.
A Solvable object within the sat Pool.
Definition Solvable.h:54
unsigned short b
Definition Arch.h:364
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
const ResKind ResTraits< Package >::kind(ResKind::package)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
Relational operators.
Definition Rel.h:46
static const Rel ANY
Definition Rel.h:58
static const Rel EQ
Definition Rel.h:52
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition Globals.h:112