libzypp  17.30.2
Capability.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 #include <zypp/base/Logger.h>
14 
15 #include <zypp/base/String.h>
16 #include <zypp/base/Regex.h>
17 #include <zypp/base/Gettext.h>
18 #include <zypp/base/Exception.h>
19 
20 #include <zypp/Arch.h>
21 #include <zypp/Rel.h>
22 #include <zypp/Edition.h>
23 #include <zypp/Capability.h>
24 
25 #include <zypp/sat/detail/PoolImpl.h>
26 #include <zypp/sat/Pool.h>
27 #include <zypp/ResPool.h>
28 
29 using std::endl;
30 
32 namespace zypp
33 {
35  namespace
36  {
37 
39  template <unsigned TLen = 5>
40  struct TempStrings
41  {
43  std::string & getNext()
44  { unsigned c = _next; _next = (_next+1) % TLen; _buf[c].clear(); return _buf[c]; }
45 
46  private:
47  unsigned _next = 0;
48  std::string _buf[TLen];
49  };
50 
52  inline std::string::size_type backskipWs( const std::string & str_r, std::string::size_type pos_r )
53  {
54  for ( ; pos_r != std::string::npos; --pos_r )
55  {
56  char ch = str_r[pos_r];
57  if ( ch != ' ' && ch != '\t' )
58  break;
59  }
60  return pos_r;
61  }
62 
64  inline std::string::size_type backskipNWs( const std::string & str_r, std::string::size_type pos_r )
65  {
66  for ( ; pos_r != std::string::npos; --pos_r )
67  {
68  char ch = str_r[pos_r];
69  if ( ch == ' ' || ch == '\t' )
70  break;
71  }
72  return pos_r;
73  }
74 
76  void splitOpEdition( std::string & str_r, Rel & op_r, Edition & ed_r )
77  {
78  if ( str_r.empty() )
79  return;
80  std::string::size_type ch( str_r.size()-1 );
81 
82  // check whether the one but last word is a valid Rel:
83  if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
84  {
85  std::string::size_type ee( ch );
86  if ( (ch = backskipNWs( str_r, ch )) != std::string::npos )
87  {
88  std::string::size_type eb( ch );
89  if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
90  {
91  std::string::size_type oe( ch );
92  ch = backskipNWs( str_r, ch ); // now before 'op'? begin
93  if ( op_r.parseFrom( str_r.substr( ch+1, oe-ch ) ) )
94  {
95  // found a legal 'op'
96  ed_r = Edition( str_r.substr( eb+1, ee-eb ) );
97  if ( ch != std::string::npos ) // 'op' is not at str_r begin, so skip WS
98  ch = backskipWs( str_r, ch );
99  str_r.erase( ch+1 );
100  return;
101  }
102  }
103  }
104  }
105  // HERE: Didn't find 'name op edition'
106  // As a convenience we check for an embeded 'op' (not surounded by WS).
107  // But just '[<=>]=?|!=' and not inside '()'.
108  ch = str_r.find_last_of( "<=>)" );
109  if ( ch != std::string::npos && str_r[ch] != ')' )
110  {
111  std::string::size_type oe( ch );
112 
113  // do edition first:
114  ch = str_r.find_first_not_of( " \t", oe+1 );
115  if ( ch != std::string::npos )
116  ed_r = Edition( str_r.substr( ch ) );
117 
118  // now finish op:
119  ch = oe-1;
120  if ( str_r[oe] != '=' ) // '[<>]'
121  {
122  op_r = ( str_r[oe] == '<' ) ? Rel::LT : Rel::GT;
123  }
124  else
125  { // '?='
126  if ( ch != std::string::npos )
127  {
128  switch ( str_r[ch] )
129  {
130  case '<': --ch; op_r = Rel::LE; break;
131  case '>': --ch; op_r = Rel::GE; break;
132  case '!': --ch; op_r = Rel::NE; break;
133  case '=': --ch; // fall through
134  default: op_r = Rel::EQ; break;
135  }
136  }
137  }
138 
139  // finally name:
140  if ( ch != std::string::npos ) // 'op' is not at str_r begin, so skip WS
141  ch = backskipWs( str_r, ch );
142  str_r.erase( ch+1 );
143  return;
144  }
145  // HERE: It's a plain 'name'
146  }
147 
150  sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
151  const Arch & arch_r,
152  const std::string & name_r,
153  Rel op_r,
154  const Edition & ed_r,
155  const ResKind & kind_r )
156  {
157  // First build the name, non-packages prefixed by kind
158  sat::Solvable::SplitIdent split( kind_r, name_r );
159  sat::detail::IdType nid( split.ident().id() );
160 
161  if ( split.kind() == ResKind::srcpackage )
162  {
163  // map 'kind srcpackage' to 'arch src', the pseudo architecture
164  // libsolv uses.
165  nid = ::pool_rel2id( pool_r, nid, IdString(ARCH_SRC).id(), REL_ARCH, /*create*/true );
166  }
167 
168  // Extend name by architecture, if provided and not a srcpackage
169  if ( ! arch_r.empty() && kind_r != ResKind::srcpackage )
170  {
171  nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH, /*create*/true );
172  }
173 
174  // Extend 'op edition', if provided
175  if ( op_r != Rel::ANY && ed_r != Edition::noedition )
176  {
177  nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(), /*create*/true );
178  }
179 
180  return nid;
181  }
182 
186  sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
187  const std::string & name_r, Rel op_r, const Edition & ed_r,
188  const ResKind & kind_r )
189  {
190  static const Arch srcArch( IdString(ARCH_SRC).asString() );
191  static const Arch nosrcArch( IdString(ARCH_NOSRC).asString() );
192  static const std::string srcKindPrefix( ResKind::srcpackage.asString() + ':' );
193 
194  // check for an embedded 'srcpackage:foo' to be mapped to 'foo' and 'ResKind::srcpackage'.
195  if ( kind_r.empty() && str::hasPrefix( name_r, srcKindPrefix ) )
196  {
197  return relFromStr( pool_r, Arch_empty, name_r.substr( srcKindPrefix.size() ), op_r, ed_r, ResKind::srcpackage );
198  }
199 
200  Arch arch( Arch_empty );
201  std::string name( name_r );
202 
203  std::string::size_type asep( name_r.rfind( "." ) );
204  if ( asep != std::string::npos )
205  {
206  Arch ext( name_r.substr( asep+1 ) );
207  if ( ext.isBuiltIn() || ext == srcArch || ext == nosrcArch )
208  {
209  arch = ext;
210  name.erase( asep );
211  }
212  }
213 
214  return relFromStr( pool_r, arch, name, op_r, ed_r, kind_r );
215  }
216 
219  sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
220  const Arch & arch_r, // parse from name if empty
221  const std::string & str_r, const ResKind & kind_r,
222  Capability::CtorFlag flag_r )
223  {
224  std::string name( str_r );
225  Rel op;
226  Edition ed;
227  if ( flag_r == Capability::UNPARSED )
228  {
229  splitOpEdition( name, op, ed );
230  }
231 
232  if ( arch_r.empty() )
233  return relFromStr( pool_r, name, op, ed, kind_r ); // parses for name[.arch]
234  // else
235  return relFromStr( pool_r, arch_r, name, op, ed, kind_r );
236  }
237 
239  } // namespace
241 
242  const Capability Capability::Null( STRID_NULL );
243  const Capability Capability::Empty( STRID_EMPTY );
244 
246 
247  Capability::Capability( const char * str_r, const ResKind & prefix_r, CtorFlag flag_r )
248  : _id( relFromStr( myPool().getPool(), Arch_empty, str_r, prefix_r, flag_r ) )
249  {}
250 
251  Capability::Capability( const std::string & str_r, const ResKind & prefix_r, CtorFlag flag_r )
252  : _id( relFromStr( myPool().getPool(), Arch_empty, str_r.c_str(), prefix_r, flag_r ) )
253  {}
254 
255  Capability::Capability( const Arch & arch_r, const char * str_r, const ResKind & prefix_r, CtorFlag flag_r )
256  : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
257  {}
258 
259  Capability::Capability( const Arch & arch_r, const std::string & str_r, const ResKind & prefix_r, CtorFlag flag_r )
260  : _id( relFromStr( myPool().getPool(), arch_r, str_r.c_str(), prefix_r, flag_r ) )
261  {}
262 
263  Capability::Capability( const char * str_r, CtorFlag flag_r, const ResKind & prefix_r )
264  : _id( relFromStr( myPool().getPool(), Arch_empty, str_r, prefix_r, flag_r ) )
265  {}
266 
267  Capability::Capability( const std::string & str_r, CtorFlag flag_r, const ResKind & prefix_r )
268  : _id( relFromStr( myPool().getPool(), Arch_empty, str_r, prefix_r, flag_r ) )
269  {}
270 
271  Capability::Capability( const Arch & arch_r, const char * str_r, CtorFlag flag_r, const ResKind & prefix_r )
272  : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
273  {}
274 
275  Capability::Capability( const Arch & arch_r, const std::string & str_r, CtorFlag flag_r, const ResKind & prefix_r )
276  : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
277  {}
278 
280  // Ctor from <name[.arch] op edition>.
282 
283  Capability::Capability( const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
284  : _id( relFromStr( myPool().getPool(), name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
285  {}
286  Capability::Capability( const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
287  : _id( relFromStr( myPool().getPool(), name_r, op_r, Edition(ed_r), prefix_r ) )
288  {}
289  Capability::Capability( const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
290  : _id( relFromStr( myPool().getPool(), name_r, op_r, ed_r, prefix_r ) )
291  {}
292 
294  // Ctor from <arch name op edition>.
296 
297  Capability::Capability( const std::string & arch_r, const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
298  : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
299  {}
300  Capability::Capability( const std::string & arch_r, const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
301  : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, op_r, Edition(ed_r), prefix_r ) )
302  {}
303  Capability::Capability( const std::string & arch_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
304  : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, op_r, ed_r, prefix_r ) )
305  {}
306  Capability::Capability( const Arch & arch_r, const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
307  : _id( relFromStr( myPool().getPool(), arch_r, name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
308  {}
309  Capability::Capability( const Arch & arch_r, const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
310  : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r, Edition(ed_r), prefix_r ) )
311  {}
312  Capability::Capability( const Arch & arch_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
313  : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r, ed_r, prefix_r ) )
314  {}
315 
317  // Ctor creating a namespace: capability.
319 
321  : _id( ::pool_rel2id( myPool().getPool(), asIdString(namespace_r).id(), (value_r.empty() ? STRID_NULL : value_r.id() ), REL_NAMESPACE, /*create*/true ) )
322  {}
323 
325  // https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.html
326  namespace
327  {
328  inline const char * opstr( int op_r )
329  {
330  switch ( op_r )
331  {
332  case REL_GT: return " > ";
333  case REL_EQ: return " = ";
334  case REL_LT: return " < ";
335  case REL_GT|REL_EQ: return " >= ";
336  case REL_LT|REL_EQ: return " <= ";
337  case REL_GT|REL_LT: return " != ";
338  case REL_GT|REL_LT|REL_EQ: return " <=> ";
339  case REL_AND: return " and ";
340  case REL_OR: return " or ";
341  case REL_COND: return " if ";
342  case REL_UNLESS: return " unless ";
343  case REL_ELSE: return " else ";
344  case REL_WITH: return " with ";
345  case REL_WITHOUT: return " without ";
346  }
347  return "UNKNOWNCAPREL";
348  }
349 
350  inline bool isBoolOp( int op_r )
351  {
352  switch ( op_r ) {
353  case REL_AND:
354  case REL_OR:
355  case REL_COND:
356  case REL_UNLESS:
357  case REL_ELSE:
358  case REL_WITH:
359  case REL_WITHOUT:
360  return true;
361  }
362  return false;
363  }
364 
365  inline bool needsBrace( int op_r, int parop_r )
366  {
367  return ( isBoolOp( parop_r ) || parop_r == 0 ) && isBoolOp( op_r )
368  && ( parop_r != op_r || op_r == REL_COND || op_r == REL_UNLESS || op_r == REL_ELSE )
369  && not ( ( parop_r == REL_COND || parop_r == REL_UNLESS ) && op_r == REL_ELSE );
370  }
371 
372  void cap2strHelper( std::string & outs_r, sat::detail::CPool * pool_r, sat::detail::IdType id_r, int parop_r )
373  {
374  if ( ISRELDEP(id_r) ) {
375  ::Reldep * rd = GETRELDEP( pool_r, id_r );
376  int op = rd->flags;
377 
378  if ( op == CapDetail::CAP_ARCH ) {
379  if ( rd->evr == ARCH_SRC || rd->evr == ARCH_NOSRC ) {
380  // map arch .{src,nosrc} to kind srcpackage
381  outs_r += ResKind::srcpackage.c_str();
382  outs_r += ":";
383  outs_r += IdString(rd->name).c_str();
384  return;
385  }
386  cap2strHelper( outs_r, pool_r, rd->name, op );
387  outs_r += ".";
388  cap2strHelper( outs_r, pool_r, rd->evr, op );
389  return;
390  }
391 
392  if ( op == CapDetail::CAP_NAMESPACE ) {
393  cap2strHelper( outs_r, pool_r, rd->name, op );
394  outs_r += "(";
395  cap2strHelper( outs_r, pool_r, rd->evr, op );
396  outs_r += ")";
397  return;
398  }
399 
400  if ( op == REL_FILECONFLICT )
401  {
402  cap2strHelper( outs_r, pool_r, rd->name, op );
403  return;
404  }
405 
406  if ( needsBrace( op, parop_r ) ) {
407  outs_r += "(";
408  cap2strHelper( outs_r, pool_r, rd->name, op );
409  outs_r += opstr( op );
410  cap2strHelper( outs_r, pool_r, rd->evr, op );
411  outs_r += ")";
412  return;
413  }
414 
415  cap2strHelper( outs_r, pool_r, rd->name, op );
416  outs_r += opstr( op );
417  cap2strHelper( outs_r, pool_r, rd->evr, op );
418  }
419  else
420  outs_r += IdString(id_r).c_str();
421  }
422  } // namespace
424 
425  const char * Capability::c_str() const
426  {
427  if ( not id() ) return "";
428  if ( not ISRELDEP(id()) ) return IdString(id()).c_str();
429 
430  static TempStrings<5> tempstrs; // Round Robin buffer to prolong the lifetime of the returned char*
431 
432  std::string & outs { tempstrs.getNext() };
433  cap2strHelper( outs, myPool().getPool(), id(), 0 );
434  return outs.c_str();
435  }
436 
438  {
439  if ( lhs == rhs )
440  return CapMatch::yes;
441 
442  CapDetail l( lhs );
443  CapDetail r( rhs );
444 
445  switch ( l.kind() )
446  {
447  case CapDetail::NOCAP:
448  return( r.kind() == CapDetail::NOCAP ); // NOCAP matches NOCAP only
449  break;
451  return CapMatch::irrelevant;
452  break;
453  case CapDetail::NAMED:
455  break;
456  }
457 
458  switch ( r.kind() )
459  {
460  case CapDetail::NOCAP:
461  return CapMatch::no; // match case handled above
462  break;
464  return CapMatch::irrelevant;
465  break;
466  case CapDetail::NAMED:
468  break;
469  }
470  // comparing two simple caps:
471  if ( l.name() != r.name() )
472  return CapMatch::no;
473 
474  // if both are arch restricted they must match
475  if ( l.arch() != r.arch()
476  && ! ( l.arch().empty() || r.arch().empty() ) )
477  return CapMatch::no;
478 
479  // isNamed matches ANY edition:
480  if ( l.isNamed() || r.isNamed() )
481  return CapMatch::yes;
482 
483  // both are versioned:
484  return overlaps( Edition::MatchRange( l.op(), l.ed() ),
485  Edition::MatchRange( r.op(), r.ed() ) );
486  }
487 
488  bool Capability::isInterestingFileSpec( const char * name_r )
489  {
490  static str::smatch what;
491  static const str::regex filenameRegex(
492  "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
494 
495  return str::regex_match( name_r, what, filenameRegex );
496  }
497 
498  Capability Capability::guessPackageSpec( const std::string & str_r, bool & rewrote_r )
499  {
500  Capability cap( str_r );
501  CapDetail detail( cap.detail() );
502 
503  // str_r might be the form "libzypp-1.2.3-4.5(.arch)'
504  // correctly parsed as name capability by the ctor.
505  // TODO: Think about allowing glob char in name - for now don't process
506  if ( detail.isNamed() && !::strpbrk( detail.name().c_str(), "*?[{" )
507  && ::strrchr( detail.name().c_str(), '-' ) && sat::WhatProvides( cap ).empty() )
508  {
509  Arch origArch( detail.arch() ); // to support a trailing .arch
510 
511  std::string guess( detail.name().asString() );
512  std::string::size_type pos( guess.rfind( '-' ) );
513  guess[pos] = '=';
514 
515  Capability guesscap( origArch, guess );
516  detail = guesscap.detail();
517 
518  ResPool pool( ResPool::instance() );
519  // require name part matching a pool items name (not just provides!)
520  if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
521  {
522  rewrote_r = true;
523  return guesscap;
524  }
525 
526  // try the one but last '-'
527  if ( pos )
528  {
529  guess[pos] = '-';
530  if ( (pos = guess.rfind( '-', pos-1 )) != std::string::npos )
531  {
532  guess[pos] = '=';
533 
534  guesscap = Capability( origArch, guess );
535  detail = guesscap.detail();
536 
537  // require name part matching a pool items name (not just provides!)
538  if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
539  {
540  rewrote_r = true;
541  return guesscap;
542  }
543  }
544  }
545  }
546 
547  rewrote_r = false;
548  return cap;
549  }
550 
551  Capability Capability::guessPackageSpec( const std::string & str_r )
552  {
553  bool dummy;
554  return guessPackageSpec( str_r, dummy );
555  }
556 
557  /******************************************************************
558  **
559  ** FUNCTION NAME : operator<<
560  ** FUNCTION TYPE : std::ostream &
561  */
562  std::ostream & operator<<( std::ostream & str, const Capability & obj )
563  {
564  return str << obj.c_str();
565  }
566 
567  std::ostream & dumpOn( std::ostream & str, const Capability & obj )
568  {
569  return str << ( obj ? ::pool_dep2str( sat::Pool::instance().get(), obj.id() ) : "" );
570  }
571 
573  //
574  // CLASS NAME : CapDetail
575  //
577 
579  {
580  // : _kind( NOCAP ), _lhs( id_r ), _rhs( 0 ), _flag( 0 ), _archIfSimple( 0 )
581 
583  return; // NOCAP
584 
585  if ( ! ISRELDEP(_lhs) )
586  {
587  // this is name without arch!
588  _kind = NAMED;
589  return;
590  }
591 
592  ::Reldep * rd = GETRELDEP( myPool().getPool(), _lhs );
593  _lhs = rd->name;
594  _rhs = rd->evr;
595  _flag = rd->flags;
596 
597  if ( Rel::isRel( _flag ) )
598  {
599  _kind = VERSIONED;
600  // Check for name.arch...
601  if ( ! ISRELDEP(_lhs) )
602  return; // this is name without arch!
603  rd = GETRELDEP( myPool().getPool(), _lhs );
604  if ( rd->flags != CAP_ARCH )
605  return; // this is not name.arch
606  // This is name.arch:
607  _lhs = rd->name;
608  _archIfSimple = rd->evr;
609  }
610  else if ( rd->flags == CAP_ARCH )
611  {
612  _kind = NAMED;
613  // This is name.arch:
614  _lhs = rd->name;
615  _archIfSimple = rd->evr;
616  }
617  else
618  {
619  _kind = EXPRESSION;
620  return;
621  }
622  // map back libsolvs pseudo arch 'src' to kind srcpackage
623  if ( _archIfSimple == ARCH_SRC || _archIfSimple == ARCH_NOSRC )
624  {
625  _lhs = IdString( (ResKind::srcpackage.asString() + ":" + IdString(_lhs).c_str()).c_str() ).id();
626  _archIfSimple = 0;
627  }
628  }
629 
630  /******************************************************************
631  **
632  ** FUNCTION NAME : operator<<
633  ** FUNCTION TYPE : std::ostream &
634  */
635  std::ostream & operator<<( std::ostream & str, const CapDetail & obj )
636  {
637  static const char archsep = '.';
638  switch ( obj.kind() )
639  {
640  case CapDetail::NOCAP:
641  return str << "<NoCap>";
642  break;
643 
644  case CapDetail::NAMED:
645  str << obj.name();
646  if ( obj.hasArch() )
647  str << archsep << obj.arch();
648  return str;
649  break;
650 
652  str << obj.name();
653  if ( obj.hasArch() )
654  str << archsep << obj.arch();
655  return str << " " << obj.op() << " " << obj.ed();
656  break;
657 
659  {
660  std::string outs;
661  auto pool = sat::Pool::instance().get();
662  auto op = obj.capRel();
663  if ( obj.capRel() == CapDetail::CAP_NAMESPACE ) {
664  cap2strHelper( outs, pool, obj.lhs().id(), op );
665  outs += "(";
666  cap2strHelper( outs, pool, obj.rhs().id(), op );
667  outs += ")";
668  }
669  else {
670  outs += "(";
671  cap2strHelper( outs, pool, obj.lhs().id(), op );
672  outs += opstr( op );
673  cap2strHelper( outs, pool, obj.rhs().id(), op );
674  outs += ")";
675  }
676  return str << outs;
677  }
678  break;
679  }
680  return str << "<UnknownCap(" << obj.lhs() << " " << obj.capRel() << " " << obj.rhs() << ")>";
681  }
682 
683  std::ostream & operator<<( std::ostream & str, CapDetail::Kind obj )
684  {
685  switch ( obj )
686  {
687  case CapDetail::NOCAP: return str << "NoCap"; break;
688  case CapDetail::NAMED: return str << "NamedCap"; break;
689  case CapDetail::VERSIONED: return str << "VersionedCap"; break;
690  case CapDetail::EXPRESSION: return str << "CapExpression"; break;
691  }
692  return str << "UnknownCap";
693  }
694 
695  std::ostream & operator<<( std::ostream & str, CapDetail::CapRel obj )
696  {
697  switch ( obj )
698  {
699  case CapDetail::REL_NONE: return str << "NoCapRel"; break;
700  case CapDetail::CAP_AND: return str << "and"; break; // &
701  case CapDetail::CAP_OR: return str << "or"; break; // |
702  case CapDetail::CAP_COND: return str << "if"; break;
703  case CapDetail::CAP_UNLESS: return str << "unless"; break;
704  case CapDetail::CAP_ELSE: return str << "else"; break;
705  case CapDetail::CAP_WITH: return str << "with"; break; // +
706  case CapDetail::CAP_WITHOUT: return str << "without"; break; // -
707  case CapDetail::CAP_NAMESPACE: return str << "NAMESPACE"; break;
708  case CapDetail::CAP_ARCH: return str << "ARCH"; break;
709  }
710  return str << "UnknownCapRel("+str::numstring(obj)+")";
711  }
712 
714 } // namespace zypp
unsigned _next
Definition: Capability.cc:47
std::string _buf[TLen]
Definition: Capability.cc:48
Architecture.
Definition: Arch.h:37
Helper providing more detailed information about a Capability.
Definition: Capability.h:299
bool isNamed() const
Definition: Capability.h:343
IdString name() const
Definition: Capability.h:352
bool hasArch() const
Definition: Capability.h:350
IdString arch() const
Definition: Capability.h:351
Capability rhs() const
Definition: Capability.h:361
Edition ed() const
Definition: Capability.h:354
Rel op() const
Definition: Capability.h:353
sat::detail::IdType _archIfSimple
Definition: Capability.h:371
Capability lhs() const
Definition: Capability.h:359
Kind kind() const
Definition: Capability.h:341
sat::detail::IdType _rhs
Definition: Capability.h:369
CapRel capRel() const
Definition: Capability.h:360
sat::detail::IdType _lhs
Definition: Capability.h:368
unsigned _flag
Definition: Capability.h:370
CapRel
Enum values corresponding with libsolv defines.
Definition: Capability.h:313
@ REL_NONE
Not an expression.
Definition: Capability.h:314
@ CAP_WITHOUT
without
Definition: Capability.h:323
@ CAP_ARCH
Used internally.
Definition: Capability.h:326
@ CAP_UNLESS
unless
Definition: Capability.h:319
Tri state Capability match result.
Definition: CapMatch.h:38
static const CapMatch no
Definition: CapMatch.h:52
static const CapMatch irrelevant
Definition: CapMatch.h:53
static const CapMatch yes
Definition: CapMatch.h:51
A sat capability.
Definition: Capability.h:60
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:253
static const Capability Null
No or Null Capability ( Id 0 ).
Definition: Capability.h:137
Capability()
Default ctor, Empty capability.
Definition: Capability.h:66
CapDetail detail() const
Helper providing more detailed information about a Capability.
Definition: Capability.h:386
const char * c_str() const
Conversion to const char *
Definition: Capability.cc:425
static CapMatch _doMatch(sat::detail::IdType lhs, sat::detail::IdType rhs)
Match two Capabilities.
Definition: Capability.cc:437
static bool isInterestingFileSpec(const IdString &name_r)
Test for a filename that is likely being REQUIRED.
Definition: Capability.h:216
static const Capability Empty
Empty Capability.
Definition: Capability.h:140
static Capability guessPackageSpec(const std::string &str_r)
Capability parser also guessing "libzypp-1.2.3-4.5.x86_64" formats.
Definition: Capability.cc:551
Edition represents [epoch:]version[-release]
Definition: Edition.h:61
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition: Edition.h:73
const char * c_str() const
Definition: IdStringType.h:105
Access to the sat-pools string space.
Definition: IdString.h:43
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:50
constexpr bool empty() const
Whether the string is empty.
Definition: IdString.h:87
IdType id() const
Expert backdoor.
Definition: IdString.h:122
std::string asString() const
Conversion to std::string
Definition: IdString.h:98
Resolvable kinds.
Definition: ResKind.h:33
static const ResKind srcpackage
Definition: ResKind.h:44
Global ResObject pool.
Definition: ResPool.h:61
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
Definition: ResPool.h:166
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
Definition: ResPool.h:197
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
detail::CPool * get() const
Expert backdoor.
Definition: Pool.cc:49
Container of Solvable providing a Capability (read only).
Definition: WhatProvides.h:89
bool empty() const
Whether the container is empty.
Regular expression.
Definition: Regex.h:95
@ nosubs
Support for substring addressing of matches is not required.
Definition: Regex.h:100
Regular expression match result.
Definition: Regex.h:168
String related utilities and Regular expression matching.
static const IdType emptyId(1)
static const IdType noId(0)
SolvableIdType size_type
Definition: PoolMember.h:126
int IdType
Generic Id type.
Definition: PoolMember.h:104
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
std::string numstring(char n, int w=0)
Definition: String.h:289
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1027
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition: Regex.h:70
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition: String.h:531
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
ResolverNamespace
The resolver's dependency namespaces.
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
Definition: Range.h:65
const Arch Arch_empty(IdString::Empty)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:567
std::string asString(const Patch::Category &obj)
Definition: Patch.cc:122
Relational operators.
Definition: Rel.h:44
static const Rel LT
Definition: Rel.h:52
static const Rel GT
Definition: Rel.h:54
static const Rel LE
Definition: Rel.h:53
static const Rel GE
Definition: Rel.h:55
static const Rel NE
Definition: Rel.h:51
static const Rel ANY
Definition: Rel.h:56
static const Rel EQ
Definition: Rel.h:50
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
Definition: Rel.h:111
static PoolImpl & myPool()
Definition: PoolImpl.cc:184