libzypp  17.1.1
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 
15 #include "zypp/base/LogTools.h"
16 #include "zypp/base/String.h"
17 
19 
20 #include "zypp/sat/Pool.h"
21 #include "zypp/sat/LookupAttr.h"
22 #include "zypp/base/StrMatcher.h"
23 
24 #include "zypp/CheckSum.h"
25 
26 using std::endl;
27 
29 namespace zypp
30 {
31  namespace sat
33  {
34 
36 
38  //
39  // CLASS NAME : LookupAttr::Impl
40  //
42 
56  {
57  public:
58  Impl()
59  : _parent( SolvAttr::noAttr )
60  {}
61  Impl( SolvAttr attr_r, Location loc_r )
62  : _attr( attr_r ), _parent( attr_r.parent() ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
63  {}
64  Impl( SolvAttr attr_r, Repository repo_r, Location loc_r )
65  : _attr( attr_r ), _parent( attr_r.parent() ), _repo( repo_r ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
66  {}
67  Impl( SolvAttr attr_r, Solvable solv_r )
68  : _attr( attr_r ), _parent( attr_r.parent() ), _solv( solv_r )
69  {}
70 
71  public:
72  SolvAttr attr() const
73  { return _attr; }
74 
75  void setAttr( SolvAttr attr_r )
76  {
77  _attr = attr_r;
78  SolvAttr p( _attr.parent() );
79  if ( p != SolvAttr::noAttr )
80  _parent = p;
81  }
82 
83  const StrMatcher & strMatcher() const
84  { return _strMatcher; }
85 
86  void setStrMatcher( const StrMatcher & matcher_r )
87  {
88  matcher_r.compile();
89  _strMatcher = matcher_r;
90  }
91 
92  public:
93  bool pool() const
94  { return ! (_repo || _solv); }
95 
96  void setPool( Location loc_r )
97  {
99  _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
100  }
101 
102  Repository repo() const
103  { return _repo; }
104 
105  void setRepo( Repository repo_r, Location loc_r )
106  {
107  _repo = repo_r;
108  _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
109  }
110 
112  { return _solv; }
113 
114  void setSolvable( Solvable solv_r )
115  {
117  _solv = solv_r;
118  }
119 
120  SolvAttr parent() const
121  { return _parent; }
122 
123  void setParent( SolvAttr attr_r )
124  { _parent = attr_r; }
125 
126  public:
128  {
129  if ( _attr == SolvAttr::noAttr || sat::Pool::instance().reposEmpty() )
130  return end();
131 
132  detail::RepoIdType whichRepo = detail::noRepoId; // all repos
133  if ( _solv )
134  whichRepo = _solv.repository().id();
135  else if ( _repo )
136  whichRepo = _repo.id();
137 
138  detail::DIWrap dip( whichRepo, _solv.id(), _attr.id(), _strMatcher.searchstring(), _strMatcher.flags().get() );
139  if ( _parent != SolvAttr::noAttr )
140  ::dataiterator_prepend_keyname( dip.get(), _parent.id() );
141 
142  return iterator( dip ); // iterator takes over ownership!
143  }
144 
146  { return iterator(); }
147 
148  private:
154 
155  private:
156  friend Impl * rwcowClone<Impl>( const Impl * rhs );
158  Impl * clone() const
159  { return new Impl( *this ); }
160  };
161 
163  //
164  // CLASS NAME : LookupAttr
165  //
167 
169  : _pimpl( new Impl )
170  {}
171 
173  : _pimpl( new Impl( attr_r, loc_r ) )
174  {}
176  : _pimpl( new Impl( attr_r, loc_r ) )
177  { _pimpl->setParent( parent_r ); }
178 
180  : _pimpl( new Impl( attr_r, repo_r, loc_r ) )
181  {}
182  LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Repository repo_r, Location loc_r )
183  : _pimpl( new Impl( attr_r, repo_r, loc_r ) )
184  { _pimpl->setParent( parent_r ); }
185 
187  : _pimpl( new Impl( attr_r, solv_r ) )
188  {}
189  LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Solvable solv_r )
190  : _pimpl( new Impl( attr_r, solv_r ) )
191  { _pimpl->setParent( parent_r ); }
192 
193 
195 
197  { return _pimpl->attr(); }
198 
200  { _pimpl->setAttr( attr_r ); }
201 
203  { return _pimpl->strMatcher(); }
204 
205  void LookupAttr::setStrMatcher( const StrMatcher & matcher_r )
206  { _pimpl->setStrMatcher( matcher_r ); }
207 
209 
210  bool LookupAttr::pool() const
211  { return _pimpl->pool(); }
212 
214  { _pimpl->setPool( loc_r ); }
215 
217  { return _pimpl->repo(); }
218 
220  { _pimpl->setRepo( repo_r, loc_r ); }
221 
223  { return _pimpl->solvable(); }
224 
226  { _pimpl->setSolvable( solv_r ); }
227 
229  { return _pimpl->parent(); }
230 
232  { _pimpl->setParent( attr_r ); }
233 
235 
237  { return _pimpl->begin(); }
238 
240  { return _pimpl->end(); }
241 
242  bool LookupAttr::empty() const
243  { return begin() == end(); }
244 
246  {
247  size_type c = 0;
248  for_( it, begin(), end() )
249  ++c;
250  return c;
251  }
252 
254 
255  std::ostream & operator<<( std::ostream & str, const LookupAttr & obj )
256  {
257  if ( obj.attr() == SolvAttr::noAttr )
258  return str << "search nothing";
259 
260  if ( obj.attr() )
261  str << "seach " << obj.attr() << " in ";
262  else
263  str << "seach ALL in ";
264 
265  if ( obj.solvable() )
266  return str << obj.solvable();
267  if ( obj.repo() )
268  return str << obj.repo();
269  return str << "pool";
270  }
271 
272  std::ostream & dumpOn( std::ostream & str, const LookupAttr & obj )
273  {
274  return dumpRange( str << obj, obj.begin(), obj.end() );
275  }
276 
278  //
279  // CLASS NAME : LookupRepoAttr
280  //
282 
284  : LookupAttr( attr_r, repo_r, REPO_ATTR )
285  {}
286 
288  { LookupAttr::setRepo( repo_r, REPO_ATTR ); }
289 
291  //
292  // CLASS NAME : detail::DIWrap
293  //
295 
296  namespace detail
297  {
298  DIWrap::DIWrap( RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
299  const std::string & mstring_r, int flags_r )
300  : _dip( new ::Dataiterator )
301  , _mstring( mstring_r )
302  {
303  ::dataiterator_init( _dip, sat::Pool::instance().get(), repoId_r, solvId_r, attrId_r,
304  _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
305  }
306 
307  DIWrap::DIWrap( RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
308  const char * mstring_r, int flags_r )
309  : _dip( new ::Dataiterator )
310  , _mstring( mstring_r ? mstring_r : "" )
311  {
312  ::dataiterator_init( _dip, sat::Pool::instance().get(), repoId_r, solvId_r, attrId_r,
313  _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
314  }
315 
316  DIWrap::DIWrap( const DIWrap & rhs )
317  : _dip( 0 )
318  , _mstring( rhs._mstring )
319  {
320  if ( rhs._dip )
321  {
322  _dip = new ::Dataiterator;
323  ::dataiterator_init_clone( _dip, rhs._dip );
324  ::dataiterator_strdup( _dip );
325  }
326  }
327 
329  {
330  if ( _dip )
331  {
332  ::dataiterator_free( _dip );
333  delete _dip;
334  }
335  }
336 
337  std::ostream & operator<<( std::ostream & str, const DIWrap & obj )
338  { return str << obj.get(); }
339  }
340 
342  //
343  // CLASS NAME : LookupAttr::iterator
344  //
346 
348  // position and moving
350 
352  { return _dip ? Repository( _dip->repo ) : Repository::noRepository; }
353 
355  { return _dip ? Solvable( _dip->solvid ) : Solvable::noSolvable; }
356 
358  { return _dip ? SolvAttr( _dip->key->name ) : SolvAttr::noAttr; }
359 
361  { if ( _dip ) ::dataiterator_skip_attribute( _dip.get() ); }
362 
364  { if ( _dip ) ::dataiterator_skip_solvable( _dip.get() ); }
365 
367  { if ( _dip ) ::dataiterator_skip_repo( _dip.get() ); }
368 
370  { if ( _dip ) { _dip.get()->repoid = -1; _dip.get()->flags |= SEARCH_THISSOLVID; } }
371 
373  { if ( _dip ) { _dip.get()->repoid = -1; } }
374 
376  // attr value type test
378 
380  { return _dip ? _dip->key->type : detail::noId; }
381 
383  {
384  switch ( solvAttrType() )
385  {
386  case REPOKEY_TYPE_U32:
387  case REPOKEY_TYPE_NUM:
388  case REPOKEY_TYPE_CONSTANT:
389  return true;
390  break;
391  }
392  return false;
393  }
394 
396  {
397  switch ( solvAttrType() )
398  {
399  case REPOKEY_TYPE_ID:
400  case REPOKEY_TYPE_IDARRAY:
401  case REPOKEY_TYPE_CONSTANTID:
402  case REPOKEY_TYPE_STR:
403  case REPOKEY_TYPE_DIRSTRARRAY:
404  return true;
405  break;
406  }
407  return false;
408  }
409 
411  {
412  switch ( solvAttrType() )
413  {
414  case REPOKEY_TYPE_ID:
415  case REPOKEY_TYPE_IDARRAY:
416  case REPOKEY_TYPE_CONSTANTID:
417  return true;
418  break;
419  }
420  return false;
421  }
422 
424  {
425  switch ( solvAttrType() )
426  {
427  case REPOKEY_TYPE_MD5:
428  case REPOKEY_TYPE_SHA1:
429  case REPOKEY_TYPE_SHA256:
430  return true;
431  break;
432  }
433  return false;
434  }
435 
437  namespace
438  {
439  enum SubType { ST_NONE, // no sub-structure
440  ST_FLEX, // flexarray
441  ST_SUB }; // inside sub-structure
442  SubType subType( const detail::DIWrap & dip )
443  {
444  if ( ! dip )
445  return ST_NONE;
446  if ( dip.get()->key->type == REPOKEY_TYPE_FLEXARRAY )
447  return ST_FLEX;
448  return dip.get()->kv.parent ? ST_SUB : ST_NONE;
449  }
450  }
452 
454  { return subType( _dip ) != ST_NONE; }
455 
457  // Iterate sub-structures.
459 
461  { return( subBegin() == subEnd() ); }
462 
464  {
465  size_type c = 0;
466  for_( it, subBegin(), subEnd() )
467  ++c;
468  return c;
469  }
470 
472  {
473  SubType subtype( subType( _dip ) );
474  if ( subtype == ST_NONE )
475  return subEnd();
476  // setup the new sub iterator with the remembered position
477  detail::DIWrap dip( 0, 0, 0 );
478  ::dataiterator_clonepos( dip.get(), _dip.get() );
479  switch ( subtype )
480  {
481  case ST_NONE: // not reached
482  break;
483  case ST_FLEX:
484  ::dataiterator_seek( dip.get(), DI_SEEK_CHILD|DI_SEEK_STAY );
485  break;
486  case ST_SUB:
487  ::dataiterator_seek( dip.get(), DI_SEEK_REWIND|DI_SEEK_STAY );
488  break;
489  }
490  return iterator( dip ); // iterator takes over ownership!
491  }
492 
494  {
495  return iterator();
496  }
497 
499  {
500  iterator it = subBegin();
501  if ( attr_r != sat::SolvAttr::allAttr )
502  {
503  while ( it != subEnd() && it.inSolvAttr() != attr_r )
504  ++it;
505  }
506  return it;
507  }
508 
510  {
511  if ( attrname_r.empty() )
512  return subBegin();
513 
514  SubType subtype( subType( _dip ) );
515  if ( subtype == ST_NONE )
516  return subBegin();
517 
518  std::string subattr( inSolvAttr().asString() );
519  if ( subtype == ST_FLEX )
520  {
521  // append ":attrname"
522  subattr += ":";
523  subattr += attrname_r;
524  }
525  else
526  {
527  // replace "oldname" after ':' with "attrname"
528  std::string::size_type pos( subattr.rfind( ':' ) );
529  if ( pos != std::string::npos )
530  {
531  subattr.erase( pos+1 );
532  subattr += attrname_r;
533  }
534  else
535  subattr = attrname_r; // no ':' so replace all.
536  }
537  return subFind( SolvAttr( subattr ) );
538  }
539 
541  // attr value retrieval
543 
545  {
546  if ( _dip )
547  {
548  switch ( solvAttrType() )
549  {
550  case REPOKEY_TYPE_U32:
551  case REPOKEY_TYPE_NUM:
552  case REPOKEY_TYPE_CONSTANT:
553  return _dip->kv.num;
554  break;
555  }
556  }
557  return 0;
558  }
559 
561  { return asInt(); }
562 
563  unsigned long long LookupAttr::iterator::asUnsignedLL() const
564  {
565  if ( _dip )
566  {
567  switch ( solvAttrType() )
568  {
569  case REPOKEY_TYPE_U32:
570  case REPOKEY_TYPE_NUM:
571  case REPOKEY_TYPE_CONSTANT:
572  return SOLV_KV_NUM64(&_dip->kv);
573  break;
574  }
575  }
576  return 0;
577  }
578 
580  { return asInt(); }
581 
582 
583  const char * LookupAttr::iterator::c_str() const
584  {
585  if ( _dip )
586  {
587  switch ( solvAttrType() )
588  {
589  case REPOKEY_TYPE_ID:
590  case REPOKEY_TYPE_IDARRAY:
591  case REPOKEY_TYPE_CONSTANTID:
592  if ( _dip->data && _dip->data->localpool )
593  return ::stringpool_id2str( &_dip->data->spool, _dip->kv.id ); // in local pool
594  else
595  return IdString( _dip->kv.id ).c_str(); // in global pool
596  break;
597 
598  case REPOKEY_TYPE_STR:
599  return _dip->kv.str;
600  break;
601 
602  case REPOKEY_TYPE_DIRSTRARRAY:
603  // may or may not be stringified depending on SEARCH_FILES flag
604  return( _dip->flags & SEARCH_FILES
605  ? _dip->kv.str
606  : ::repodata_dir2str( _dip->data, _dip->kv.id, _dip->kv.str ) );
607  break;
608  }
609  }
610  return 0;
611  }
612 
613  std::string LookupAttr::iterator::asString() const
614  {
615  if ( _dip )
616  {
617  switch ( solvAttrType() )
618  {
619  case REPOKEY_TYPE_ID:
620  case REPOKEY_TYPE_IDARRAY:
621  case REPOKEY_TYPE_CONSTANTID:
622  {
623  detail::IdType id = ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 );
624  return ISRELDEP(id) ? Capability( id ).asString()
625  : IdString( id ).asString();
626  }
627  break;
628 
629  case REPOKEY_TYPE_STR:
630  case REPOKEY_TYPE_DIRSTRARRAY:
631  {
632  const char * ret( c_str() );
633  return ret ? ret : "";
634  }
635  break;
636 
637  case REPOKEY_TYPE_U32:
638  case REPOKEY_TYPE_NUM:
639  case REPOKEY_TYPE_CONSTANT:
640  return str::numstring( asInt() );
641  break;
642 
643  case REPOKEY_TYPE_MD5:
644  case REPOKEY_TYPE_SHA1:
645  case REPOKEY_TYPE_SHA256:
646  {
647  return asCheckSum().asString();
648  }
649  break;
650 
651  case REPOKEY_TYPE_FLEXARRAY:
652  {
653  std::ostringstream str;
654  str << "{" << endl;
655  for_( it, subBegin(), subEnd() )
656  {
657  str << " " << it.inSolvAttr() << " = " << it.asString() << endl;
658  }
659  str << "}";
660  return str.str();
661  }
662  break;
663  }
664  }
665  return std::string();
666  }
667 
669  {
670  if ( _dip )
671  {
672  switch ( solvAttrType() )
673  {
674  case REPOKEY_TYPE_ID:
675  case REPOKEY_TYPE_IDARRAY:
676  case REPOKEY_TYPE_CONSTANTID:
677  return IdString( ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 ) );
678  break;
679  }
680  }
681  return IdString();
682  }
683 
685  {
686  if ( _dip )
687  {
688  switch ( solvAttrType() )
689  {
690  case REPOKEY_TYPE_MD5:
691  return CheckSum::md5( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
692  break;
693 
694  case REPOKEY_TYPE_SHA1:
695  return CheckSum::sha1( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
696  break;
697 
698  case REPOKEY_TYPE_SHA224:
699  return CheckSum::sha224( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
700  break;
701 
702  case REPOKEY_TYPE_SHA256:
703  return CheckSum::sha256( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
704  break;
705 
706  case REPOKEY_TYPE_SHA384:
707  return CheckSum::sha384( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
708  break;
709 
710  case REPOKEY_TYPE_SHA512:
711  return CheckSum::sha512( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
712  break;
713  }
714  }
715  return CheckSum();
716  }
717 
719  // internal stuff below
721 
723  : iterator_adaptor_( 0 )
724  {}
725 
727  : iterator_adaptor_( 0 )
728  , _dip( rhs._dip )
729  {
730  base_reference() = _dip.get();
731  }
732 
734  : iterator_adaptor_( 0 )
735  {
736  _dip.swap( dip_r ); // take ownership!
737  base_reference() = _dip.get();
738  increment();
739  }
740 
742  {}
743 
745  {
746  if ( &rhs != this )
747  {
748  _dip = rhs._dip;
749  base_reference() = _dip.get();
750  }
751  return *this;
752  }
753 
755 
757  {
758  // Iterator equal is same position in same container.
759  // Here: same attribute in same solvable.
760  return( lhs.solvid == rhs.solvid && lhs.key->name == rhs.key->name );
761  }
762 
764  {
765  return _dip ? ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 )
766  : detail::noId;
767  }
768 
770  {
771  if ( _dip )
772  {
773  if ( ! ::dataiterator_step( _dip.get() ) )
774  {
775  _dip.reset();
776  base_reference() = 0;
777  }
778  else
779  {
780  ::dataiterator_strdup( _dip.get() );
781  }
782  }
783  }
784 
785  std::ostream & operator<<( std::ostream & str, const LookupAttr::iterator & obj )
786  {
787  const detail::CDataiterator * dip = obj.get();
788  if ( ! dip )
789  return str << "EndOfQuery";
790 
791  if ( obj.inSolvable() )
792  str << obj.inSolvable();
793  else if ( obj.inRepo() )
794  str << obj.inRepo();
795 
796  str << '<' << obj.inSolvAttr() << (obj.solvAttrSubEntry() ? ">(*" : ">(")
797  << IdString(obj.solvAttrType()) << ") = " << obj.asString();
798  return str;
799  }
800 
801  template<> CheckSum LookupAttr::iterator::asType<CheckSum>() const
802  { return asCheckSum(); }
803 
805  } // namespace sat
808 } // namespace zypp
810 
811 std::ostream & operator<<( std::ostream & str, const zypp::sat::detail::CDataiterator * obj )
812 {
813  str << "detail::CDataiterator(";
814  if ( ! obj )
815  {
816  str << "NULL";
817  }
818  else
819  {
820  str << "|" << zypp::Repository(obj->repo);
821  str << "|" << zypp::sat::Solvable(obj->solvid);
822  str << "|" << zypp::IdString(obj->key->name);
823  str << "|" << zypp::IdString(obj->key->type);
824  str << "|" << obj->repodataid;
825  str << "|" << obj->repoid;
826  }
827  return str << ")";
828 }
829 
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
void stayInThisRepo()
Stop after all matches in the current Repository are processed.
Definition: LookupAttr.cc:372
DIWrap()
NULL detail::CDataiterator
Definition: LookupAttr.h:296
void setStrMatcher(const StrMatcher &matcher_r)
Definition: LookupAttr.cc:86
SolvAttr parent() const
Whether to search within a sub-structure (SolvAttr::noAttr if not)
Definition: LookupAttr.cc:228
int IdType
Generic Id type.
Definition: PoolMember.h:104
A Solvable object within the sat Pool.
Definition: Solvable.h:53
SolvAttr parent() const
Return the parent of well know sub-structure attributes (SolvAttr::noAttr if none).
Definition: SolvAttr.cc:151
bool subEmpty() const
Whether the sub-structure is empty.
Definition: LookupAttr.cc:460
IdString idStr() const
As IdStr.
Definition: LookupAttr.cc:668
IdType id() const
Expert backdoor.
Definition: Solvable.h:385
LookupAttr::iterator end() const
Definition: LookupAttr.cc:145
void setPool(Location=SOLV_ATTR)
Set search in Pool (all repositories).
Definition: LookupAttr.cc:213
IdType id() const
Definition: IdStringType.h:108
Solvable solvable() const
Whether to search in one Solvable.
Definition: LookupAttr.cc:222
iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition: LookupAttr.cc:493
::_Dataiterator CDataiterator
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:58
void setAttr(SolvAttr attr_r)
Set the SolvAttr to search.
Definition: LookupAttr.cc:199
Impl(SolvAttr attr_r, Solvable solv_r)
Definition: LookupAttr.cc:67
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
static const SolvAttr allAttr
Value to request searching all Attributes (0).
Definition: SolvAttr.h:46
detail::IdType solvAttrType() const
The current SolvAttr type.
Definition: LookupAttr.cc:379
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition: StrMatcher.h:297
bool solvAttrCheckSum() const
Whether this is a CheckSum attribute.
Definition: LookupAttr.cc:423
const StrMatcher & strMatcher() const
The pattern to match.
Definition: LookupAttr.cc:202
bool solvAttrString() const
Whether this is a string attribute.
Definition: LookupAttr.cc:395
Lightweight attribute value lookup.
Definition: LookupAttr.h:107
detail::CDataiterator * get() const
Expert backdoor.
Definition: LookupAttr.h:568
::_Repo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
void setRepo(Repository repo_r, Location loc_r)
Definition: LookupAttr.cc:105
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\ ", const std::string &sep="\ ", const std::string &sfx="\, const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition: LogTools.h:91
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
void setParent(SolvAttr attr_r)
Set search within a sub-structure (SolvAttr::noAttr for none)
Definition: LookupAttr.cc:231
void setSolvable(Solvable solv_r)
Set search in one Solvable.
Definition: LookupAttr.cc:225
void setPool(Location loc_r)
Definition: LookupAttr.cc:96
String related utilities and Regular expression matching.
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
detail::CDataiterator * get() const
Definition: LookupAttr.h:331
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Definition: LookupAttr.cc:360
std::ostream & operator<<(std::ostream &str, const DIWrap &obj)
Definition: LookupAttr.cc:337
Access to the sat-pools string space.
Definition: IdString.h:41
RWCOW_pointer< Impl > _pimpl
Definition: LookupAttr.h:226
void setSolvable(Solvable solv_r)
Definition: LookupAttr.cc:114
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
detail::IdType dereference() const
Definition: LookupAttr.cc:763
const StrMatcher & strMatcher() const
Definition: LookupAttr.cc:83
static CheckSum md5(const std::string &checksum)
Definition: CheckSum.h:75
bool dip_equal(const detail::CDataiterator &lhs, const detail::CDataiterator &rhs) const
Definition: LookupAttr.cc:756
SolvAttr attr() const
Definition: LookupAttr.cc:72
LookupAttr()
Default ctor finds nothing.
Definition: LookupAttr.cc:168
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:71
LookupAttr implememtation.
Definition: LookupAttr.cc:55
void setRepo(Repository repo_r)
Set search in one Repository.
Definition: LookupAttr.cc:287
iterator & operator=(const iterator &rhs)
Definition: LookupAttr.cc:744
bool solvAttrNumeric() const
Whether this is a numeric attribute (incl.
Definition: LookupAttr.cc:382
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:239
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:359
void compile() const
Compile the pattern e.g.
Definition: StrMatcher.cc:292
static Pool instance()
Singleton ctor.
Definition: Pool.h:53
Solvable attribute keys.
Definition: SolvAttr.h:40
void setRepo(Repository repo_r, Location=SOLV_ATTR)
Set search in one Repository.
Definition: LookupAttr.cc:219
std::ostream & dumpOn(std::ostream &str, const LookupAttr &obj)
Definition: LookupAttr.cc:272
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition: LookupAttr.cc:357
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:90
static CheckSum sha224(const std::string &checksum)
Definition: CheckSum.h:78
SolvAttr parent() const
Definition: LookupAttr.cc:120
Wrapper around sat detail::CDataiterator.
Definition: LookupAttr.h:292
void stayInThisSolvable()
Stop after all matches in the current Solvable are processed.
Definition: LookupAttr.cc:369
Impl * clone() const
clone for RWCOW_pointer
Definition: LookupAttr.cc:158
LookupAttr::iterator begin() const
Definition: LookupAttr.cc:127
void setStrMatcher(const StrMatcher &matcher_r)
Set the pattern to match.
Definition: LookupAttr.cc:205
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
Definition: LookupAttr.cc:363
void setAttr(SolvAttr attr_r)
Definition: LookupAttr.cc:75
void swap(DIWrap &rhs)
Definition: LookupAttr.h:308
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:50
int asInt() const
Conversion to numeric types.
Definition: LookupAttr.cc:544
std::string numstring(char n, int w=0)
Definition: String.h:305
LookupRepoAttr()
Default ctor finds nothing.
Definition: LookupAttr.h:261
SolvableIdType size_type
Definition: PoolMember.h:126
static CheckSum sha256(const std::string &checksum)
Definition: CheckSum.h:79
bool pool() const
Whether to search in Pool.
Definition: LookupAttr.cc:210
size_type subSize() const
Ammount of attributes in the sub-structure.
Definition: LookupAttr.cc:463
SolvAttr attr() const
The SolvAttr to search.
Definition: LookupAttr.cc:196
static const SolvAttr noAttr
Value representing noAttr ("")
Definition: SolvAttr.h:48
Repository repo() const
Whether to search in one Repository.
Definition: LookupAttr.cc:216
iterator subFind(SolvAttr attr_r) const
Iterator pointing to the first occurance of SolvAttr attr_r in sub-structure.
Definition: LookupAttr.cc:498
Impl(SolvAttr attr_r, Repository repo_r, Location loc_r)
Definition: LookupAttr.cc:64
std::ostream & operator<<(std::ostream &str, const LookupAttr &obj)
Definition: LookupAttr.cc:255
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:62
int get() const
Return the integer representation.
Definition: StrMatcher.h:150
Solvable inSolvable() const
The current Solvable.
Definition: LookupAttr.cc:354
Impl(SolvAttr attr_r, Location loc_r)
Definition: LookupAttr.cc:61
void setParent(SolvAttr attr_r)
Definition: LookupAttr.cc:123
A sat capability.
Definition: Capability.h:59
Solvable solvable() const
Definition: LookupAttr.cc:111
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition: LookupAttr.cc:366
static const IdType noId(0)
static CheckSum sha384(const std::string &checksum)
Definition: CheckSum.h:80
detail::CDataiterator * _dip
Definition: LookupAttr.h:335
const Match & flags() const
The current search flags.
Definition: StrMatcher.cc:320
bool empty() const
Definition: String.h:104
static CheckSum sha1(const std::string &checksum)
Definition: CheckSum.h:77
bool solvAttrIdString() const
Whether this string attribute is available as IdString.
Definition: LookupAttr.cc:410
std::string asString() const
Conversion to std::string
Definition: IdString.h:91
CheckSum asCheckSum() const
As CheckSum.
Definition: LookupAttr.cc:684
size_type size() const
Ammount of results.
Definition: LookupAttr.cc:245
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: LookupAttr.cc:613
static CheckSum sha512(const std::string &checksum)
Definition: CheckSum.h:81
std::string asString() const
Definition: Capability.h:158
IdType id() const
Expert backdoor.
Definition: Repository.h:307
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition: LookupAttr.cc:471
Repository inRepo() const
The current Repository.
Definition: LookupAttr.cc:351
bool solvAttrSubEntry() const
Whether this is the entry to a sub-structure (flexarray).
Definition: LookupAttr.cc:453
Location
Specify the where to look for the attribule.
Definition: LookupAttr.h:116
unsigned long long asUnsignedLL() const
Definition: LookupAttr.cc:563
bool empty() const
Whether the query is empty.
Definition: LookupAttr.cc:242
const std::string & searchstring() const
The current searchstring.
Definition: StrMatcher.cc:301
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:236
const char * c_str() const
Conversion to string types.
Definition: LookupAttr.cc:583
Repository repo() const
Definition: LookupAttr.cc:102
Search for repository attributes.
Definition: LookupAttr.h:118
std::ostream & operator<<(std::ostream &str, const LookupAttr::iterator &obj)
Definition: LookupAttr.cc:785