libzypp 17.37.10

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
23#include <zypp/sat/SolvIterMixin.h>
24#include <zypp/sat/LookupAttr.h>
25#include <zypp/base/StrMatcher.h>
26#include <zypp/sat/Pool.h>
27
29 namespace zypp
30{
31
32 namespace detail
33 {
34 class PoolQueryIterator;
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
97 using const_iterator = detail::PoolQueryIterator;
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
174 enum StatusFilter {
175 ALL = 0, // both install filter and uninstall filter bits are 0
176 INSTALLED_ONLY = 1,
177 UNINSTALLED_ONLY = 2
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;
413 bool filesMatchBasename() 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
425 Match::Mode matchMode() const
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:
489 RW_pointer<Impl> _pimpl;
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:
530 PoolQueryIterator()
531 {}
532
534 PoolQueryIterator( const shared_ptr<PoolQueryMatcher> & matcher_r )
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
596 sat::Solvable dereference() const
597 { return base_reference().inSolvable(); }
598
599 void increment();
600
601 private:
602 const Matches & matches() const;
603
604 private:
605 shared_ptr<PoolQueryMatcher> _matcher;
606 mutable shared_ptr<Matches> _matches;
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
621 inline detail::PoolQueryIterator PoolQuery::end() const
622 { return detail::PoolQueryIterator(); }
623
625} // namespace zypp
627
628#endif // ZYPP_POOLQUERY_H
LookupAttr.h
Pool.h
SolvIterMixin.h
StrMatcher.h
Impl
bool
shared_ptr
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::Capability
A sat capability.
Definition Capability.h:63
zypp::Edition
Edition represents [epoch:]version[-release]
Definition Edition.h:61
zypp::Match
String matching option flags as used e.g.
Definition StrMatcher.h:33
zypp::Match::Mode
Mode
Mode flags (mutual exclusive).
Definition StrMatcher.h:41
zypp::PoolQuery::Impl
Definition PoolQuery.cc:417
zypp::PoolQuery
Meta-data query API.
Definition PoolQuery.h:91
zypp::PoolQuery::flags
Match flags() const
Free function to get libsolv repo search flags.
Definition PoolQuery.cc:969
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const Arch &arch)
Definition PoolQuery.h:327
zypp::PoolQuery::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PoolQuery.h:489
zypp::PoolQuery::dumpOn
std::ostream & dumpOn(std::ostream &str, const PoolQuery &obj) ZYPP_API
Detailed stream output.
Definition PoolQuery.cc:1498
zypp::PoolQuery::setComment
void setComment(const std::string &comment) const
Set an optional comment string describing the purpose of the query.
Definition PoolQuery.cc:879
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:320
zypp::PoolQuery::execute
void execute(ProcessResolvable fnc)
Executes the query with the current settings.
Definition PoolQuery.cc:1056
zypp::PoolQuery::empty
bool empty() const
Whether the result is empty.
Definition PoolQuery.cc:1036
zypp::PoolQuery::addKind
void addKind(const ResKind &kind)
Filter by selectable kind.
Definition PoolQuery.cc:876
zypp::PoolQuery::setFilesMatchBasename
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
zypp::PoolQuery::filesMatchBasename
bool filesMatchBasename() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition PoolQuery.h:413
zypp::PoolQuery::size_type
unsigned int size_type
Definition PoolQuery.h:98
zypp::PoolQuery::operator!=
bool operator!=(const PoolQuery &b) const
Definition PoolQuery.h:459
zypp::PoolQuery::ProcessResolvable
function< bool(const sat::Solvable &)> ProcessResolvable
Definition PoolQuery.h:101
zypp::PoolQuery::AttrRawStrMap
std::map< sat::SolvAttr, StrContainer > AttrRawStrMap
Definition PoolQuery.h:95
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:299
zypp::PoolQuery::comment
const std::string & comment() const
Definition PoolQuery.cc:1014
zypp::PoolQuery::filesMatchFullPath
bool filesMatchFullPath() const
Whether searching in filelists looks at the full path or just at the basenames.
Definition PoolQuery.cc:1022
zypp::PoolQuery::addRepo
void addRepo(const std::string &repoalias)
Filter by repo.
Definition PoolQuery.cc:866
zypp::PoolQuery::matchMode
Match::Mode matchMode() const
Returns string matching mode as enum.
Definition PoolQuery.h:425
zypp::PoolQuery::PoolQuery
PoolQuery()
Definition PoolQuery.cc:859
zypp::PoolQuery::edition
const Edition edition() const
Definition PoolQuery.cc:999
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const Rel &op, const Edition &edition, const Arch &arch)
Definition PoolQuery.h:313
zypp::PoolQuery::end
const_iterator end() const
An iterator pointing to the end of the query result.
Definition PoolQuery.h:621
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Arch &arch)
Definition PoolQuery.h:306
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const Edition &edition)
Definition PoolQuery.h:317
zypp::PoolQuery::StrContainer
std::set< std::string > StrContainer
Definition PoolQuery.h:94
zypp::PoolQuery::size
size_type size() const
Number of solvables in the query result.
Definition PoolQuery.cc:1043
zypp::PoolQuery::begin
const_iterator begin() const
Query result accessers.
Definition PoolQuery.cc:1855
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const Rel &op, const Edition &edition)
Definition PoolQuery.h:310
zypp::PoolQuery::addDependency
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
zypp::PoolQuery::const_iterator
detail::PoolQueryIterator const_iterator
Definition PoolQuery.h:97
zypp::PoolQuery::StatusFilter
StatusFilter
Installed status filter setters.
Definition PoolQuery.h:174
zypp::PoolQuery::UNINSTALLED_ONLY
@ UNINSTALLED_ONLY
Definition PoolQuery.h:177
zypp::PoolQuery::ALL
@ ALL
Definition PoolQuery.h:175
zypp::PoolQuery::INSTALLED_ONLY
@ INSTALLED_ONLY
Definition PoolQuery.h:176
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr)
Definition PoolQuery.h:324
zypp::PoolQuery::setFilesMatchFullPath
void setFilesMatchFullPath(bool value=true)
If set (default), look at the full path when searching in filelists.
Definition PoolQuery.cc:1024
zypp::PoolQuery::Kinds
std::set< ResKind > Kinds
Definition PoolQuery.h:93
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const std::string &name, const Edition &edition)
Definition PoolQuery.h:296
zypp::PoolQuery::addDependency
void addDependency(const sat::SolvAttr &attr, const std::string &name)
Definition PoolQuery.h:303
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::detail::PoolQueryIterator
PoolQuery iterator as returned by PoolQuery::begin.
Definition PoolQuery.h:523
zypp::detail::PoolQueryIterator::matches
const Matches & matches() const
Definition PoolQuery.cc:1821
zypp::detail::PoolQueryIterator::dereference
sat::Solvable dereference() const
Definition PoolQuery.h:596
zypp::detail::PoolQueryIterator::matchesSize
size_type matchesSize() const
Number of attribute matches.
Definition PoolQuery.h:586
zypp::detail::PoolQueryIterator::increment
void increment()
Definition PoolQuery.cc:1808
zypp::detail::PoolQueryIterator::matchesEnd
matches_iterator matchesEnd() const
End of matches.
Definition PoolQuery.h:590
zypp::detail::PoolQueryIterator::matchesEmpty
bool matchesEmpty() const
False unless this is the end iterator.
Definition PoolQuery.h:584
zypp::detail::PoolQueryIterator::_matches
shared_ptr< Matches > _matches
Definition PoolQuery.h:606
zypp::detail::PoolQueryIterator::matchesBegin
matches_iterator matchesBegin() const
Begin of matches.
Definition PoolQuery.h:588
zypp::detail::PoolQueryIterator::size_type
Matches::size_type size_type
Definition PoolQuery.h:526
zypp::detail::PoolQueryIterator::_matcher
shared_ptr< PoolQueryMatcher > _matcher
Definition PoolQuery.h:605
zypp::detail::PoolQueryIterator::matches_iterator
Matches::const_iterator matches_iterator
Definition PoolQuery.h:527
zypp::detail::PoolQueryIterator::Matches
std::vector< sat::LookupAttr::iterator > Matches
Definition PoolQuery.h:524
zypp::detail::PoolQueryIterator::operator<<
std::ostream & operator<<(std::ostream &str, const PoolQueryIterator &obj)
Stream output.
Definition PoolQuery.h:611
zypp::detail::PoolQueryIterator::PoolQueryIterator
PoolQueryIterator()
Default ctor is also end.
Definition PoolQuery.h:530
zypp::detail::PoolQueryIterator::PoolQueryIterator
PoolQueryIterator(const shared_ptr< PoolQueryMatcher > &matcher_r)
\Ref PoolQuery ctor.
Definition PoolQuery.h:534
zypp::sat::SolvAttr
Solvable attribute keys.
Definition SolvAttr.h:41
zypp::sat::SolvIterMixin
Base class providing common iterator types based on a Solvable iterator.
Definition SolvIterMixin.h:117
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
b
unsigned short b
Definition mediablocklist.cc:1
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::detail
Definition PoolQuery.cc:1509
zypp::solver::detail
Definition PoolImpl.h:110
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator<
bool operator<(const StrMatcher &lhs, const StrMatcher &rhs)
Definition StrMatcher.cc:340
zypp::operator==
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...
Definition SetRelationMixin.h:84
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
zypp::kind
const ResKind ResTraits< Package >::kind(ResKind::package)
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::Rel
Relational operators.
Definition Rel.h:46
zypp::Rel::ANY
static const Rel ANY
Definition Rel.h:58
zypp::Rel::EQ
static const Rel EQ
Definition Rel.h:52
ZYPP_DEPRECATED
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition Globals.h:112
Function.h
PtrTypes.h
Regex.h