libzypp  17.38.7
zyppng::sat::LookupAttr Class Reference

Lightweight attribute value lookup. More...

#include <zypp/ng/sat/lookupattr.h>

Inheritance diagram for zyppng::sat::LookupAttr:

Classes

class  Impl
 LookupAttr implementation. More...
 
class  iterator
 Result iterator. More...
 
class  TransformIterator
 TransformIterator returning an iterator vaue of type TResult. More...
 

Public Types

enum  Location { SOLV_ATTR = 0, REPO_ATTR = -1 }
 Specify the where to look for the attribule. More...
 
using Exception = MatchException
 
using size_type = unsigned int
 

Public Member Functions

 LookupAttr ()
 Default ctor finds nothing. More...
 
 LookupAttr (const LookupAttr &)=default
 
 LookupAttr (LookupAttr &&) noexcept=default
 
LookupAttroperator= (const LookupAttr &)=default
 
LookupAttroperator= (LookupAttr &&) noexcept=default
 
 LookupAttr (Pool &pool, SolvAttr attr_r, Location=SOLV_ATTR)
 Lookup SolvAttr in Pool (all repositories). More...
 
 LookupAttr (Pool &pool, SolvAttr attr_r, SolvAttr parent_r, Location=SOLV_ATTR)
 
 LookupAttr (SolvAttr attr_r, Repository repo_r, Location=SOLV_ATTR)
 Lookup SolvAttr in oneRepository. More...
 
 LookupAttr (SolvAttr attr_r, SolvAttr parent_r, Repository repo_r, Location=SOLV_ATTR)
 
 LookupAttr (SolvAttr attr_r, Solvable solv_r)
 Lookup SolvAttr in one Solvable. More...
 
 LookupAttr (SolvAttr attr_r, SolvAttr parent_r, Solvable solv_r)
 
Search result.
iterator begin () const
 Iterator to the begin of query results. More...
 
iterator end () const
 Iterator behind the end of query results. More...
 
bool empty () const
 Whether the query is empty. More...
 
size_type size () const
 Ammount of results. More...
 
What to search.
SolvAttr attr () const
 The SolvAttr to search. More...
 
void setAttr (SolvAttr attr_r)
 Set the SolvAttr to search. More...
 
Restrict attributes to match a pattern.
const StrMatcherstrMatcher () const
 The pattern to match. More...
 
void setStrMatcher (const StrMatcher &matcher_r)
 Set the pattern to match. More...
 
void resetStrMatcher ()
 Reset the pattern to match. More...
 
Where to search.
bool pool () const
 Whether to search in Pool. More...
 
void setPool (Location=SOLV_ATTR)
 Set search in Pool (all repositories). More...
 
Repository repo () const
 Whether to search in one Repository. More...
 
void setRepo (Repository repo_r, Location=SOLV_ATTR)
 Set search in one Repository. More...
 
Solvable solvable () const
 Whether to search in one Solvable. More...
 
void setSolvable (Solvable solv_r)
 Set search in one Solvable. More...
 
SolvAttr parent () const
 Whether to search within a sub-structure (SolvAttr::noAttr if not) More...
 
void setParent (SolvAttr attr_r)
 Set search within a sub-structure (SolvAttr::noAttr for none) More...
 

Private Attributes

zypp::RWCOW_pointer< Impl_pimpl
 

Detailed Description

Lightweight attribute value lookup.

Search for an attribute in Pool, one Repository or one Solvable. LookupAttr builds the query, LookupAttr::iterator iterates over the result.

Per default LookupAttr looks for attributes associated with a Solvable. But you may also pass REPO_ATTR as Location argument, to lookup attributes associated with the Repository (e.g. DeltaRpm information).

For convenience

See also
LookupRepoAttr.

Modifying the query will not affect any running iterator.

Use SolvAttr::allAttr to search all attributes.

