#include <PoolQuery.h>
enum | StatusFilter { ALL = 0, INSTALLED_ONLY = 1, UNINSTALLED_ONLY = 2 } |
Installed status filter setters. More... | |
void | setInstalledOnly () |
Return only repo packages. | |
void | setUninstalledOnly () |
Return only packages from repos other than . | |
void | setStatusFilterFlags (StatusFilter flags) |
Set status filter directly. | |
Public Types | |
typedef std::set< ResKind > | Kinds |
typedef std::set< std::string > | StrContainer |
typedef std::map < sat::SolvAttr, StrContainer > | AttrRawStrMap |
typedef detail::PoolQueryIterator | const_iterator |
typedef unsigned int | size_type |
typedef function< bool(const sat::Solvable &)> | ProcessResolvable |
Public Member Functions | |
PoolQuery () | |
~PoolQuery () | |
void | execute (ProcessResolvable fnc) |
Executes the query with the current settings. | |
void | addKind (const ResKind &kind) |
Filter by selectable kind. | |
void | addRepo (const std::string &repoalias) |
Filter by repo. | |
void | addString (const std::string &value) |
Add a global query string. | |
void | addAttribute (const sat::SolvAttr &attr, const std::string &value="") |
Filter by the value of the specified attr attribute. | |
void | setEdition (const Edition &edition, const Rel &op=Rel::EQ) |
Set version condition. | |
void | setRequireAll (bool require_all=true) |
Require that all of the values set by addString or addAttribute match the values of respective attributes. | |
bool | recover (std::istream &str, char delim= '\n') |
Reads from stream query. | |
void | serialize (std::ostream &str, char delim= '\n') const |
Writes a machine-readable string representation of the query to stream. | |
std::string | asString () const |
Return a human-readable description of the query. | |
bool | operator== (const PoolQuery &b) const |
bool | operator!= (const PoolQuery &b) const |
Match | flags () const |
Free function to get the satsolver repo search flags. | |
void | setFlags (const Match &flags) |
Free function to set the satsolver repo search flags. | |
const_iterator | begin () const |
Query result accessers. | |
const_iterator | end () const |
An iterator pointing to the end of the query result. | |
bool | empty () const |
Whether the result is empty. | |
size_type | size () const |
Number of solvables in the query result. | |
Filter by dependencies matching a broken down capability <tt>name [op edition]</tt> and/or architecture. | |
The capabilities name part may be defined as query string like with addAttribute.Globing and regex are supported. Global query strings defined by addString are considered.
So without any
An optional
{ setMatchGlob(); setCaseSensitive( false ); addDependency( sat::SolvAttr::provides, "kde*", Rel::EQ, Edition("2.0") ); addDependency( sat::SolvAttr::provides, "kde*", Edition("2.0") ); // same as above } { setMatchGlob(); setCaseSensitive( false ); addString( "kde*" ); addDependency( sat::SolvAttr::provides, Rel::EQ, Edition("2.0") );// same as above addDependency( sat::SolvAttr::provides, Edition("2.0") ); // same as above }
SolvAttr::provides SolvAttr::obsoletes SolvAttr::conflicts SolvAttr::requires SolvAttr::recommends SolvAttr::suggests SolvAttr::supplements SolvAttr::enhances
// Find all packages providing "kernel > 2.0" addDependency( sat::SolvAttr::provides, "kernel", Rel::GT, Edition("2.0") ); // // Find all packages named "kernel" and with edition "> 2.0" addDependency( sat::SolvAttr::name, "kernel", Rel::GT, Edition("2.0") ); | |
void | addDependency (const sat::SolvAttr &attr, const std::string &name, const Rel &op, const Edition &edition) |
Query "name|global op edition" . | |
void | addDependency (const sat::SolvAttr &attr, const std::string &name, const Rel &op, const Edition &edition, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr, const std::string &name, const Edition &edition) |
void | addDependency (const sat::SolvAttr &attr, const std::string &name, const Edition &edition, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr, const std::string &name) |
void | addDependency (const sat::SolvAttr &attr, const std::string &name, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr, const Rel &op, const Edition &edition) |
void | addDependency (const sat::SolvAttr &attr, const Rel &op, const Edition &edition, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr, const Edition &edition) |
void | addDependency (const sat::SolvAttr &attr, const Edition &edition, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr) |
void | addDependency (const sat::SolvAttr &attr, const Arch &arch) |
void | addDependency (const sat::SolvAttr &attr, Capability cap_r) |
Text Matching Options | |
| |
void | setCaseSensitive (bool value=true) |
Turn case sentitivity on or off (unsets or sets SEARCH_NOCASE flag). | |
void | setFilesMatchFullPath (bool value=true) |
If set (default), look at the full path when searching in filelists. | |
void | setFilesMatchBasename (bool value=true) |
void | setMatchExact () |
Set to match exact string instead of substring. | |
void | setMatchSubstring () |
Set to substring (the default). | |
void | setMatchGlob () |
Set to match globs. | |
void | setMatchRegex () |
Set to use the query strings as regexes. | |
void | setMatchWord () |
Set to match words (uses regex). | |
getters | |
const StrContainer & | strings () const |
Search strings added via addString(). | |
const AttrRawStrMap & | attributes () const |
Map (map<SolvAttr, StrContainer>) of attribute values added via addAttribute(), addDep in string form. | |
const StrContainer & | attribute (const sat::SolvAttr &attr) const |
const Kinds & | kinds () const |
const StrContainer & | repos () const |
const Edition | edition () const |
const Rel | editionRel () const |
bool | caseSensitive () const |
returns true if search is case sensitive | |
bool | filesMatchFullPath () const |
Whether searching in filelists looks at the full path or just at the basenames. | |
bool | filesMatchBasename () const |
bool | matchExact () const |
bool | matchSubstring () const |
bool | matchGlob () const |
bool | matchRegex () const |
bool | matchWord () const |
Match::Mode | matchMode () const |
Returns string matching mode as enum. | |
bool | requireAll () const |
Whether all values added via addString() or addAttribute() are required to match the values of the respective attributes. | |
StatusFilter | statusFilterFlags () const |
Private Attributes | |
RW_pointer< Impl > | _pimpl |
Pointer to implementation. | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &str, const PoolQuery &obj) |
std::ostream & | dumpOn (std::ostream &str, const PoolQuery &obj) |
Classes | |
class | Impl |
Returns solvables of specified kinds from specified repositories with attributes matching the specified search strings.
The search strings can be specified via addString() and addAttribute() methods. String matching type can be set using the setMatch*() methods. Multiple search strings for a particular attribute will be combined into a regex (see addString() and addAttribute() for more details).
The begin() and end() methods return a PoolQueryIterator returning sat::Solvable objects which can easily be turned into Resolvable objects. Additionally, thanx to the sat::SolvIterMixin, a Selectable and PoolItem iterators are automatically available.
PoolQuery q; q.addAttribute(sat::SolvAttr::name, "zypp*"); q.addKind(ResKind::package); q.setMatchGlob();
for (PoolQuery::Selectable_iterator it = q.selectableBegin(); it != q.selectableEnd(); ++it) { ui::Selectable::constPtr s = *it; // ... }
Performance considerations
Results of simple queries like those using one string and/or one attribute and/or one repository are filtered by sat-solver's Dataiterator directly, and thus it is fast.
Queries with multiple strings are implemented using regexes. Queries based on kinds, multiple repos, and multiple attributes are filtered inside the PoolQuery, so these tend to be slower.
tests/zypp/PoolQuery_test.cc for more examples
Definition at line 90 of file PoolQuery.h.
typedef std::set<ResKind> zypp::PoolQuery::Kinds |
Definition at line 93 of file PoolQuery.h.
typedef std::set<std::string> zypp::PoolQuery::StrContainer |
Definition at line 94 of file PoolQuery.h.
typedef std::map<sat::SolvAttr, StrContainer> zypp::PoolQuery::AttrRawStrMap |
Definition at line 95 of file PoolQuery.h.
Definition at line 97 of file PoolQuery.h.
typedef unsigned int zypp::PoolQuery::size_type |
Reimplemented from zypp::sat::SolvIterMixin< Derived, DerivedSolvable_iterator >.
Definition at line 98 of file PoolQuery.h.
typedef function<bool( const sat::Solvable & )> zypp::PoolQuery::ProcessResolvable |
Definition at line 101 of file PoolQuery.h.
Installed status filter setters.
Filter by status (installed uninstalled)
Definition at line 162 of file PoolQuery.h.
zypp::PoolQuery::PoolQuery | ( | ) |
Definition at line 831 of file PoolQuery.cc.
zypp::PoolQuery::~PoolQuery | ( | ) |
Definition at line 835 of file PoolQuery.cc.
detail::PoolQueryIterator zypp::PoolQuery::begin | ( | ) | const |
Query result accessers.
Compile the query and return an iterator to the result.
sat::MatchInvalidRegexException | if the query was about to use a regex which failed to compile. |
Definition at line 1737 of file PoolQuery.cc.
References _pimpl.
Referenced by zypp::Locks::addLock(), zypp::LocksRemovePredicate::contains(), zypp::dumpOn(), empty(), execute(), zypp::ApplyLock::operator()(), zypp::PoolQueryResult::operator+=(), zypp::PoolQueryResult::operator-=(), zypp::Locks::removeLock(), and size().
detail::PoolQueryIterator zypp::PoolQuery::end | ( | ) | const [inline] |
An iterator pointing to the end of the query result.
Definition at line 616 of file PoolQuery.h.
Referenced by zypp::Locks::addLock(), zypp::detail::PoolQueryMatcher::advance(), zypp::LocksRemovePredicate::contains(), zypp::dumpOn(), empty(), execute(), zypp::detail::PoolQueryMatcher::matchDetail(), zypp::ApplyLock::operator()(), zypp::PoolQueryResult::operator+=(), zypp::PoolQueryResult::operator-=(), zypp::Locks::removeLock(), and size().
bool zypp::PoolQuery::empty | ( | ) | const |
Whether the result is empty.
Reimplemented from zypp::sat::SolvIterMixin< Derived, DerivedSolvable_iterator >.
Definition at line 997 of file PoolQuery.cc.
References begin(), and end().
Referenced by zypp::LocksCleanPredicate::operator()().
PoolQuery::size_type zypp::PoolQuery::size | ( | ) | const |
Number of solvables in the query result.
Reimplemented from zypp::sat::SolvIterMixin< Derived, DerivedSolvable_iterator >.
Definition at line 1004 of file PoolQuery.cc.
void zypp::PoolQuery::execute | ( | ProcessResolvable | fnc | ) |
Executes the query with the current settings.
Results are yielded via the fnc callback.
Definition at line 1017 of file PoolQuery.cc.
References begin(), end(), and zypp::invokeOnEach().
void zypp::PoolQuery::addKind | ( | const ResKind & | kind | ) |
Filter by selectable kind.
By default, all kinds will be returned. If addKind() is used, only the specified kinds will be returned (multiple kinds will be ORed).
Pass ResKind constants to this method, (e.g. ResKind::package).
Definition at line 848 of file PoolQuery.cc.
References _pimpl.
Referenced by zypp::Locks::addLock(), zypp::makeTrivialQuery(), and zypp::Locks::removeLock().
void zypp::PoolQuery::addRepo | ( | const std::string & | repoalias | ) |
void zypp::PoolQuery::setInstalledOnly | ( | ) |
Return only repo packages.
Definition at line 930 of file PoolQuery.cc.
References _pimpl, and INSTALLED_ONLY.
void zypp::PoolQuery::setUninstalledOnly | ( | ) |
Return only packages from repos other than .
Definition at line 932 of file PoolQuery.cc.
References _pimpl, and UNINSTALLED_ONLY.
void zypp::PoolQuery::setStatusFilterFlags | ( | PoolQuery::StatusFilter | flags | ) |
Set status filter directly.
Definition at line 934 of file PoolQuery.cc.
References _pimpl.
void zypp::PoolQuery::addString | ( | const std::string & | value | ) |
Add a global query string.
The string added via this method is applied to all query attributes as if addAttribute(..., ) was called for all of them.
This method can be used multiple times in which case the query strings will be combined (together with strings added via addAttribute()) into a regex. Searched attribute value will match this regex if any of these strings will match the value. This can be changed by (not yet implemented) setRequireAll() method.
void zypp::PoolQuery::addAttribute | ( | const sat::SolvAttr & | attr, | |
const std::string & | value = "" | |||
) |
Filter by the value of the specified attr attribute.
This can be any of the available solvable attributes.
This method can be used multiple times with the same attr in which case the query strings will be combined (together with strings added via addString()) into a regex. Searched attribute value will match this regex if any of these strings will match the value. This can be changed by (not yet implemented) setRequireAll() method.
"name"
part only. Any "op edition"
part of a Capability is not considered at all. attr | Attribute identfier. Use sat::Solvattr::* constants | |
value | What to search for. |
Definition at line 854 of file PoolQuery.cc.
References _pimpl.
Referenced by addDependency(), zypp::Locks::addLock(), zypp::makeTrivialQuery(), and zypp::Locks::removeLock().
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name, | |||
const Rel & | op, | |||
const Edition & | edition | |||
) |
Query "name|global op edition"
.
Definition at line 857 of file PoolQuery.cc.
References zypp::Arch_empty.
Referenced by addDependency().
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name, | |||
const Rel & | op, | |||
const Edition & | edition, | |||
const Arch & | arch | |||
) |
Definition at line 860 of file PoolQuery.cc.
References _pimpl, addAttribute(), zypp::Rel::ANY_e, zypp::Arch::empty(), zypp::Rel::inSwitch(), zypp::isDependencyAttribute(), zypp::Rel::NONE_e, and zypp::Match::OTHER.
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name, | |||
const Edition & | edition | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name, | |||
const Edition & | edition, | |||
const Arch & | arch | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const std::string & | name, | |||
const Arch & | arch | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const Rel & | op, | |||
const Edition & | edition | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const Rel & | op, | |||
const Edition & | edition, | |||
const Arch & | arch | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const Edition & | edition | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const Edition & | edition, | |||
const Arch & | arch | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr | ) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
const Arch & | arch | |||
) | [inline] |
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, | |
Capability | cap_r | |||
) |
Definition at line 891 of file PoolQuery.cc.
References _pimpl, zypp::IdString::asString(), zypp::CapDetail::ed(), zypp::isDependencyAttribute(), zypp::CapDetail::isSimple(), zypp::CapDetail::name(), and zypp::CapDetail::op().
Set version condition.
This will filter out solvables not matching solvableEdition op edition
.
edition | Edition to look for. | |
op | Found-wanted relation operator. |
Definition at line 908 of file PoolQuery.cc.
References _pimpl.
void zypp::PoolQuery::setCaseSensitive | ( | bool | value = true |
) |
Turn case sentitivity on or off (unsets or sets SEARCH_NOCASE flag).
PoolQuery defaults to case insensitive search unless this method is used.
value | Whether to turn the case sensitivity on (default) or off. |
Definition at line 975 of file PoolQuery.cc.
References _pimpl, and zypp::Match::NOCASE.
Referenced by zypp::Locks::addLock(), zypp::makeTrivialQuery(), and zypp::Locks::removeLock().
void zypp::PoolQuery::setFilesMatchFullPath | ( | bool | value = true |
) |
If set (default), look at the full path when searching in filelists.
Otherwise just match the the basenames.
Definition at line 980 of file PoolQuery.cc.
References _pimpl, and zypp::Match::FILES.
Referenced by setFilesMatchBasename().
void zypp::PoolQuery::setFilesMatchBasename | ( | bool | value = true |
) | [inline] |
void zypp::PoolQuery::setMatchExact | ( | ) |
Set to match exact string instead of substring.
Definition at line 915 of file PoolQuery.cc.
References _pimpl.
Referenced by zypp::Locks::addLock(), zypp::makeTrivialQuery(), and zypp::Locks::removeLock().
void zypp::PoolQuery::setMatchSubstring | ( | ) |
void zypp::PoolQuery::setMatchGlob | ( | ) |
void zypp::PoolQuery::setMatchRegex | ( | ) |
Set to use the query strings as regexes.
Definition at line 916 of file PoolQuery.cc.
References _pimpl.
void zypp::PoolQuery::setMatchWord | ( | ) |
void zypp::PoolQuery::setRequireAll | ( | bool | require_all = true |
) |
Require that all of the values set by addString or addAttribute match the values of respective attributes.
Definition at line 938 of file PoolQuery.cc.
References _pimpl.
const PoolQuery::StrContainer & zypp::PoolQuery::strings | ( | ) | const |
Search strings added via addString().
Definition at line 943 of file PoolQuery.cc.
References _pimpl.
const PoolQuery::AttrRawStrMap & zypp::PoolQuery::attributes | ( | ) | const |
Map (map<SolvAttr, StrContainer>) of attribute values added via addAttribute(), addDep in string form.
Definition at line 947 of file PoolQuery.cc.
References _pimpl.
const PoolQuery::StrContainer & zypp::PoolQuery::attribute | ( | const sat::SolvAttr & | attr | ) | const |
const PoolQuery::Kinds & zypp::PoolQuery::kinds | ( | ) | const |
const PoolQuery::StrContainer & zypp::PoolQuery::repos | ( | ) | const |
const Edition zypp::PoolQuery::edition | ( | ) | const |
const Rel zypp::PoolQuery::editionRel | ( | ) | const |
bool zypp::PoolQuery::caseSensitive | ( | ) | const |
returns true if search is case sensitive
Definition at line 973 of file PoolQuery.cc.
References _pimpl, and zypp::Match::NOCASE.
bool zypp::PoolQuery::filesMatchFullPath | ( | ) | const |
Whether searching in filelists looks at the full path or just at the basenames.
Definition at line 978 of file PoolQuery.cc.
References _pimpl, and zypp::Match::FILES.
Referenced by filesMatchBasename().
bool zypp::PoolQuery::filesMatchBasename | ( | ) | const [inline] |
bool zypp::PoolQuery::matchExact | ( | ) | const |
bool zypp::PoolQuery::matchSubstring | ( | ) | const |
bool zypp::PoolQuery::matchGlob | ( | ) | const |
bool zypp::PoolQuery::matchRegex | ( | ) | const |
bool zypp::PoolQuery::matchWord | ( | ) | const |
Match::Mode zypp::PoolQuery::matchMode | ( | ) | const [inline] |
Returns string matching mode as enum.
Definition at line 421 of file PoolQuery.h.
References flags(), and zypp::Match::mode().
bool zypp::PoolQuery::requireAll | ( | ) | const |
Whether all values added via addString() or addAttribute() are required to match the values of the respective attributes.
Definition at line 991 of file PoolQuery.cc.
References _pimpl.
Referenced by zypp::Locks::removeLock().
PoolQuery::StatusFilter zypp::PoolQuery::statusFilterFlags | ( | ) | const |
bool zypp::PoolQuery::recover | ( | std::istream & | str, | |
char | delim = '\n' | |||
) |
Reads from stream query.
Attributes is sepated by delim. Query is separated by two delim.
str | input stream which contains query | |
delim | delimeter for attributes |
Referenced by zypp::readPoolQueriesFromFile().
void zypp::PoolQuery::serialize | ( | std::ostream & | str, | |
char | delim = '\n' | |||
) | const |
Writes a machine-readable string representation of the query to stream.
Use delim as attribute delimiter.
str | output stream to write to | |
delim | delimiter for attributes |
string zypp::PoolQuery::asString | ( | ) | const |
Return a human-readable description of the query.
Definition at line 1402 of file PoolQuery.cc.
References _pimpl.
Referenced by zypp::operator<<().
bool zypp::PoolQuery::operator== | ( | const PoolQuery & | b | ) | const |
bool zypp::PoolQuery::operator!= | ( | const PoolQuery & | b | ) | const [inline] |
Definition at line 460 of file PoolQuery.h.
Match zypp::PoolQuery::flags | ( | ) | const |
Free function to get the satsolver repo search flags.
Definition at line 924 of file PoolQuery.cc.
References _pimpl.
Referenced by matchMode().
void zypp::PoolQuery::setFlags | ( | const Match & | flags | ) |
Free function to set the satsolver repo search flags.
Definition at line 926 of file PoolQuery.cc.
References _pimpl.
std::ostream & operator<< | ( | std::ostream & | str, | |
const PoolQuery & | obj | |||
) | [related] |
Stream output.
std::ostream & dumpOn | ( | std::ostream & | str, | |
const PoolQuery & | obj | |||
) | [related] |
Detailed stream output.
Definition at line 1408 of file PoolQuery.cc.
RW_pointer<Impl> zypp::PoolQuery::_pimpl [private] |
Pointer to implementation.
Definition at line 481 of file PoolQuery.h.
Referenced by addAttribute(), addDependency(), addKind(), addRepo(), asString(), attribute(), attributes(), begin(), caseSensitive(), edition(), editionRel(), filesMatchFullPath(), flags(), kinds(), matchExact(), matchGlob(), matchRegex(), matchSubstring(), matchWord(), operator==(), repos(), requireAll(), setCaseSensitive(), setEdition(), setFilesMatchFullPath(), setFlags(), setInstalledOnly(), setMatchExact(), setMatchGlob(), setMatchRegex(), setMatchSubstring(), setMatchWord(), setRequireAll(), setStatusFilterFlags(), setUninstalledOnly(), statusFilterFlags(), and strings().