libzypp  17.38.8
lookupattr.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 #include <sstream>
14 #include <utility>
15 
17 #include <zypp-core/base/String.h>
18 
19 #include <zypp/ng/sat/pool.h>
20 #include <zypp/ng/idstringtype.h>
21 #include <zypp/ng/sat/lookupattr.h>
22 #include <zypp/base/StrMatcher.h>
23 #include <zypp/ng/sat/capability.h>
24 
25 #include <zypp-core/CheckSum.h>
26 
27 using std::endl;
28 
29 namespace zyppng::sat
30 {
32 
47  {
48  public:
49  Impl()
50  : _pool( nullptr )
51  , _parent( SolvAttr::noAttr )
52  {}
53  Impl( detail::CPool * pool_r, const SolvAttr& attr_r, Location loc_r )
54  : _pool( pool_r ), _attr( attr_r ), _parent( attr_r.parent() ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
55  {}
56  Impl( detail::CPool * pool_r, const SolvAttr& attr_r, Repository repo_r, Location loc_r )
57  : _pool( pool_r ), _attr( attr_r ), _parent( attr_r.parent() ), _repo( repo_r ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
58  {}
59  Impl( detail::CPool * pool_r, const SolvAttr& attr_r, Solvable solv_r )
60  : _pool( pool_r ), _attr( attr_r ), _parent( attr_r.parent() ), _solv( solv_r )
61  {}
62 
63  public:
64  SolvAttr attr() const
65  { return _attr; }
66 
67  void setAttr( SolvAttr attr_r )
68  {
69  _attr = std::move(attr_r);
70  SolvAttr p( _attr.parent() );
71  if ( p != SolvAttr::noAttr )
72  _parent = p;
73  }
74 
75  const StrMatcher & strMatcher() const
76  { return _strMatcher; }
77 
78  void setStrMatcher( const StrMatcher & matcher_r )
79  {
80  matcher_r.compile();
81  _strMatcher = matcher_r;
82  }
83 
84  public:
85  bool pool() const
86  { return ! (_repo || _solv); }
87 
88  void setPool( Location loc_r )
89  {
91  _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
92  }
93 
94  Repository repo() const
95  { return _repo; }
96 
97  void setRepo( Repository repo_r, Location loc_r )
98  {
99  _repo = repo_r;
100  _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
101  // Extract pool from repo
102  if ( _repo )
103  _pool = _repo.pool().get();
104  }
105 
107  { return _solv; }
108 
109  void setSolvable( Solvable solv_r )
110  {
112  _solv = solv_r;
113  // Extract pool from solvable
114  if ( _solv )
115  _pool = _solv.pool().get();
116  }
117 
118  SolvAttr parent() const
119  { return _parent; }
120 
121  void setParent( SolvAttr attr_r )
122  { _parent = std::move(attr_r); }
123 
124  public:
126  {
127  if ( _attr == SolvAttr::noAttr || ! _pool || ! _pool->nrepos )
128  return end();
129 
130  detail::RepoIdType whichRepo = detail::noRepoId; // all repos
131  if ( _solv )
132  whichRepo = _solv.repository();
133  else if ( _repo )
134  whichRepo = _repo.id();
135 
136  detail::DIWrap dip( _pool, whichRepo, _solv.id(), _attr.id(), _strMatcher.searchstring(), _strMatcher.flags().get() );
137  if ( _parent != SolvAttr::noAttr )
138  ::dataiterator_prepend_keyname( dip.get(), _parent.id() );
139 
140  return iterator( dip ); // iterator takes over ownership!
141  }
142 
144  { return iterator(); }
145 
146  private:
148  SolvAttr _attr;
149  SolvAttr _parent;
153 
154  private:
155  friend Impl * zypp::rwcowClone<Impl>( const Impl * rhs );
157  Impl * clone() const
158  { return new Impl( *this ); }
159  };
160 
166  : _pimpl( new Impl )
167  {}
168 
169  LookupAttr::LookupAttr( Pool & pool, SolvAttr attr_r, Location loc_r )
170  : _pimpl( new Impl( pool.get(), std::move(attr_r), std::move(loc_r) ) )
171  {}
172 
173  LookupAttr::LookupAttr( Pool & pool, SolvAttr attr_r, SolvAttr parent_r, Location loc_r )
174  : _pimpl( new Impl( pool.get(), std::move(attr_r), std::move(loc_r) ) )
175  { _pimpl->setParent( std::move(parent_r) ); }
176 
177  LookupAttr::LookupAttr( SolvAttr attr_r, Repository repo_r, Location loc_r )
178  {
179  detail::CPool * cp = repo_r.pool().get();
180  _pimpl.reset( new Impl( cp, std::move(attr_r), std::move(repo_r), std::move(loc_r) ) );
181  }
182 
183  LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Repository repo_r, Location loc_r )
184  {
185  detail::CPool * cp = repo_r.pool().get();
186  _pimpl.reset( new Impl( cp, std::move(attr_r), std::move(repo_r), std::move(loc_r) ) );
187  _pimpl->setParent( std::move(parent_r) );
188  }
189 
190  LookupAttr::LookupAttr( SolvAttr attr_r, Solvable solv_r )
191  {
192  detail::CPool * cp = solv_r.pool().get();
193  _pimpl.reset( new Impl( cp, std::move(attr_r), std::move(solv_r) ) );
194  }
195 
196  LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Solvable solv_r )
197  {
198  detail::CPool * cp = solv_r.pool().get();
199  _pimpl.reset( new Impl( cp, std::move(attr_r), std::move(solv_r) ) );
200  _pimpl->setParent( std::move(parent_r) );
201  }
202 
203 
204  SolvAttr LookupAttr::attr() const
205  { return _pimpl->attr(); }
206 
207  void LookupAttr::setAttr( SolvAttr attr_r )
208  { _pimpl->setAttr( std::move(attr_r) ); }
209 
211  { return _pimpl->strMatcher(); }
212 
213  void LookupAttr::setStrMatcher( const StrMatcher & matcher_r )
214  { _pimpl->setStrMatcher( matcher_r ); }
215 
216  bool LookupAttr::pool() const
217  { return _pimpl->pool(); }
218 
220  { _pimpl->setPool( loc_r ); }
221 
223  { return _pimpl->repo(); }
224 
226  { _pimpl->setRepo( repo_r, loc_r ); }
227 
229  { return _pimpl->solvable(); }
230 
232  { _pimpl->setSolvable( solv_r ); }
233 
234  SolvAttr LookupAttr::parent() const
235  { return _pimpl->parent(); }
236 
237  void LookupAttr::setParent( SolvAttr attr_r )
238  { _pimpl->setParent( std::move(attr_r) ); }
239 
241  { return _pimpl->begin(); }
242 
244  { return _pimpl->end(); }
245 
246  bool LookupAttr::empty() const
247  { return begin() == end(); }
248 
250  {
251  size_type c = 0;
252  for ( auto it = begin(); it != end(); ++it )
253  ++c;
254  return c;
255  }
256 
261  LookupRepoAttr::LookupRepoAttr( SolvAttr attr_r, Repository repo_r )
262  : LookupAttr( std::move(attr_r), repo_r, REPO_ATTR )
263  {}
264 
266  { LookupAttr::setRepo( repo_r, REPO_ATTR ); }
267 
272  namespace detail
273  {
274  DIWrap::DIWrap( detail::CPool * pool, RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
275  std::string mstring_r, int flags_r )
276  : _dip( new ::Dataiterator )
277  , _pool( pool )
278  , _mstring(std::move( mstring_r ))
279  {
280  ::dataiterator_init( _dip, _pool, repoId_r, solvId_r, attrId_r,
281  _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
282  }
283 
284  DIWrap::DIWrap( detail::CPool * pool, RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
285  const char * mstring_r, int flags_r )
286  : _dip( new ::Dataiterator )
287  , _pool( pool )
288  , _mstring( mstring_r ? mstring_r : "" )
289  {
290  ::dataiterator_init( _dip, _pool, repoId_r, solvId_r, attrId_r,
291  _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
292  }
293 
294  DIWrap::DIWrap( const DIWrap & rhs )
295  : _dip( 0 )
296  , _pool( rhs._pool )
297  , _mstring( rhs._mstring )
298  {
299  if ( rhs._dip )
300  {
301  _dip = new ::Dataiterator;
302  ::dataiterator_init_clone( _dip, rhs._dip );
303  ::dataiterator_strdup( _dip );
304  }
305  }
306 
308  {
309  if ( _dip )
310  {
311  ::dataiterator_free( _dip );
312  delete _dip;
313  }
314  }
315  }
316 
322  { return _dip ? Repository( _dip->repo ) : Repository::noRepository; }
323 
325  { return _dip ? Solvable( _dip->solvid ) : Solvable::noSolvable; }
326 
328  { return _dip ? SolvAttr( _dip->key->name ) : SolvAttr::noAttr; }
329 
331  { if ( _dip ) ::dataiterator_skip_attribute( _dip.get() ); }
332 
334  { if ( _dip ) ::dataiterator_skip_solvable( _dip.get() ); }
335 
337  { if ( _dip ) ::dataiterator_skip_repo( _dip.get() ); }
338 
340  { if ( _dip ) { _dip.get()->repoid = -1; _dip.get()->flags |= SEARCH_THISSOLVID; } }
341 
343  { if ( _dip ) { _dip.get()->repoid = -1; } }
344 
346  { return _dip ? _dip->key->type : detail::noId; }
347 
349  {
350  switch ( solvAttrType() )
351  {
352  case REPOKEY_TYPE_NUM:
353  case REPOKEY_TYPE_CONSTANT:
354  return true;
355  break;
356  }
357  return false;
358  }
359 
361  {
362  switch ( solvAttrType() )
363  {
364  case REPOKEY_TYPE_ID:
365  case REPOKEY_TYPE_IDARRAY:
366  case REPOKEY_TYPE_CONSTANTID:
367  case REPOKEY_TYPE_STR:
368  case REPOKEY_TYPE_DIRSTRARRAY:
369  return true;
370  break;
371  }
372  return false;
373  }
374 
376  {
377  switch ( solvAttrType() )
378  {
379  case REPOKEY_TYPE_ID:
380  case REPOKEY_TYPE_IDARRAY:
381  case REPOKEY_TYPE_CONSTANTID:
382  return true;
383  break;
384  }
385  return false;
386  }
387 
389  {
390  switch ( solvAttrType() )
391  {
392  case REPOKEY_TYPE_MD5:
393  case REPOKEY_TYPE_SHA1:
394  case REPOKEY_TYPE_SHA256:
395  return true;
396  break;
397  }
398  return false;
399  }
400 
401  namespace
402  {
403  enum SubType { ST_NONE, // no sub-structure
404  ST_FLEX, // flexarray
405  ST_SUB }; // inside sub-structure
406  SubType subType( const detail::DIWrap & dip )
407  {
408  if ( ! dip )
409  return ST_NONE;
410  if ( dip.get()->key->type == REPOKEY_TYPE_FLEXARRAY )
411  return ST_FLEX;
412  return dip.get()->kv.parent ? ST_SUB : ST_NONE;
413  }
415  SubType subType( const detail::CDataiterator * dip )
416  {
417  if ( ! dip )
418  return ST_NONE;
419  if ( dip->key->type == REPOKEY_TYPE_FLEXARRAY )
420  return ST_FLEX;
421  return dip->kv.parent ? ST_SUB : ST_NONE;
422  }
423  }
424 
426  { return subType( _dip ) != ST_NONE; }
427 
429  { return subBegin() == subEnd(); }
430 
432  {
433  size_type c = 0;
434  for ( auto it = subBegin(); it != subEnd(); ++it )
435  ++c;
436  return c;
437  }
438 
440  {
441  SubType subtype( subType( _dip ) );
442  if ( subtype == ST_NONE )
443  return subEnd();
444  // Clone the current position into a new DIWrap using the pool stored on us.
445  detail::DIWrap dip( _pool, 0, 0, 0 );
446  ::dataiterator_clonepos( dip.get(), _dip );
447  switch ( subtype )
448  {
449  case ST_NONE: // not reached
450  break;
451  case ST_FLEX:
452  ::dataiterator_seek( dip.get(), DI_SEEK_CHILD|DI_SEEK_STAY );
453  break;
454  case ST_SUB:
455  ::dataiterator_seek( dip.get(), DI_SEEK_REWIND|DI_SEEK_STAY );
456  break;
457  }
458  return LookupAttr::iterator( dip ); // iterator takes over ownership!
459  }
460 
462  {
463  return LookupAttr::iterator();
464  }
465 
466  LookupAttr::iterator LookupAttrValue::subFind( const SolvAttr & attr_r ) const
467  {
468  LookupAttr::iterator it = subBegin();
469  if ( attr_r != SolvAttr::allAttr )
470  {
471  while ( it != subEnd() && (*it).inSolvAttr() != attr_r )
472  ++it;
473  }
474  return it;
475  }
476 
478  {
479  if ( attrname_r.empty() )
480  return subBegin();
481 
482  SubType subtype( subType( _dip ) );
483  if ( subtype == ST_NONE )
484  return subBegin();
485 
486  std::string subattr( inSolvAttr().asString() );
487  if ( subtype == ST_FLEX )
488  {
489  // append ":attrname"
490  subattr += ":";
491  subattr += attrname_r;
492  }
493  else
494  {
495  // replace "oldname" after ':' with "attrname"
496  std::string::size_type pos( subattr.rfind( ':' ) );
497  if ( pos != std::string::npos )
498  {
499  subattr.erase( pos+1 );
500  subattr += attrname_r;
501  }
502  else
503  subattr = attrname_r; // no ':' so replace all.
504  }
505  return subFind( SolvAttr( subattr ) );
506  }
507 
509  {
510  if ( _dip )
511  {
512  switch ( solvAttrType() )
513  {
514  case REPOKEY_TYPE_NUM:
515  case REPOKEY_TYPE_CONSTANT:
516  return _dip->kv.num;
517  break;
518  }
519  }
520  return 0;
521  }
522 
524  { return asInt(); }
525 
526  unsigned long long LookupAttrValue::asUnsignedLL() const
527  {
528  if ( _dip )
529  {
530  switch ( solvAttrType() )
531  {
532  case REPOKEY_TYPE_NUM:
533  case REPOKEY_TYPE_CONSTANT:
534  return SOLV_KV_NUM64(&_dip->kv);
535  break;
536  }
537  }
538  return 0;
539  }
540 
542  { return asInt(); }
543 
544 
545  const char * LookupAttrValue::c_str() const
546  {
547  if ( _dip )
548  {
549  switch ( solvAttrType() )
550  {
551  case REPOKEY_TYPE_ID:
552  case REPOKEY_TYPE_IDARRAY:
553  case REPOKEY_TYPE_CONSTANTID:
554  if ( _dip->data && _dip->data->localpool )
555  return ::stringpool_id2str( &_dip->data->spool, _dip->kv.id ); // in local pool
556  else
557  return IdString( _dip->kv.id ).c_str(); // in global pool
558  break;
559 
560  case REPOKEY_TYPE_STR:
561  return _dip->kv.str;
562  break;
563 
564  case REPOKEY_TYPE_DIRSTRARRAY:
565  // may or may not be stringified depending on SEARCH_FILES flag
566  return( _dip->flags & SEARCH_FILES
567  ? _dip->kv.str
568  : ::repodata_dir2str( _dip->data, _dip->kv.id, _dip->kv.str ) );
569  break;
570  }
571  }
572  return 0;
573  }
574 
575  std::string LookupAttrValue::asString() const
576  {
577  if ( _dip )
578  {
579  switch ( solvAttrType() )
580  {
581  case REPOKEY_TYPE_ID:
582  case REPOKEY_TYPE_IDARRAY:
583  case REPOKEY_TYPE_CONSTANTID:
584  {
585  detail::IdType id = ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 );
586  return ISRELDEP(id) ? Capability( id ).asString()
587  : IdString( id ).asString();
588  }
589  break;
590 
591  case REPOKEY_TYPE_STR:
592  case REPOKEY_TYPE_DIRSTRARRAY:
593  {
594  const char * ret( c_str() );
595  return ret ? ret : "";
596  }
597  break;
598 
599  case REPOKEY_TYPE_NUM:
600  case REPOKEY_TYPE_CONSTANT:
601  return zypp::str::numstring( asInt() );
602  break;
603 
604  case REPOKEY_TYPE_MD5:
605  case REPOKEY_TYPE_SHA1:
606  case REPOKEY_TYPE_SHA256:
607  {
608  return asCheckSum().asString();
609  }
610  break;
611 
612  case REPOKEY_TYPE_FLEXARRAY:
613  {
614  std::ostringstream str;
615  str << "{" << endl;
616  for ( auto it = subBegin(); it != subEnd(); ++it )
617  {
618  str << " " << (*it).inSolvAttr() << " = " << (*it).asString() << endl;
619  }
620  str << "}";
621  return str.str();
622  }
623  break;
624  }
625  }
626  return std::string();
627  }
628 
630  {
631  if ( _dip )
632  {
633  switch ( solvAttrType() )
634  {
635  case REPOKEY_TYPE_ID:
636  case REPOKEY_TYPE_IDARRAY:
637  case REPOKEY_TYPE_CONSTANTID:
638  return IdString( ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 ) );
639  break;
640  }
641  }
642  return IdString();
643  }
644 
646  {
647  if ( _dip )
648  {
649  switch ( solvAttrType() )
650  {
651  case REPOKEY_TYPE_MD5:
652  return CheckSum::md5( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
653  break;
654 
655  case REPOKEY_TYPE_SHA1:
656  return CheckSum::sha1( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
657  break;
658 
659  case REPOKEY_TYPE_SHA224:
660  return CheckSum::sha224( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
661  break;
662 
663  case REPOKEY_TYPE_SHA256:
664  return CheckSum::sha256( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
665  break;
666 
667  case REPOKEY_TYPE_SHA384:
668  return CheckSum::sha384( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
669  break;
670 
671  case REPOKEY_TYPE_SHA512:
672  return CheckSum::sha512( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
673  break;
674  }
675  }
676  return CheckSum();
677  }
678 
680  {}
681 
683  : _dip( rhs._dip )
684  {}
685 
687  {
688  _dip.swap( dip_r ); // take ownership!
689  increment();
690  }
691 
693  {}
694 
696  {
697  if ( &rhs != this )
698  {
699  _dip = rhs._dip;
700  }
701  return *this;
702  }
703 
705  {
706  // Iterator equal is same position in same container.
707  // Here: same attribute in same solvable.
708  return( lhs.solvid == rhs.solvid && lhs.key->name == rhs.key->name );
709  }
710 
712  {
713  return LookupAttrValue( _dip.get(), _dip.pool() );
714  }
715 
717  {
718  increment();
719  return *this;
720  }
721 
723  {
724  iterator tmp = *this;
725  increment();
726  return tmp;
727  }
728 
729  bool LookupAttr::iterator::operator==( const iterator & rhs ) const
730  {
731  return ( bool(_dip) == bool(rhs._dip) )
732  && ( ! _dip || dip_equal( *_dip.get(), *rhs._dip.get() ) );
733  }
734 
736  {
737  if ( _dip )
738  {
739  if ( ! ::dataiterator_step( _dip.get() ) )
740  {
741  _dip.reset();
742  }
743  else
744  {
745  ::dataiterator_strdup( _dip.get() );
746  }
747  }
748  }
749 
750  template<> CheckSum LookupAttrValue::asType<CheckSum>() const
751  { return asCheckSum(); }
752 
753 } // namespace zyppng::sat
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
void setStrMatcher(const StrMatcher &matcher_r)
Definition: lookupattr.cc:78
const StrMatcher & strMatcher() const
The pattern to match.
Definition: lookupattr.cc:210
void setAttr(SolvAttr attr_r)
Definition: lookupattr.cc:67
Impl(detail::CPool *pool_r, const SolvAttr &attr_r, Location loc_r)
Definition: lookupattr.cc:53
A Solvable object within the sat Pool.
Definition: solvable.h:65
Impl * clone() const
clone for RWCOW_pointer
Definition: lookupattr.cc:157
unsigned long long asUnsignedLL() const
Definition: lookupattr.cc:526
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition: Patch.cc:122
DIWrap()
NULL detail::CDataiterator
Definition: lookupattr.h:297
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition: StrMatcher.h:297
void setSolvable(Solvable solv_r)
Set search in one Solvable.
Definition: lookupattr.cc:231
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
Definition: lookupattr.cc:333
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
Lightweight attribute value lookup.
Definition: lookupattr.h:113
void stayInThisSolvable()
Stop after all matches in the current Solvable are processed.
Definition: lookupattr.cc:339
LookupAttr::iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition: lookupattr.cc:439
void stayInThisRepo()
Stop after all matches in the current Repository are processed.
Definition: lookupattr.cc:342
bool subEmpty() const
Whether the sub-structure is empty.
Definition: lookupattr.cc:428
void setAttr(SolvAttr attr_r)
Set the SolvAttr to search.
Definition: lookupattr.cc:207
String related utilities and Regular expression matching.
const char * c_str() const
Conversion to string types.
Definition: lookupattr.cc:545
Value proxy returned by LookupAttr::iterator::operator*().
Definition: lookupattr.h:453
Definition: ansi.h:854
Access to the sat-pools string space.
Definition: IdString.h:51
Orchestrator for a libsolv pool instance.
Definition: pool.h:36
void setPool(Location loc_r)
Definition: lookupattr.cc:88
void setPool(Location=SOLV_ATTR)
Set search in Pool (all repositories).
Definition: lookupattr.cc:219
zypp::sat::detail::CPool CPool
Definition: poolconstants.h:36
Repository inRepo() const
The current Repository.
Definition: lookupattr.cc:321
void setParent(SolvAttr attr_r)
Definition: lookupattr.cc:121
static CheckSum md5(const std::string &checksum)
Definition: CheckSum.h:73
void setParent(SolvAttr attr_r)
Set search within a sub-structure (SolvAttr::noAttr for none)
Definition: lookupattr.cc:237
LookupAttr()
Default ctor finds nothing.
Definition: lookupattr.cc:165
zypp::sat::detail::SolvableIdType SolvableIdType
Definition: poolconstants.h:44
bool empty() const
Whether the query is empty.
Definition: lookupattr.cc:246
bool dip_equal(const detail::CDataiterator &lhs, const detail::CDataiterator &rhs) const
Definition: lookupattr.cc:704
unsigned int size_type
Definition: lookupattr.h:119
detail::IdType solvAttrType() const
The current SolvAttr type.
Definition: lookupattr.cc:345
LookupAttr::iterator begin() const
Definition: lookupattr.cc:125
void setRepo(Repository repo_r, Location=SOLV_ATTR)
Set search in one Repository.
Definition: lookupattr.cc:225
void compile() const
Compile the pattern e.g.
Definition: StrMatcher.cc:297
detail::CDataiterator * get() const
Definition: lookupattr.h:334
Repository repo() const
Whether to search in one Repository.
Definition: lookupattr.cc:222
Repository repo() const
Definition: lookupattr.cc:94
void setStrMatcher(const StrMatcher &matcher_r)
Set the pattern to match.
Definition: lookupattr.cc:213
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: lookupattr.cc:575
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition: lookupattr.cc:336
detail::CPool * get() const
Expert backdoor.
Definition: pool.h:59
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:91
size_type subSize() const
Amount of attributes in the sub-structure.
Definition: lookupattr.cc:431
static CheckSum sha224(const std::string &checksum)
Definition: CheckSum.h:76
bool solvAttrNumeric() const
Whether this is a numeric attribute (incl.
Definition: lookupattr.cc:348
This file contains private API, this might break at any time between releases.
Definition: capabilities.h:22
A sat capability.
Definition: capability.h:73
LookupAttr implementation.
Definition: lookupattr.cc:46
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition: lookupattr.cc:327
size_type size() const
Ammount of results.
Definition: lookupattr.cc:249
detail::CDataiterator * _dip
Definition: lookupattr.h:339
Location
Specify the where to look for the attribule.
Definition: lookupattr.h:122
SolvAttr parent() const
Whether to search within a sub-structure (SolvAttr::noAttr if not)
Definition: lookupattr.cc:234
static const Repository noRepository
Represents no Repository.
Definition: repository.h:79
LookupAttr::size_type size_type
Definition: lookupattr.h:456
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:51
std::string numstring(char n, int w=0)
Definition: String.h:290
Impl(detail::CPool *pool_r, const SolvAttr &attr_r, Solvable solv_r)
Definition: lookupattr.cc:59
SolvableIdType size_type
Definition: poolconstants.h:59
bool solvAttrString() const
Whether this is a string attribute.
Definition: lookupattr.cc:360
zypp::sat::detail::IdType IdType
Definition: poolconstants.h:43
iterator begin() const
Iterator to the begin of query results.
Definition: lookupattr.cc:240
IdString idStr() const
As IdString.
Definition: lookupattr.cc:629
IdType id() const
Expert backdoor.
Definition: solvable.h:342
LookupAttr::iterator subFind(const SolvAttr &attr_r) const
Iterator pointing to the first occurrence of SolvAttr attr_r in the sub-structure.
Definition: lookupattr.cc:466
static CheckSum sha256(const std::string &checksum)
Definition: CheckSum.h:77
bool solvAttrIdString() const
Whether this string attribute is available as IdString.
Definition: lookupattr.cc:375
zypp::RWCOW_pointer< Impl > _pimpl
Definition: lookupattr.h:237
void setRepo(Repository repo_r)
Set search in one Repository.
Definition: lookupattr.cc:265
Search for repository attributes.
Definition: lookupattr.h:124
zypp::sat::detail::CDataiterator CDataiterator
Definition: poolconstants.h:33
int asInt() const
Conversion to numeric types.
Definition: lookupattr.cc:508
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition: solvable.cc:273
int get() const
Return the integer representation.
Definition: StrMatcher.h:150
unsigned asUnsigned() const
Definition: lookupattr.cc:523
IdType id() const
Expert backdoor.
Definition: repository.h:327
static const Solvable noSolvable
Represents no Solvable.
Definition: solvable.h:95
bool solvAttrSubEntry() const
Whether this is the entry to a sub-structure (flexarray).
Definition: lookupattr.cc:425
detail::CDataiterator * _dip
non-owning — current iterator position
Definition: lookupattr.h:591
Impl(detail::CPool *pool_r, const SolvAttr &attr_r, Repository repo_r, Location loc_r)
Definition: lookupattr.cc:56
static const IdType noId(0)
Wrapper around sat detail::CDataiterator.
Definition: lookupattr.h:293
static CheckSum sha384(const std::string &checksum)
Definition: CheckSum.h:78
CheckSum asCheckSum() const
As CheckSum.
Definition: lookupattr.cc:645
const Match & flags() const
The current search flags.
Definition: StrMatcher.cc:325
iterator end() const
Iterator behind the end of query results.
Definition: lookupattr.cc:243
LookupAttr::iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition: lookupattr.cc:461
bool empty() const
Definition: String.h:108
const StrMatcher & strMatcher() const
Definition: lookupattr.cc:75
bool solvAttrCheckSum() const
Whether this is a CheckSum attribute.
Definition: lookupattr.cc:388
static CheckSum sha1(const std::string &checksum)
Definition: CheckSum.h:75
Solvable solvable() const
Whether to search in one Solvable.
Definition: lookupattr.cc:228
std::string asString() const
Definition: capability.h:203
std::string asString() const
Conversion to std::string
Definition: IdString.h:110
Solvable inSolvable() const
The current Solvable.
Definition: lookupattr.cc:324
LookupRepoAttr()
Default ctor finds nothing.
Definition: lookupattr.h:262
iterator & operator=(const iterator &rhs)
Definition: lookupattr.cc:695
static CheckSum sha512(const std::string &checksum)
Definition: CheckSum.h:79
void setSolvable(Solvable solv_r)
Definition: lookupattr.cc:109
zypp::IdString IdString
Definition: idstring.h:16
bool operator==(const iterator &rhs) const
Definition: lookupattr.cc:729
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Definition: lookupattr.cc:330
zypp::sat::detail::RepoIdType RepoIdType
Definition: poolconstants.h:45
const std::string & searchstring() const
The current searchstring.
Definition: StrMatcher.cc:306
SolvAttr attr() const
The SolvAttr to search.
Definition: lookupattr.cc:204
void setRepo(Repository repo_r, Location loc_r)
Definition: lookupattr.cc:97
LookupAttr::iterator end() const
Definition: lookupattr.cc:143
bool pool() const
Whether to search in Pool.
Definition: lookupattr.cc:216