15#include <zypp/base/LogTools.h>
16#include <zypp/base/String.h>
18#include <zypp/sat/detail/PoolImpl.h>
24#include <zypp/CheckSum.h>
140 ::dataiterator_prepend_keyname( dip.
get(),
_parent.
id() );
156 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
159 {
return new Impl( *
this ); }
173 : _pimpl( new
Impl( attr_r, loc_r ) )
176 : _pimpl( new
Impl( attr_r, loc_r ) )
177 {
_pimpl->setParent( parent_r ); }
180 : _pimpl( new
Impl( attr_r, repo_r, loc_r ) )
183 : _pimpl( new
Impl( attr_r, repo_r, loc_r ) )
184 {
_pimpl->setParent( parent_r ); }
187 : _pimpl( new
Impl( attr_r, solv_r ) )
190 : _pimpl( new
Impl( attr_r, solv_r ) )
191 {
_pimpl->setParent( parent_r ); }
197 {
return _pimpl->attr(); }
200 {
_pimpl->setAttr( attr_r ); }
203 {
return _pimpl->strMatcher(); }
206 {
_pimpl->setStrMatcher( matcher_r ); }
211 {
return _pimpl->pool(); }
214 {
_pimpl->setPool( loc_r ); }
217 {
return _pimpl->repo(); }
220 {
_pimpl->setRepo( repo_r, loc_r ); }
223 {
return _pimpl->solvable(); }
226 {
_pimpl->setSolvable( solv_r ); }
229 {
return _pimpl->parent(); }
232 {
_pimpl->setParent( attr_r ); }
237 {
return _pimpl->begin(); }
258 return str <<
"search nothing";
261 str <<
"search " << obj.
attr() <<
" in ";
263 str <<
"search ALL in ";
269 return str <<
"pool";
299 const std::string & mstring_r,
int flags_r )
300 : _dip( new ::Dataiterator )
301 , _mstring( mstring_r )
308 const char * mstring_r,
int flags_r )
309 : _dip( new ::Dataiterator )
310 , _mstring( mstring_r ? mstring_r :
"" )
318 , _mstring( rhs._mstring )
322 _dip = new ::Dataiterator;
323 ::dataiterator_init_clone(
_dip, rhs.
_dip );
324 ::dataiterator_strdup(
_dip );
332 ::dataiterator_free(
_dip );
338 {
return str << obj.
get(); }
361 {
if ( _dip ) ::dataiterator_skip_attribute( _dip.get() ); }
364 {
if ( _dip ) ::dataiterator_skip_solvable( _dip.get() ); }
367 {
if ( _dip ) ::dataiterator_skip_repo( _dip.get() ); }
370 {
if ( _dip ) { _dip.get()->repoid = -1; _dip.get()->flags |= SEARCH_THISSOLVID; } }
373 {
if ( _dip ) { _dip.get()->repoid = -1; } }
384 switch ( solvAttrType() )
386 case REPOKEY_TYPE_NUM:
387 case REPOKEY_TYPE_CONSTANT:
396 switch ( solvAttrType() )
398 case REPOKEY_TYPE_ID:
399 case REPOKEY_TYPE_IDARRAY:
400 case REPOKEY_TYPE_CONSTANTID:
401 case REPOKEY_TYPE_STR:
402 case REPOKEY_TYPE_DIRSTRARRAY:
411 switch ( solvAttrType() )
413 case REPOKEY_TYPE_ID:
414 case REPOKEY_TYPE_IDARRAY:
415 case REPOKEY_TYPE_CONSTANTID:
424 switch ( solvAttrType() )
426 case REPOKEY_TYPE_MD5:
427 case REPOKEY_TYPE_SHA1:
428 case REPOKEY_TYPE_SHA256:
438 enum SubType { ST_NONE,
445 if ( dip.
get()->key->type == REPOKEY_TYPE_FLEXARRAY )
447 return dip.
get()->kv.parent ? ST_SUB : ST_NONE;
453 {
return subType( _dip ) != ST_NONE; }
460 {
return( subBegin() == subEnd() ); }
465 for_( it, subBegin(), subEnd() )
472 SubType subtype( subType( _dip ) );
473 if ( subtype == ST_NONE )
477 ::dataiterator_clonepos( dip.
get(), _dip.get() );
483 ::dataiterator_seek( dip.
get(), DI_SEEK_CHILD|DI_SEEK_STAY );
486 ::dataiterator_seek( dip.
get(), DI_SEEK_REWIND|DI_SEEK_STAY );
502 while ( it != subEnd() && it.
inSolvAttr() != attr_r )
510 if ( attrname_r.
empty() )
513 SubType subtype( subType( _dip ) );
514 if ( subtype == ST_NONE )
517 std::string subattr( inSolvAttr().asString() );
518 if ( subtype == ST_FLEX )
522 subattr += attrname_r;
527 std::string::size_type pos( subattr.rfind(
':' ) );
528 if ( pos != std::string::npos )
530 subattr.erase( pos+1 );
531 subattr += attrname_r;
534 subattr = attrname_r;
536 return subFind(
SolvAttr( subattr ) );
547 switch ( solvAttrType() )
549 case REPOKEY_TYPE_NUM:
550 case REPOKEY_TYPE_CONSTANT:
565 switch ( solvAttrType() )
567 case REPOKEY_TYPE_NUM:
568 case REPOKEY_TYPE_CONSTANT:
569 return SOLV_KV_NUM64(&_dip->kv);
584 switch ( solvAttrType() )
586 case REPOKEY_TYPE_ID:
587 case REPOKEY_TYPE_IDARRAY:
588 case REPOKEY_TYPE_CONSTANTID:
589 if ( _dip->data && _dip->data->localpool )
590 return ::stringpool_id2str( &_dip->data->spool, _dip->kv.id );
595 case REPOKEY_TYPE_STR:
599 case REPOKEY_TYPE_DIRSTRARRAY:
601 return( _dip->flags & SEARCH_FILES
603 : ::repodata_dir2str( _dip->data, _dip->kv.id, _dip->kv.str ) );
614 switch ( solvAttrType() )
616 case REPOKEY_TYPE_ID:
617 case REPOKEY_TYPE_IDARRAY:
618 case REPOKEY_TYPE_CONSTANTID:
620 detail::IdType id = ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 );
626 case REPOKEY_TYPE_STR:
627 case REPOKEY_TYPE_DIRSTRARRAY:
629 const char * ret( c_str() );
630 return ret ? ret :
"";
634 case REPOKEY_TYPE_NUM:
635 case REPOKEY_TYPE_CONSTANT:
639 case REPOKEY_TYPE_MD5:
640 case REPOKEY_TYPE_SHA1:
641 case REPOKEY_TYPE_SHA256:
643 return asCheckSum().asString();
647 case REPOKEY_TYPE_FLEXARRAY:
649 std::ostringstream
str;
651 for_( it, subBegin(), subEnd() )
653 str <<
" " << it.inSolvAttr() <<
" = " << it.asString() << endl;
661 return std::string();
668 switch ( solvAttrType() )
670 case REPOKEY_TYPE_ID:
671 case REPOKEY_TYPE_IDARRAY:
672 case REPOKEY_TYPE_CONSTANTID:
673 return IdString( ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 ) );
684 switch ( solvAttrType() )
686 case REPOKEY_TYPE_MD5:
687 return CheckSum::md5( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
690 case REPOKEY_TYPE_SHA1:
691 return CheckSum::sha1( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
694 case REPOKEY_TYPE_SHA224:
695 return CheckSum::sha224( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
698 case REPOKEY_TYPE_SHA256:
699 return CheckSum::sha256( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
702 case REPOKEY_TYPE_SHA384:
703 return CheckSum::sha384( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
706 case REPOKEY_TYPE_SHA512:
707 return CheckSum::sha512( ::repodata_chk2str( _dip->data, solvAttrType(), (
unsigned char *)_dip->kv.str ) );
719 : iterator_adaptor_( 0 )
723 : iterator_adaptor_( 0 )
730 : iterator_adaptor_( 0 )
745 base_reference() = _dip.
get();
756 return( lhs.solvid == rhs.solvid && lhs.key->name == rhs.key->name );
761 return _dip ? ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 )
769 if ( ! ::dataiterator_step( _dip.get() ) )
772 base_reference() = 0;
776 ::dataiterator_strdup( _dip.get() );
785 return str <<
"EndOfQuery";
797 template<>
CheckSum LookupAttr::iterator::asType<CheckSum>()
const
798 {
return asCheckSum(); }
809 str <<
"detail::CDataiterator(";
820 str <<
"|" << obj->repodataid;
821 str <<
"|" << obj->repoid;
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static CheckSum md5(const std::string &checksum)
static CheckSum sha384(const std::string &checksum)
static CheckSum sha1(const std::string &checksum)
static CheckSum sha512(const std::string &checksum)
static CheckSum sha256(const std::string &checksum)
static CheckSum sha224(const std::string &checksum)
Access to the sat-pools string space.
const char * c_str() const
Conversion to const char *
std::string asString() const
Conversion to std::string
int get() const
Return the integer representation.
static const Repository noRepository
Represents no Repository.
IdType id() const
Expert backdoor.
String matching (STRING|SUBSTRING|GLOB|REGEX).
const std::string & searchstring() const
The current searchstring.
const Match & flags() const
The current search flags.
void compile() const
Compile the pattern e.g.
LookupAttr implememtation.
Impl(SolvAttr attr_r, Solvable solv_r)
void setSolvable(Solvable solv_r)
void setStrMatcher(const StrMatcher &matcher_r)
void setParent(SolvAttr attr_r)
Solvable solvable() const
LookupAttr::iterator end() const
const StrMatcher & strMatcher() const
void setPool(Location loc_r)
Impl * clone() const
clone for RWCOW_pointer
LookupAttr::iterator begin() const
Impl(SolvAttr attr_r, Location loc_r)
void setRepo(Repository repo_r, Location loc_r)
void setAttr(SolvAttr attr_r)
Impl(SolvAttr attr_r, Repository repo_r, Location loc_r)
detail::CDataiterator * get() const
Expert backdoor.
iterator subBegin() const
Iterator to the begin of a sub-structure.
unsigned long long asUnsignedLL() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
unsigned asUnsigned() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void stayInThisSolvable()
Stop after all matches in the current Solvable are processed.
IdString idStr() const
As IdStr.
detail::IdType dereference() const
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
SolvAttr inSolvAttr() const
The current SolvAttr.
bool subEmpty() const
Whether the sub-structure is empty.
iterator subFind(SolvAttr attr_r) const
Iterator pointing to the first occurance of SolvAttr attr_r in sub-structure.
CheckSum asCheckSum() const
As CheckSum.
bool solvAttrCheckSum() const
Whether this is a CheckSum attribute.
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
bool asBool() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
iterator subEnd() const
Iterator behind the end of a sub-structure.
void stayInThisRepo()
Stop after all matches in the current Repository are processed.
bool solvAttrSubEntry() const
Whether this is the entry to a sub-structure (flexarray).
Solvable inSolvable() const
The current Solvable.
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
const char * c_str() const
Conversion to string types.
size_type subSize() const
Ammount of attributes in the sub-structure.
iterator & operator=(const iterator &rhs)
bool solvAttrNumeric() const
Whether this is a numeric attribute (incl.
bool solvAttrIdString() const
Whether this string attribute is available as IdString.
bool dip_equal(const detail::CDataiterator &lhs, const detail::CDataiterator &rhs) const
bool solvAttrString() const
Whether this is a string attribute.
detail::IdType solvAttrType() const
The current SolvAttr type.
int asInt() const
Conversion to numeric types.
Repository inRepo() const
The current Repository.
Lightweight attribute value lookup.
iterator end() const
Iterator behind the end of query results.
RWCOW_pointer< Impl > _pimpl
const StrMatcher & strMatcher() const
The pattern to match.
bool empty() const
Whether the query is empty.
Location
Specify the where to look for the attribule.
@ REPO_ATTR
Search for repository attributes.
void setStrMatcher(const StrMatcher &matcher_r)
Set the pattern to match.
Repository repo() const
Whether to search in one Repository.
SolvAttr attr() const
The SolvAttr to search.
SolvAttr parent() const
Whether to search within a sub-structure (SolvAttr::noAttr if not)
void setAttr(SolvAttr attr_r)
Set the SolvAttr to search.
void setRepo(Repository repo_r, Location=SOLV_ATTR)
Set search in one Repository.
bool pool() const
Whether to search in Pool.
size_type size() const
Ammount of results.
iterator begin() const
Iterator to the begin of query results.
void setSolvable(Solvable solv_r)
Set search in one Solvable.
Solvable solvable() const
Whether to search in one Solvable.
std::ostream & operator<<(std::ostream &str, const LookupAttr &obj)
Stream output.
LookupAttr()
Default ctor finds nothing.
void setPool(Location=SOLV_ATTR)
Set search in Pool (all repositories).
void setParent(SolvAttr attr_r)
Set search within a sub-structure (SolvAttr::noAttr for none)
void setRepo(Repository repo_r)
Set search in one Repository.
LookupRepoAttr()
Default ctor finds nothing.
static Pool instance()
Singleton ctor.
static const SolvAttr noAttr
Value representing noAttr ("")
SolvAttr parent() const
Return the parent of well know sub-structure attributes (SolvAttr::noAttr if none).
static const SolvAttr allAttr
Value to request searching all Attributes (0).
A Solvable object within the sat Pool.
IdType id() const
Expert backdoor.
static const Solvable noSolvable
Represents no Solvable.
Repository repository() const
The Repository this Solvable belongs to.
Wrapper around sat detail::CDataiterator.
detail::CDataiterator * get() const
DIWrap()
NULL detail::CDataiterator
detail::CDataiterator * _dip
String related utilities and Regular expression matching.
static const IdType noId(0)
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
::s_Dataiterator CDataiterator
Wrapped libsolv C data type exposed as backdoor.
int IdType
Generic Id type.
std::ostream & operator<<(std::ostream &str, const DIWrap &obj)
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
std::string numstring(char n, int w=0)
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.