To search for attributes located in a sub-structure (flexarray) you also have to pass the sub-structures attribute as parent. Passing SolvAttr::allAttr a parent will lookup the attribute in any sub-structure. Few attributes are known to have a parent (

See also
SolvAttr::parent). Setting those attributes will automatically initialize their parent value.
// Lookup all 'name' attributes:
sat::LookupAttr q( pool, sat::SolvAttr::name );
// Lookup all 'name' attributes within a sub-structure 'data':
sat::LookupAttr q( pool, sat::SolvAttr::name, sat::SolvAttr::data );
// Lookup all 'name' attributes within any sub-structure:
sat::LookupAttr q( pool, sat::SolvAttr::name, sat::SolvAttr::allAttr );
// look for all attributes of one solvable
void ditest( sat::Solvable slv_r )
{
sat::LookupAttr q( sat::SolvAttr::allAttr, slv_r );
MIL << q << ": " << endl;
for_( it, q.begin(), q.end() )
{
MIL << " " << it.inSolvAttr() << " = " << it.asString() << endl;
}
}
// look for an attribute in the pool.
sat::LookupAttr q( pool, sat::SolvAttr("susetags:datadir") );
MIL << q << ": " << endl;
for_( it, q.begin(), q.end() )
{
MIL << " " << it << endl;
}
// look for a repo attribute in the pool.
sat::LookupRepoAttr q( pool, sat::SolvAttr::repositoryAddedFileProvides );
MIL << q << ": " << endl;
for_( it, q.begin(), q.end() )
{
MIL << " " << it << endl;
}

Definition at line 111 of file lookupattr.h.

Member Typedef Documentation

◆ Exception

◆ size_type

using zyppng::sat::LookupAttr::size_type = unsigned int

Definition at line 117 of file lookupattr.h.

Member Enumeration Documentation

◆ Location

Specify the where to look for the attribule.

Enumerator
SOLV_ATTR 

Search for solvable attributes (default)

REPO_ATTR 

Search for repository attributes.

Definition at line 120 of file lookupattr.h.

Constructor & Destructor Documentation

◆ LookupAttr() [1/9]

zyppng::sat::LookupAttr::LookupAttr ( )

Default ctor finds nothing.

CLASS NAME : LookupAttr.

Definition at line 165 of file lookupattr.cc.

◆ LookupAttr() [2/9]

zyppng::sat::LookupAttr::LookupAttr ( const LookupAttr )
default

◆ LookupAttr() [3/9]

zyppng::sat::LookupAttr::LookupAttr ( LookupAttr &&  )
defaultnoexcept

◆ LookupAttr() [4/9]

zyppng::sat::LookupAttr::LookupAttr ( Pool pool,
SolvAttr  attr_r,
Location  loc_r = SOLV_ATTR 
)
explicit

Lookup SolvAttr in Pool (all repositories).

Definition at line 169 of file lookupattr.cc.

◆ LookupAttr() [5/9]

zyppng::sat::LookupAttr::LookupAttr ( Pool pool,
SolvAttr  attr_r,
SolvAttr  parent_r,
Location  loc_r = SOLV_ATTR 
)

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 173 of file lookupattr.cc.

◆ LookupAttr() [6/9]

zyppng::sat::LookupAttr::LookupAttr ( SolvAttr  attr_r,
Repository  repo_r,
Location  loc_r = SOLV_ATTR 
)

Lookup SolvAttr in oneRepository.

Definition at line 177 of file lookupattr.cc.

◆ LookupAttr() [7/9]

zyppng::sat::LookupAttr::LookupAttr ( SolvAttr  attr_r,
SolvAttr  parent_r,
Repository  repo_r,
Location  loc_r = SOLV_ATTR 
)

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 183 of file lookupattr.cc.

◆ LookupAttr() [8/9]

zyppng::sat::LookupAttr::LookupAttr ( SolvAttr  attr_r,
Solvable  solv_r 
)

Lookup SolvAttr in one Solvable.

Definition at line 190 of file lookupattr.cc.

◆ LookupAttr() [9/9]

zyppng::sat::LookupAttr::LookupAttr ( SolvAttr  attr_r,
SolvAttr  parent_r,
Solvable  solv_r 
)

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 196 of file lookupattr.cc.

