libzypp 17.37.10

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
16#include <zypp/base/LogTools.h>
17#include <zypp/base/String.h>
18
19#include <zypp/sat/detail/PoolImpl.h>
20
21#include <zypp/sat/Pool.h>
22#include <zypp/sat/LookupAttr.h>
23#include <zypp/base/StrMatcher.h>
24
25#include <zypp/CheckSum.h>
26
27 using std::endl;
28
30 namespace zypp
31{
33 namespace sat
34 {
35
36 using detail::noSolvableId;
37
39 //
40 // CLASS NAME : LookupAttr::Impl
41 //
43
56 class LookupAttr::Impl
57 {
58 public:
59 Impl()
60 : _parent( SolvAttr::noAttr )
61 {}
62 Impl( const SolvAttr& attr_r, Location loc_r )
63 : _attr( attr_r ), _parent( attr_r.parent() ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
64 {}
65 Impl( const SolvAttr& attr_r, Repository repo_r, Location loc_r )
66 : _attr( attr_r ), _parent( attr_r.parent() ), _repo( repo_r ), _solv( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId )
67 {}
68 Impl( const SolvAttr& attr_r, Solvable solv_r )
69 : _attr( attr_r ), _parent( attr_r.parent() ), _solv( solv_r )
70 {}
71
72 public:
73 SolvAttr attr() const
74 { return _attr; }
75
76 void setAttr( SolvAttr attr_r )
77 {
78 _attr = std::move(attr_r);
79 SolvAttr p( _attr.parent() );
80 if ( p != SolvAttr::noAttr )
81 _parent = p;
82 }
83
84 const StrMatcher & strMatcher() const
85 { return _strMatcher; }
86
87 void setStrMatcher( const StrMatcher & matcher_r )
88 {
89 matcher_r.compile();
90 _strMatcher = matcher_r;
91 }
92
93 public:
94 bool pool() const
95 { return ! (_repo || _solv); }
96
97 void setPool( Location loc_r )
98 {
99 _repo = Repository::noRepository;
100 _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
101 }
102
103 Repository repo() const
104 { return _repo; }
105
106 void setRepo( Repository repo_r, Location loc_r )
107 {
108 _repo = repo_r;
109 _solv = Solvable( loc_r == REPO_ATTR ? SOLVID_META : noSolvableId );
110 }
111
112 Solvable solvable() const
113 { return _solv; }
114
115 void setSolvable( Solvable solv_r )
116 {
117 _repo = Repository::noRepository;
118 _solv = solv_r;
119 }
120
121 SolvAttr parent() const
122 { return _parent; }
123
124 void setParent( SolvAttr attr_r )
125 { _parent = std::move(attr_r); }
126
127 public:
128 LookupAttr::iterator begin() const
129 {
130 if ( _attr == SolvAttr::noAttr || sat::Pool::instance().reposEmpty() )
131 return end();
132
133 detail::RepoIdType whichRepo = detail::noRepoId; // all repos
134 if ( _solv )
135 whichRepo = _solv.repository().id();
136 else if ( _repo )
137 whichRepo = _repo.id();
138
139 detail::DIWrap dip( whichRepo, _solv.id(), _attr.id(), _strMatcher.searchstring(), _strMatcher.flags().get() );
140 if ( _parent != SolvAttr::noAttr )
141 ::dataiterator_prepend_keyname( dip.get(), _parent.id() );
142
143 return iterator( dip ); // iterator takes over ownership!
144 }
145
146 LookupAttr::iterator end() const
147 { return iterator(); }
148
149 private:
150 SolvAttr _attr;
151 SolvAttr _parent;
152 Repository _repo;
153 Solvable _solv;
154 StrMatcher _strMatcher;
155
156 private:
157 friend Impl * rwcowClone<Impl>( const Impl * rhs );
159 Impl * clone() const
160 { return new Impl( *this ); }
161 };
162
164 //
165 // CLASS NAME : LookupAttr
166 //
168
169 LookupAttr::LookupAttr()
170 : _pimpl( new Impl )
171 {}
172
173 LookupAttr::LookupAttr( SolvAttr attr_r, Location loc_r )
174 : _pimpl( new Impl( std::move(attr_r), std::move(loc_r) ) )
175 {}
176 LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Location loc_r )
177 : _pimpl( new Impl( std::move(attr_r), std::move(loc_r) ) )
178 { _pimpl->setParent( std::move(parent_r) ); }
179
180 LookupAttr::LookupAttr( SolvAttr attr_r, Repository repo_r, Location loc_r )
181 : _pimpl( new Impl( std::move(attr_r), std::move(repo_r), std::move(loc_r) ) )
182 {}
183 LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Repository repo_r, Location loc_r )
184 : _pimpl( new Impl( std::move(attr_r), std::move(repo_r), std::move(loc_r) ) )
185 { _pimpl->setParent( std::move(parent_r) ); }
186
187 LookupAttr::LookupAttr( SolvAttr attr_r, Solvable solv_r )
188 : _pimpl( new Impl( std::move(attr_r), std::move(solv_r) ) )
189 {}
190 LookupAttr::LookupAttr( SolvAttr attr_r, SolvAttr parent_r, Solvable solv_r )
191 : _pimpl( new Impl( std::move(attr_r), std::move(solv_r) ) )
192 { _pimpl->setParent( std::move(parent_r) ); }
193
194
196
197 SolvAttr LookupAttr::attr() const
198 { return _pimpl->attr(); }
199
200 void LookupAttr::setAttr( SolvAttr attr_r )
201 { _pimpl->setAttr( std::move(attr_r) ); }
202
203 const StrMatcher & LookupAttr::strMatcher() const
204 { return _pimpl->strMatcher(); }
205
206 void LookupAttr::setStrMatcher( const StrMatcher & matcher_r )
207 { _pimpl->setStrMatcher( matcher_r ); }
208
210
211 bool LookupAttr::pool() const
212 { return _pimpl->pool(); }
213
214 void LookupAttr::setPool( Location loc_r )
215 { _pimpl->setPool( loc_r ); }
216
217 Repository LookupAttr::repo() const
218 { return _pimpl->repo(); }
219
220 void LookupAttr::setRepo( Repository repo_r, Location loc_r )
221 { _pimpl->setRepo( repo_r, loc_r ); }
222
223 Solvable LookupAttr::solvable() const
224 { return _pimpl->solvable(); }
225
226 void LookupAttr::setSolvable( Solvable solv_r )
227 { _pimpl->setSolvable( solv_r ); }
228
229 SolvAttr LookupAttr::parent() const
230 { return _pimpl->parent(); }
231
232 void LookupAttr::setParent( SolvAttr attr_r )
233 { _pimpl->setParent( std::move(attr_r) ); }
234
236
237 LookupAttr::iterator LookupAttr::begin() const
238 { return _pimpl->begin(); }
239
240 LookupAttr::iterator LookupAttr::end() const
241 { return _pimpl->end(); }
242
243 bool LookupAttr::empty() const
244 { return begin() == end(); }
245
246 LookupAttr::size_type LookupAttr::size() const
247 {
248 size_type c = 0;
249 for_( it, begin(), end() )
250 ++c;
251 return c;
252 }
253
255
256 std::ostream & operator<<( std::ostream & str, const LookupAttr & obj )
257 {
258 if ( obj.attr() == SolvAttr::noAttr )
259 return str << "search nothing";
260
261 if ( obj.attr() )
262 str << "search " << obj.attr() << " in ";
263 else
264 str << "search ALL in ";
265
266 if ( obj.solvable() )
267 return str << obj.solvable();
268 if ( obj.repo() )
269 return str << obj.repo();
270 return str << "pool";
271 }
272
273 std::ostream & dumpOn( std::ostream & str, const LookupAttr & obj )
274 {
275 return dumpRange( str << obj, obj.begin(), obj.end() );
276 }
277
279 //
280 // CLASS NAME : LookupRepoAttr
281 //
283
284 LookupRepoAttr::LookupRepoAttr( SolvAttr attr_r, Repository repo_r )
285 : LookupAttr( std::move(attr_r), repo_r, REPO_ATTR )
286 {}
287
288 void LookupRepoAttr::setRepo( Repository repo_r )
289 { LookupAttr::setRepo( repo_r, REPO_ATTR ); }
290
292 //
293 // CLASS NAME : detail::DIWrap
294 //
296
297 namespace detail
298 {
299 DIWrap::DIWrap( RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
300 std::string mstring_r, int flags_r )
301 : _dip( new ::Dataiterator )
302 , _mstring(std::move( mstring_r ))
303 {
304 ::dataiterator_init( _dip, sat::Pool::instance().get(), repoId_r, solvId_r, attrId_r,
305 _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
306 }
307
308 DIWrap::DIWrap( RepoIdType repoId_r, SolvableIdType solvId_r, IdType attrId_r,
309 const char * mstring_r, int flags_r )
310 : _dip( new ::Dataiterator )
311 , _mstring( mstring_r ? mstring_r : "" )
312 {
313 ::dataiterator_init( _dip, sat::Pool::instance().get(), repoId_r, solvId_r, attrId_r,
314 _mstring.empty() ? 0 : _mstring.c_str(), flags_r );
315 }
316
317 DIWrap::DIWrap( const DIWrap & rhs )
318 : _dip( 0 )
319 , _mstring( rhs._mstring )
320 {
321 if ( rhs._dip )
322 {
323 _dip = new ::Dataiterator;
324 ::dataiterator_init_clone( _dip, rhs._dip );
325 ::dataiterator_strdup( _dip );
326 }
327 }
328
329 DIWrap::~DIWrap()
330 {
331 if ( _dip )
332 {
333 ::dataiterator_free( _dip );
334 delete _dip;
335 }
336 }
337
338 std::ostream & operator<<( std::ostream & str, const DIWrap & obj )
339 { return str << obj.get(); }
340 }
341
343 //
344 // CLASS NAME : LookupAttr::iterator
345 //
347
349 // position and moving
351
352 Repository LookupAttr::iterator::inRepo() const
353 { return _dip ? Repository( _dip->repo ) : Repository::noRepository; }
354
355 Solvable LookupAttr::iterator::inSolvable() const
356 { return _dip ? Solvable( _dip->solvid ) : Solvable::noSolvable; }
357
358 SolvAttr LookupAttr::iterator::inSolvAttr() const
359 { return _dip ? SolvAttr( _dip->key->name ) : SolvAttr::noAttr; }
360
361 void LookupAttr::iterator::nextSkipSolvAttr()
362 { if ( _dip ) ::dataiterator_skip_attribute( _dip.get() ); }
363
364 void LookupAttr::iterator::nextSkipSolvable()
365 { if ( _dip ) ::dataiterator_skip_solvable( _dip.get() ); }
366
367 void LookupAttr::iterator::nextSkipRepo()
368 { if ( _dip ) ::dataiterator_skip_repo( _dip.get() ); }
369
370 void LookupAttr::iterator::stayInThisSolvable()
371 { if ( _dip ) { _dip.get()->repoid = -1; _dip.get()->flags |= SEARCH_THISSOLVID; } }
372
373 void LookupAttr::iterator::stayInThisRepo()
374 { if ( _dip ) { _dip.get()->repoid = -1; } }
375
377 // attr value type test
379
380 detail::IdType LookupAttr::iterator::solvAttrType() const
381 { return _dip ? _dip->key->type : detail::noId; }
382
383 bool LookupAttr::iterator::solvAttrNumeric() const
384 {
385 switch ( solvAttrType() )
386 {
387 case REPOKEY_TYPE_NUM:
388 case REPOKEY_TYPE_CONSTANT:
389 return true;
390 break;
391 }
392 return false;
393 }
394
395 bool LookupAttr::iterator::solvAttrString() const
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
410 bool LookupAttr::iterator::solvAttrIdString() const
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
423 bool LookupAttr::iterator::solvAttrCheckSum() const
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
453 bool LookupAttr::iterator::solvAttrSubEntry() const
454 { return subType( _dip ) != ST_NONE; }
455
457 // Iterate sub-structures.
459
460 bool LookupAttr::iterator::subEmpty() const
461 { return( subBegin() == subEnd() ); }
462
463 LookupAttr::size_type LookupAttr::iterator::subSize() const
464 {
465 size_type c = 0;
466 for_( it, subBegin(), subEnd() )
467 ++c;
468 return c;
469 }
470
471 LookupAttr::iterator LookupAttr::iterator::subBegin() const
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
493 LookupAttr::iterator LookupAttr::iterator::subEnd() const
494 {
495 return iterator();
496 }
497
498 LookupAttr::iterator LookupAttr::iterator::subFind( const SolvAttr& attr_r ) const
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
509 LookupAttr::iterator LookupAttr::iterator::subFind( const C_Str & attrname_r ) const
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
544 int LookupAttr::iterator::asInt() const
545 {
546 if ( _dip )
547 {
548 switch ( solvAttrType() )
549 {
550 case REPOKEY_TYPE_NUM:
551 case REPOKEY_TYPE_CONSTANT:
552 return _dip->kv.num;
553 break;
554 }
555 }
556 return 0;
557 }
558
559 unsigned LookupAttr::iterator::asUnsigned() const
560 { return asInt(); }
561
562 unsigned long long LookupAttr::iterator::asUnsignedLL() const
563 {
564 if ( _dip )
565 {
566 switch ( solvAttrType() )
567 {
568 case REPOKEY_TYPE_NUM:
569 case REPOKEY_TYPE_CONSTANT:
570 return SOLV_KV_NUM64(&_dip->kv);
571 break;
572 }
573 }
574 return 0;
575 }
576
577 bool LookupAttr::iterator::asBool() const
578 { return asInt(); }
579
580
581 const char * LookupAttr::iterator::c_str() const
582 {
583 if ( _dip )
584 {
585 switch ( solvAttrType() )
586 {
587 case REPOKEY_TYPE_ID:
588 case REPOKEY_TYPE_IDARRAY:
589 case REPOKEY_TYPE_CONSTANTID:
590 if ( _dip->data && _dip->data->localpool )
591 return ::stringpool_id2str( &_dip->data->spool, _dip->kv.id ); // in local pool
592 else
593 return IdString( _dip->kv.id ).c_str(); // in global pool
594 break;
595
596 case REPOKEY_TYPE_STR:
597 return _dip->kv.str;
598 break;
599
600 case REPOKEY_TYPE_DIRSTRARRAY:
601 // may or may not be stringified depending on SEARCH_FILES flag
602 return( _dip->flags & SEARCH_FILES
603 ? _dip->kv.str
604 : ::repodata_dir2str( _dip->data, _dip->kv.id, _dip->kv.str ) );
605 break;
606 }
607 }
608 return 0;
609 }
610
611 std::string LookupAttr::iterator::asString() const
612 {
613 if ( _dip )
614 {
615 switch ( solvAttrType() )
616 {
617 case REPOKEY_TYPE_ID:
618 case REPOKEY_TYPE_IDARRAY:
619 case REPOKEY_TYPE_CONSTANTID:
620 {
621 detail::IdType id = ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 );
622 return ISRELDEP(id) ? Capability( id ).asString()
623 : IdString( id ).asString();
624 }
625 break;
626
627 case REPOKEY_TYPE_STR:
628 case REPOKEY_TYPE_DIRSTRARRAY:
629 {
630 const char * ret( c_str() );
631 return ret ? ret : "";
632 }
633 break;
634
635 case REPOKEY_TYPE_NUM:
636 case REPOKEY_TYPE_CONSTANT:
637 return str::numstring( asInt() );
638 break;
639
640 case REPOKEY_TYPE_MD5:
641 case REPOKEY_TYPE_SHA1:
642 case REPOKEY_TYPE_SHA256:
643 {
644 return asCheckSum().asString();
645 }
646 break;
647
648 case REPOKEY_TYPE_FLEXARRAY:
649 {
650 std::ostringstream str;
651 str << "{" << endl;
652 for_( it, subBegin(), subEnd() )
653 {
654 str << " " << it.inSolvAttr() << " = " << it.asString() << endl;
655 }
656 str << "}";
657 return str.str();
658 }
659 break;
660 }
661 }
662 return std::string();
663 }
664
665 IdString LookupAttr::iterator::idStr() const
666 {
667 if ( _dip )
668 {
669 switch ( solvAttrType() )
670 {
671 case REPOKEY_TYPE_ID:
672 case REPOKEY_TYPE_IDARRAY:
673 case REPOKEY_TYPE_CONSTANTID:
674 return IdString( ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 ) );
675 break;
676 }
677 }
678 return IdString();
679 }
680
681 CheckSum LookupAttr::iterator::asCheckSum() const
682 {
683 if ( _dip )
684 {
685 switch ( solvAttrType() )
686 {
687 case REPOKEY_TYPE_MD5:
688 return CheckSum::md5( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
689 break;
690
691 case REPOKEY_TYPE_SHA1:
692 return CheckSum::sha1( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
693 break;
694
695 case REPOKEY_TYPE_SHA224:
696 return CheckSum::sha224( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
697 break;
698
699 case REPOKEY_TYPE_SHA256:
700 return CheckSum::sha256( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
701 break;
702
703 case REPOKEY_TYPE_SHA384:
704 return CheckSum::sha384( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
705 break;
706
707 case REPOKEY_TYPE_SHA512:
708 return CheckSum::sha512( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) );
709 break;
710 }
711 }
712 return CheckSum();
713 }
714
716 // internal stuff below
718
719 LookupAttr::iterator::iterator()
720 : iterator_adaptor_( 0 )
721 {}
722
723 LookupAttr::iterator::iterator( const iterator & rhs )
724 : iterator_adaptor_( 0 )
725 , _dip( rhs._dip )
726 {
727 base_reference() = _dip.get();
728 }
729
730 LookupAttr::iterator::iterator( detail::DIWrap & dip_r )
731 : iterator_adaptor_( 0 )
732 {
733 _dip.swap( dip_r ); // take ownership!
734 base_reference() = _dip.get();
735 increment();
736 }
737
738 LookupAttr::iterator::~iterator()
739 {}
740
741 LookupAttr::iterator & LookupAttr::iterator::operator=( const iterator & rhs )
742 {
743 if ( &rhs != this )
744 {
745 _dip = rhs._dip;
746 base_reference() = _dip.get();
747 }
748 return *this;
749 }
750
752
753 bool LookupAttr::iterator::dip_equal( const detail::CDataiterator & lhs, const detail::CDataiterator & rhs ) const
754 {
755 // Iterator equal is same position in same container.
756 // Here: same attribute in same solvable.
757 return( lhs.solvid == rhs.solvid && lhs.key->name == rhs.key->name );
758 }
759
760 detail::IdType LookupAttr::iterator::dereference() const
761 {
762 return _dip ? ::repodata_globalize_id( _dip->data, _dip->kv.id, 1 )
763 : detail::noId;
764 }
765
766 void LookupAttr::iterator::increment()
767 {
768 if ( _dip )
769 {
770 if ( ! ::dataiterator_step( _dip.get() ) )
771 {
772 _dip.reset();
773 base_reference() = 0;
774 }
775 else
776 {
777 ::dataiterator_strdup( _dip.get() );
778 }
779 }
780 }
781
782 std::ostream & operator<<( std::ostream & str, const LookupAttr::iterator & obj )
783 {
784 const detail::CDataiterator * dip = obj.get();
785 if ( ! dip )
786 return str << "EndOfQuery";
787
788 if ( obj.inSolvable() )
789 str << obj.inSolvable();
790 else if ( obj.inRepo() )
791 str << obj.inRepo();
792
793 str << '<' << obj.inSolvAttr() << (obj.solvAttrSubEntry() ? ">(*" : ">(")
794 << IdString(obj.solvAttrType()) << ") = " << obj.asString();
795 return str;
796 }
797
798 template<> CheckSum LookupAttr::iterator::asType<CheckSum>() const
799 { return asCheckSum(); }
800
802 } // namespace sat
805} // namespace zypp
807
808std::ostream & operator<<( std::ostream & str, const zypp::sat::detail::CDataiterator * obj )
809{
810 str << "detail::CDataiterator(";
811 if ( ! obj )
812 {
813 str << "NULL";
814 }
815 else
816 {
817 str << "|" << zypp::Repository(obj->repo);
818 str << "|" << zypp::sat::Solvable(obj->solvid);
819 str << "|" << zypp::IdString(obj->key->name);
820 str << "|" << zypp::IdString(obj->key->type);
821 str << "|" << obj->repodataid;
822 str << "|" << obj->repoid;
823 }
824 return str << ")";
825}
826
LookupAttr.h
Pool.h
StrMatcher.h
zypp::C_Str
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition String.h:92
zypp::C_Str::empty
bool empty() const
Definition String.h:108
zypp::Capability
A sat capability.
Definition Capability.h:63
zypp::Capability::asString
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Capability.h:168
zypp::CheckSum
Definition CheckSum.h:34
zypp::CheckSum::md5
static CheckSum md5(const std::string &checksum)
Definition CheckSum.h:73
zypp::CheckSum::sha384
static CheckSum sha384(const std::string &checksum)
Definition CheckSum.h:78
zypp::CheckSum::sha1
static CheckSum sha1(const std::string &checksum)
Definition CheckSum.h:75
zypp::CheckSum::sha512
static CheckSum sha512(const std::string &checksum)
Definition CheckSum.h:79
zypp::CheckSum::sha256
static CheckSum sha256(const std::string &checksum)
Definition CheckSum.h:77
zypp::CheckSum::sha224
static CheckSum sha224(const std::string &checksum)
Definition CheckSum.h:76
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *
Definition IdString.cc:50
zypp::IdString::asString
std::string asString() const
Conversion to std::string
Definition IdString.h:99
zypp::Repository
Definition Repository.h:40
zypp::Repository::noRepository
static const Repository noRepository
Represents no Repository.
Definition Repository.h:67
zypp::StrMatcher
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition StrMatcher.h:298
zypp::StrMatcher::compile
void compile() const
Compile the pattern e.g.
Definition StrMatcher.cc:297
zypp::sat::LookupAttr::Impl
LookupAttr implememtation.
Definition LookupAttr.cc:57
zypp::sat::LookupAttr::Impl::_repo
Repository _repo
Definition LookupAttr.cc:152
zypp::sat::LookupAttr::Impl::_parent
SolvAttr _parent
Definition LookupAttr.cc:151
zypp::sat::LookupAttr::Impl::setSolvable
void setSolvable(Solvable solv_r)
Definition LookupAttr.cc:115
zypp::sat::LookupAttr::Impl::setStrMatcher
void setStrMatcher(const StrMatcher &matcher_r)
Definition LookupAttr.cc:87
zypp::sat::LookupAttr::Impl::setParent
void setParent(SolvAttr attr_r)
Definition LookupAttr.cc:124
zypp::sat::LookupAttr::Impl::solvable
Solvable solvable() const
Definition LookupAttr.cc:112
zypp::sat::LookupAttr::Impl::end
LookupAttr::iterator end() const
Definition LookupAttr.cc:146
zypp::sat::LookupAttr::Impl::attr
SolvAttr attr() const
Definition LookupAttr.cc:73
zypp::sat::LookupAttr::Impl::strMatcher
const StrMatcher & strMatcher() const
Definition LookupAttr.cc:84
zypp::sat::LookupAttr::Impl::setPool
void setPool(Location loc_r)
Definition LookupAttr.cc:97
zypp::sat::LookupAttr::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition LookupAttr.cc:159
zypp::sat::LookupAttr::Impl::Impl
Impl(const SolvAttr &attr_r, Location loc_r)
Definition LookupAttr.cc:62
zypp::sat::LookupAttr::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::sat::LookupAttr::Impl::begin
LookupAttr::iterator begin() const
Definition LookupAttr.cc:128
zypp::sat::LookupAttr::Impl::_solv
Solvable _solv
Definition LookupAttr.cc:153
zypp::sat::LookupAttr::Impl::_strMatcher
StrMatcher _strMatcher
Definition LookupAttr.cc:154
zypp::sat::LookupAttr::Impl::_attr
SolvAttr _attr
Definition LookupAttr.cc:150
zypp::sat::LookupAttr::Impl::pool
bool pool() const
Definition LookupAttr.cc:94
zypp::sat::LookupAttr::Impl::Impl
Impl(const SolvAttr &attr_r, Repository repo_r, Location loc_r)
Definition LookupAttr.cc:65
zypp::sat::LookupAttr::Impl::repo
Repository repo() const
Definition LookupAttr.cc:103
zypp::sat::LookupAttr::Impl::Impl
Impl()
Definition LookupAttr.cc:59
zypp::sat::LookupAttr::Impl::Impl
Impl(const SolvAttr &attr_r, Solvable solv_r)
Definition LookupAttr.cc:68
zypp::sat::LookupAttr::Impl::parent
SolvAttr parent() const
Definition LookupAttr.cc:121
zypp::sat::LookupAttr::Impl::setRepo
void setRepo(Repository repo_r, Location loc_r)
Definition LookupAttr.cc:106
zypp::sat::LookupAttr::Impl::setAttr
void setAttr(SolvAttr attr_r)
Definition LookupAttr.cc:76
zypp::sat::LookupAttr::iterator
Result iterator.
Definition LookupAttr.h:364
zypp::sat::LookupAttr::iterator::get
detail::CDataiterator * get() const
Expert backdoor.
Definition LookupAttr.h:575
zypp::sat::LookupAttr::iterator::subBegin
iterator subBegin() const
Iterator to the begin of a sub-structure.
Definition LookupAttr.cc:471
zypp::sat::LookupAttr::iterator::asUnsignedLL
unsigned long long asUnsignedLL() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition LookupAttr.cc:562
zypp::sat::LookupAttr::iterator::asUnsigned
unsigned asUnsigned() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition LookupAttr.cc:559
zypp::sat::LookupAttr::iterator::stayInThisSolvable
void stayInThisSolvable()
Stop after all matches in the current Solvable are processed.
Definition LookupAttr.cc:370
zypp::sat::LookupAttr::iterator::asType
Tp asType() const
Templated return type.
Definition LookupAttr.h:535
zypp::sat::LookupAttr::iterator::idStr
IdString idStr() const
As IdStr.
Definition LookupAttr.cc:665
zypp::sat::LookupAttr::iterator::dereference
detail::IdType dereference() const
Definition LookupAttr.cc:760
zypp::sat::LookupAttr::iterator::nextSkipSolvable
void nextSkipSolvable()
On the next call to operator++ advance to the next Solvable.
Definition LookupAttr.cc:364
zypp::sat::LookupAttr::iterator::inSolvAttr
SolvAttr inSolvAttr() const
The current SolvAttr.
Definition LookupAttr.cc:358
zypp::sat::LookupAttr::iterator::iterator
iterator()
Definition LookupAttr.cc:719
zypp::sat::LookupAttr::iterator::subEmpty
bool subEmpty() const
Whether the sub-structure is empty.
Definition LookupAttr.cc:460
zypp::sat::LookupAttr::iterator::increment
void increment()
Definition LookupAttr.cc:766
zypp::sat::LookupAttr::iterator::asCheckSum
CheckSum asCheckSum() const
As CheckSum.
Definition LookupAttr.cc:681
zypp::sat::LookupAttr::iterator::~iterator
~iterator()
Definition LookupAttr.cc:738
zypp::sat::LookupAttr::iterator::solvAttrCheckSum
bool solvAttrCheckSum() const
Whether this is a CheckSum attribute.
Definition LookupAttr.cc:423
zypp::sat::LookupAttr::iterator::asString
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition LookupAttr.cc:611
zypp::sat::LookupAttr::iterator::nextSkipSolvAttr
void nextSkipSolvAttr()
On the next call to operator++ advance to the next SolvAttr.
Definition LookupAttr.cc:361
zypp::sat::LookupAttr::iterator::asBool
bool asBool() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition LookupAttr.cc:577
zypp::sat::LookupAttr::iterator::subEnd
iterator subEnd() const
Iterator behind the end of a sub-structure.
Definition LookupAttr.cc:493
zypp::sat::LookupAttr::iterator::stayInThisRepo
void stayInThisRepo()
Stop after all matches in the current Repository are processed.
Definition LookupAttr.cc:373
zypp::sat::LookupAttr::iterator::solvAttrSubEntry
bool solvAttrSubEntry() const
Whether this is the entry to a sub-structure (flexarray).
Definition LookupAttr.cc:453
zypp::sat::LookupAttr::iterator::subFind
iterator subFind(const SolvAttr &attr_r) const
Iterator pointing to the first occurance of SolvAttr attr_r in sub-structure.
Definition LookupAttr.cc:498
zypp::sat::LookupAttr::iterator::inSolvable
Solvable inSolvable() const
The current Solvable.
Definition LookupAttr.cc:355
zypp::sat::LookupAttr::iterator::_dip
detail::DIWrap _dip
Definition LookupAttr.h:578
zypp::sat::LookupAttr::iterator::nextSkipRepo
void nextSkipRepo()
On the next call to operator++ advance to the next Repository.
Definition LookupAttr.cc:367
zypp::sat::LookupAttr::iterator::c_str
const char * c_str() const
Conversion to string types.
Definition LookupAttr.cc:581
zypp::sat::LookupAttr::iterator::subSize
size_type subSize() const
Ammount of attributes in the sub-structure.
Definition LookupAttr.cc:463
zypp::sat::LookupAttr::iterator::operator=
iterator & operator=(const iterator &rhs)
Definition LookupAttr.cc:741
zypp::sat::LookupAttr::iterator::solvAttrNumeric
bool solvAttrNumeric() const
Whether this is a numeric attribute (incl.
Definition LookupAttr.cc:383
zypp::sat::LookupAttr::iterator::solvAttrIdString
bool solvAttrIdString() const
Whether this string attribute is available as IdString.
Definition LookupAttr.cc:410
zypp::sat::LookupAttr::iterator::dip_equal
bool dip_equal(const detail::CDataiterator &lhs, const detail::CDataiterator &rhs) const
Definition LookupAttr.cc:753
zypp::sat::LookupAttr::iterator::solvAttrString
bool solvAttrString() const
Whether this is a string attribute.
Definition LookupAttr.cc:395
zypp::sat::LookupAttr::iterator::solvAttrType
detail::IdType solvAttrType() const
The current SolvAttr type.
Definition LookupAttr.cc:380
zypp::sat::LookupAttr::iterator::asInt
int asInt() const
Conversion to numeric types.
Definition LookupAttr.cc:544
zypp::sat::LookupAttr::iterator::inRepo
Repository inRepo() const
The current Repository.
Definition LookupAttr.cc:352
zypp::sat::LookupAttr::end
iterator end() const
Iterator behind the end of query results.
Definition LookupAttr.cc:240
zypp::sat::LookupAttr::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition LookupAttr.h:234
zypp::sat::LookupAttr::strMatcher
const StrMatcher & strMatcher() const
The pattern to match.
Definition LookupAttr.cc:203
zypp::sat::LookupAttr::empty
bool empty() const
Whether the query is empty.
Definition LookupAttr.cc:243
zypp::sat::LookupAttr::size_type
unsigned int size_type
Definition LookupAttr.h:115
zypp::sat::LookupAttr::Location
Location
Specify the where to look for the attribule.
Definition LookupAttr.h:118
zypp::sat::LookupAttr::REPO_ATTR
@ REPO_ATTR
Search for repository attributes.
Definition LookupAttr.h:120
zypp::sat::LookupAttr::setStrMatcher
void setStrMatcher(const StrMatcher &matcher_r)
Set the pattern to match.
Definition LookupAttr.cc:206
zypp::sat::LookupAttr::repo
Repository repo() const
Whether to search in one Repository.
Definition LookupAttr.cc:217
zypp::sat::LookupAttr::attr
SolvAttr attr() const
The SolvAttr to search.
Definition LookupAttr.cc:197
zypp::sat::LookupAttr::parent
SolvAttr parent() const
Whether to search within a sub-structure (SolvAttr::noAttr if not)
Definition LookupAttr.cc:229
zypp::sat::LookupAttr::setAttr
void setAttr(SolvAttr attr_r)
Set the SolvAttr to search.
Definition LookupAttr.cc:200
zypp::sat::LookupAttr::setRepo
void setRepo(Repository repo_r, Location=SOLV_ATTR)
Set search in one Repository.
Definition LookupAttr.cc:220
zypp::sat::LookupAttr::pool
bool pool() const
Whether to search in Pool.
Definition LookupAttr.cc:211
zypp::sat::LookupAttr::size
size_type size() const
Ammount of results.
Definition LookupAttr.cc:246
zypp::sat::LookupAttr::begin
iterator begin() const
Iterator to the begin of query results.
Definition LookupAttr.cc:237
zypp::sat::LookupAttr::setSolvable
void setSolvable(Solvable solv_r)
Set search in one Solvable.
Definition LookupAttr.cc:226
zypp::sat::LookupAttr::solvable
Solvable solvable() const
Whether to search in one Solvable.
Definition LookupAttr.cc:223
zypp::sat::LookupAttr::operator<<
std::ostream & operator<<(std::ostream &str, const LookupAttr &obj) ZYPP_API
Stream output.
Definition LookupAttr.cc:256
zypp::sat::LookupAttr::LookupAttr
LookupAttr()
Default ctor finds nothing.
Definition LookupAttr.cc:169
zypp::sat::LookupAttr::setPool
void setPool(Location=SOLV_ATTR)
Set search in Pool (all repositories).
Definition LookupAttr.cc:214
zypp::sat::LookupAttr::setParent
void setParent(SolvAttr attr_r)
Set search within a sub-structure (SolvAttr::noAttr for none)
Definition LookupAttr.cc:232
zypp::sat::LookupRepoAttr::setRepo
void setRepo(Repository repo_r)
Set search in one Repository.
Definition LookupAttr.cc:288
zypp::sat::LookupRepoAttr::LookupRepoAttr
LookupRepoAttr()
Default ctor finds nothing.
Definition LookupAttr.h:268
zypp::sat::Pool::instance
static Pool instance()
Singleton ctor.
Definition Pool.h:55
zypp::sat::SolvAttr
Solvable attribute keys.
Definition SolvAttr.h:41
zypp::sat::SolvAttr::noAttr
static const SolvAttr noAttr
Value representing noAttr ("")
Definition SolvAttr.h:48
zypp::sat::SolvAttr::allAttr
static const SolvAttr allAttr
Value to request searching all Attributes (0).
Definition SolvAttr.h:46
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::sat::Solvable::noSolvable
static const Solvable noSolvable
Represents no Solvable.
Definition Solvable.h:80
zypp::sat::detail::DIWrap
Wrapper around sat detail::CDataiterator.
Definition LookupAttr.h:300
zypp::sat::detail::DIWrap::get
detail::CDataiterator * get() const
Definition LookupAttr.h:338
zypp::sat::detail::DIWrap::_mstring
std::string _mstring
Definition LookupAttr.h:343
zypp::sat::detail::DIWrap::DIWrap
DIWrap()
NULL detail::CDataiterator
Definition LookupAttr.h:303
zypp::sat::detail::DIWrap::~DIWrap
~DIWrap()
Definition LookupAttr.cc:329
zypp::sat::detail::DIWrap::_dip
detail::CDataiterator * _dip
Definition LookupAttr.h:342
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::sat::detail
Definition PoolImpl.cc:72
zypp::sat::detail::SolvableIdType
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition PoolMember.h:125
zypp::sat::detail::noId
static const IdType noId(0)
zypp::sat::detail::noSolvableId
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolMember.h:104
zypp::sat::detail::noRepoId
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
zypp::sat::detail::CDataiterator
::s_Dataiterator CDataiterator
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:58
zypp::sat::detail::operator<<
std::ostream & operator<<(std::ostream &str, const DIWrap &obj)
Definition LookupAttr.cc:338
zypp::sat::detail::RepoIdType
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition PoolMember.h:133
zypp::sat
Definition Resolver.h:28
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
Definition FileConflicts.cc:109
zypp::sat::noSolvableId
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
zypp::sat::dumpOn
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Definition LocaleSupport.cc:41
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:290
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::dumpRange
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).
Definition LogTools.h:120
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
PoolImpl.h
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
CheckSum.h
LogTools.h
String.h