libzypp 17.37.17
|
Meta-data query API. More...
#include <zypp/PoolQuery.h>
Classes | |
class | Impl |
Public Types | |
enum | StatusFilter { ALL = 0 , INSTALLED_ONLY = 1 , UNINSTALLED_ONLY = 2 } |
Installed status filter setters. More... | |
using | Kinds = std::set<ResKind> |
using | StrContainer = std::set<std::string> |
using | AttrRawStrMap = std::map<sat::SolvAttr, StrContainer> |
using | const_iterator = detail::PoolQueryIterator |
using | size_type = unsigned int |
using | ProcessResolvable = function<bool (const sat::Solvable &)> |
Public Types inherited from zypp::sat::SolvIterMixin< PoolQuery, detail::PoolQueryIterator > | |
using | size_type |
using | Solvable_iterator |
using | PoolItem_iterator |
using | Selectable_iterator |
Public Member Functions | |
PoolQuery () | |
~PoolQuery () | |
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. | |
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 | setComment (const std::string &comment) const |
Set an optional comment string describing the purpose of the query. | |
void | setInstalledOnly () |
Return only @System repo packages. | |
void | setUninstalledOnly () |
Return only packages from repos other than @System. | |
void | setStatusFilterFlags (StatusFilter flags) |
Set status filter directly. | |
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. | |
Filter by dependencies matching a broken down capability <tt>name [op edition]</tt> and/or architecture. | |
The capabilities Globing and regex are supported. Global query strings defined by addString are considered. So without any op edition arch addDependency behaves the same as addAttribute. If an edition range is given, matches are restricted accordingly. There are various overloads, so pick the one you like best. An optional {
setMatchGlob();
setCaseSensitive( false );
}
{
setMatchGlob();
setCaseSensitive( false );
addString( "kde*" );
}
void setCaseSensitive(bool value=true) Turn case sentitivity on or off (unsets or sets SEARCH_NOCASE flag). Definition PoolQuery.cc:1019 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
This is the list of valid dependency attributes: SolvAttr::provides
SolvAttr::obsoletes
SolvAttr::conflicts
SolvAttr::requires
SolvAttr::recommends
SolvAttr::suggests
SolvAttr::supplements
SolvAttr::enhances
// Find all packages providing "kernel > 2.0"
// // Find all packages named "kernel" and with 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 Rel &op, const Edition &edition, const Arch &arch, Match::Mode mode) |
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) |
void | setEdition (const Edition &edition, const Rel &op=Rel::EQ) |
Set version condition. | |
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) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
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 substring to match words. | |
Public Member Functions inherited from zypp::sat::SolvIterMixin< PoolQuery, detail::PoolQueryIterator > | |
bool | empty () const |
Whether the collection is epmty. | |
size_type | size () const |
Size of the collection. | |
bool | contains (const TSolv &solv_r) const |
Whether collection contains a specific Solvable. | |
Solvable_iterator | solvableBegin () const |
Solvable_iterator | solvableEnd () const |
Iterable< Solvable_iterator > | solvable () const |
PoolItem_iterator | poolItemBegin () const |
PoolItem_iterator | poolItemEnd () const |
Iterable< PoolItem_iterator > | poolItem () const |
Selectable_iterator | selectableBegin () const |
Selectable_iterator | selectableEnd () const |
Iterable< Selectable_iterator > | selectable () const |
Related Symbols | |
(Note that these are not member symbols.) | |
std::ostream & | operator<< (std::ostream &str, const PoolQuery &obj) ZYPP_API |
Stream output. | |
std::ostream & | dumpOn (std::ostream &str, const PoolQuery &obj) ZYPP_API |
Detailed stream output. |
getters | |
RW_pointer< Impl > | _pimpl |
Pointer to implementation. | |
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 std::string & | comment () 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 |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
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. | |
StatusFilter | statusFilterFlags () const |
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 |
bool | operator!= (const PoolQuery &b) const |
Match | flags () const |
Free function to get libsolv repo search flags. | |
void | setFlags (const Match &flags) |
Free function to set libsolv repo search flags. | |
void | setRequireAll (bool require_all=true) ZYPP_DEPRECATED |
bool | requireAll () const ZYPP_DEPRECATED |
Additional Inherited Members | |
SolvIterMixin () | |
~SolvIterMixin () | |
SolvIterMixin & | operator= (const SolvIterMixin &)=default |
Meta-data query API.
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.
Definition at line 90 of file PoolQuery.h.
using zypp::PoolQuery::Kinds = std::set<ResKind> |
Definition at line 93 of file PoolQuery.h.
using zypp::PoolQuery::StrContainer = std::set<std::string> |
Definition at line 94 of file PoolQuery.h.
using zypp::PoolQuery::AttrRawStrMap = std::map<sat::SolvAttr, StrContainer> |
Definition at line 95 of file PoolQuery.h.
Definition at line 97 of file PoolQuery.h.
using zypp::PoolQuery::size_type = unsigned int |
Definition at line 98 of file PoolQuery.h.
using zypp::PoolQuery::ProcessResolvable = function<bool (const sat::Solvable &)> |
Definition at line 101 of file PoolQuery.h.
Installed status filter setters.
Filter by status (installed uninstalled)
Enumerator | |
---|---|
ALL | |
INSTALLED_ONLY | |
UNINSTALLED_ONLY |
Definition at line 174 of file PoolQuery.h.
zypp::PoolQuery::PoolQuery | ( | ) |
Definition at line 859 of file PoolQuery.cc.
zypp::PoolQuery::~PoolQuery | ( | ) |
Definition at line 863 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 1855 of file PoolQuery.cc.
|
inline |
An iterator pointing to the end of the query result.
Definition at line 621 of file PoolQuery.h.
bool zypp::PoolQuery::empty | ( | ) | const |
Whether the result is empty.
Definition at line 1036 of file PoolQuery.cc.
PoolQuery::size_type zypp::PoolQuery::size | ( | ) | const |
Number of solvables in the query result.
Definition at line 1043 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 1056 of file PoolQuery.cc.
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).
sat::SolvAttr::name
. The following will always match and include the kernel packages
, no matter which kind filter is set. Pass ResKind constants to this method, (e.g. ResKind::package).
Definition at line 876 of file PoolQuery.cc.
void zypp::PoolQuery::addRepo | ( | const std::string & | repoalias | ) |
Filter by repo.
By default, all repos will be returned. If addRepo() is used, only the specified repo will be returned (multiple repos will be ORed).
Definition at line 866 of file PoolQuery.cc.
void zypp::PoolQuery::setComment | ( | const std::string & | comment | ) | const |
Set an optional comment string describing the purpose of the query.
Stored and retrieved when serializing the query. E.g. as lock.
Definition at line 879 of file PoolQuery.cc.
void zypp::PoolQuery::setInstalledOnly | ( | ) |
Return only @System repo packages.
Definition at line 975 of file PoolQuery.cc.
void zypp::PoolQuery::setUninstalledOnly | ( | ) |
Return only packages from repos other than @System.
Definition at line 977 of file PoolQuery.cc.
void zypp::PoolQuery::setStatusFilterFlags | ( | PoolQuery::StatusFilter | flags | ) |
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(..., \value) 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.
Definition at line 882 of file PoolQuery.cc.
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.
"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 885 of file PoolQuery.cc.
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 888 of file PoolQuery.cc.
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, |
const std::string & | name, | ||
const Rel & | op, | ||
const Edition & | edition, | ||
const Arch & | arch ) |
Definition at line 894 of file PoolQuery.cc.
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, |
const std::string & | name, | ||
const Rel & | op, | ||
const Edition & | edition, | ||
const Arch & | arch, | ||
Match::Mode | mode ) |
Definition at line 900 of file PoolQuery.cc.
|
inline |
Definition at line 296 of file PoolQuery.h.
|
inline |
Definition at line 299 of file PoolQuery.h.
|
inline |
Definition at line 303 of file PoolQuery.h.
|
inline |
Definition at line 306 of file PoolQuery.h.
|
inline |
Definition at line 310 of file PoolQuery.h.
|
inline |
Definition at line 313 of file PoolQuery.h.
|
inline |
Definition at line 317 of file PoolQuery.h.
|
inline |
Definition at line 320 of file PoolQuery.h.
|
inline |
Definition at line 324 of file PoolQuery.h.
|
inline |
Definition at line 327 of file PoolQuery.h.
void zypp::PoolQuery::addDependency | ( | const sat::SolvAttr & | attr, |
Capability | cap_r ) |
Definition at line 940 of file PoolQuery.cc.
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 957 of file PoolQuery.cc.
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 1019 of file PoolQuery.cc.
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 1024 of file PoolQuery.cc.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 368 of file PoolQuery.h.
void zypp::PoolQuery::setMatchExact | ( | ) |
Set to match exact string instead of substring.
Definition at line 964 of file PoolQuery.cc.
void zypp::PoolQuery::setMatchSubstring | ( | ) |
Set to substring (the default).
Definition at line 963 of file PoolQuery.cc.
void zypp::PoolQuery::setMatchGlob | ( | ) |
Set to match globs.
Definition at line 966 of file PoolQuery.cc.
void zypp::PoolQuery::setMatchRegex | ( | ) |
Set to use the query strings as regexes.
Definition at line 965 of file PoolQuery.cc.
void zypp::PoolQuery::setMatchWord | ( | ) |
Set substring to match words.
Definition at line 967 of file PoolQuery.cc.
const PoolQuery::StrContainer & zypp::PoolQuery::strings | ( | ) | const |
Search strings added via addString()
Definition at line 984 of file PoolQuery.cc.
const PoolQuery::AttrRawStrMap & zypp::PoolQuery::attributes | ( | ) | const |
Map (map<SolvAttr, StrContainer>) of attribute values added via addAttribute(), addDep in string form.
Definition at line 988 of file PoolQuery.cc.
const PoolQuery::StrContainer & zypp::PoolQuery::attribute | ( | const sat::SolvAttr & | attr | ) | const |
Definition at line 992 of file PoolQuery.cc.
const PoolQuery::Kinds & zypp::PoolQuery::kinds | ( | ) | const |
Definition at line 1006 of file PoolQuery.cc.
const PoolQuery::StrContainer & zypp::PoolQuery::repos | ( | ) | const |
Definition at line 1010 of file PoolQuery.cc.
const std::string & zypp::PoolQuery::comment | ( | ) | const |
Definition at line 1014 of file PoolQuery.cc.
const Edition zypp::PoolQuery::edition | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 999 of file PoolQuery.cc.
const Rel zypp::PoolQuery::editionRel | ( | ) | const |
Definition at line 1001 of file PoolQuery.cc.
bool zypp::PoolQuery::caseSensitive | ( | ) | const |
returns true if search is case sensitive
Definition at line 1017 of file PoolQuery.cc.
bool zypp::PoolQuery::filesMatchFullPath | ( | ) | const |
Whether searching in filelists looks at the full path or just at the basenames.
Definition at line 1022 of file PoolQuery.cc.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 413 of file PoolQuery.h.
bool zypp::PoolQuery::matchExact | ( | ) | const |
Definition at line 1027 of file PoolQuery.cc.
bool zypp::PoolQuery::matchSubstring | ( | ) | const |
Definition at line 1028 of file PoolQuery.cc.
bool zypp::PoolQuery::matchGlob | ( | ) | const |
Definition at line 1029 of file PoolQuery.cc.
bool zypp::PoolQuery::matchRegex | ( | ) | const |
Definition at line 1030 of file PoolQuery.cc.
bool zypp::PoolQuery::matchWord | ( | ) | const |
Definition at line 1031 of file PoolQuery.cc.
|
inline |
Returns string matching mode as enum.
Definition at line 425 of file PoolQuery.h.
PoolQuery::StatusFilter zypp::PoolQuery::statusFilterFlags | ( | ) | const |
Definition at line 1033 of file PoolQuery.cc.
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 |
Definition at line 1152 of file PoolQuery.cc.
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 |
Definition at line 1393 of file PoolQuery.cc.
std::string zypp::PoolQuery::asString | ( | ) | const |
Return a human-readable description of the query.
Definition at line 1492 of file PoolQuery.cc.
Definition at line 1504 of file PoolQuery.cc.
Definition at line 1501 of file PoolQuery.cc.
Definition at line 459 of file PoolQuery.h.
Match zypp::PoolQuery::flags | ( | ) | const |
Free function to get libsolv repo search flags.
Definition at line 969 of file PoolQuery.cc.
void zypp::PoolQuery::setFlags | ( | const Match & | flags | ) |
Free function to set libsolv repo search flags.
Definition at line 971 of file PoolQuery.cc.
void zypp::PoolQuery::setRequireAll | ( | bool | require_all = true | ) |
Definition at line 1060 of file PoolQuery.cc.
bool zypp::PoolQuery::requireAll | ( | ) | const |
Definition at line 1061 of file PoolQuery.cc.
|
Stream output.
Definition at line 1495 of file PoolQuery.cc.
|
Detailed stream output.
Definition at line 1498 of file PoolQuery.cc.
|
private |
Pointer to implementation.
Definition at line 489 of file PoolQuery.h.