Member Function Documentation

◆ operator=() [1/2]

LookupAttr& zyppng::sat::LookupAttr::operator= ( const LookupAttr )
default

◆ operator=() [2/2]

LookupAttr& zyppng::sat::LookupAttr::operator= ( LookupAttr &&  )
defaultnoexcept

◆ begin()

LookupAttr::iterator zyppng::sat::LookupAttr::begin ( ) const

Iterator to the begin of query results.

Definition at line 240 of file lookupattr.cc.

◆ end()

LookupAttr::iterator zyppng::sat::LookupAttr::end ( ) const

Iterator behind the end of query results.

Definition at line 243 of file lookupattr.cc.

◆ empty()

bool zyppng::sat::LookupAttr::empty ( ) const

Whether the query is empty.

Definition at line 246 of file lookupattr.cc.

◆ size()

LookupAttr::size_type zyppng::sat::LookupAttr::size ( ) const

Ammount of results.

Note
This is not a cheap call. It runs the query.

Definition at line 249 of file lookupattr.cc.

◆ attr()

SolvAttr zyppng::sat::LookupAttr::attr ( ) const

The SolvAttr to search.

Definition at line 204 of file lookupattr.cc.

◆ setAttr()

void zyppng::sat::LookupAttr::setAttr ( SolvAttr  attr_r)

Set the SolvAttr to search.

Definition at line 207 of file lookupattr.cc.

◆ strMatcher()

const StrMatcher & zyppng::sat::LookupAttr::strMatcher ( ) const

The pattern to match.

You can also evaluate StrMatcher in a boolean context, in order to test whether an StrMatcher is set:

if ( q.strMatcher() )
...; // an StrMatcher is set

Definition at line 210 of file lookupattr.cc.

◆ setStrMatcher()

void zyppng::sat::LookupAttr::setStrMatcher ( const StrMatcher matcher_r)

Set the pattern to match.

Exceptions
MatchExceptionAny of the exceptions thrown by StrMatcher::compile.

Definition at line 213 of file lookupattr.cc.

◆ resetStrMatcher()

void zyppng::sat::LookupAttr::resetStrMatcher ( )

Reset the pattern to match.

◆ pool()

bool zyppng::sat::LookupAttr::pool ( ) const

Whether to search in Pool.

Definition at line 216 of file lookupattr.cc.

◆ setPool()

void zyppng::sat::LookupAttr::setPool ( Location  loc_r = SOLV_ATTR)

Set search in Pool (all repositories).

Definition at line 219 of file lookupattr.cc.

◆ repo()

Repository zyppng::sat::LookupAttr::repo ( ) const

Whether to search in one Repository.

Definition at line 222 of file lookupattr.cc.

◆ setRepo()

void zyppng::sat::LookupAttr::setRepo ( Repository  repo_r,
Location  loc_r = SOLV_ATTR 
)

Set search in one Repository.

Definition at line 225 of file lookupattr.cc.

◆ solvable()

Solvable zyppng::sat::LookupAttr::solvable ( ) const

Whether to search in one Solvable.

Definition at line 228 of file lookupattr.cc.

◆ setSolvable()

void zyppng::sat::LookupAttr::setSolvable ( Solvable  solv_r)

Set search in one Solvable.

Definition at line 231 of file lookupattr.cc.

◆ parent()

SolvAttr zyppng::sat::LookupAttr::parent ( ) const

Whether to search within a sub-structure (SolvAttr::noAttr if not)

Definition at line 234 of file lookupattr.cc.

◆ setParent()

void zyppng::sat::LookupAttr::setParent ( SolvAttr  attr_r)

Set search within a sub-structure (SolvAttr::noAttr for none)

Definition at line 237 of file lookupattr.cc.

Member Data Documentation

◆ _pimpl

zypp::RWCOW_pointer<Impl> zyppng::sat::LookupAttr::_pimpl
private

Definition at line 235 of file lookupattr.h.


The documentation for this class was generated from the following files: