40 template <
unsigned TLen = 5>
44 std::string & getNext()
45 {
unsigned c = _next; _next = (_next+1) % TLen; _buf[c].clear();
return _buf[c]; }
49 std::string _buf[TLen];
53 inline std::string::size_type backskipWs(
const std::string & str_r, std::string::size_type pos_r )
55 for ( ; pos_r != std::string::npos; --pos_r )
57 char ch = str_r[pos_r];
58 if ( ch !=
' ' && ch !=
'\t' )
65 inline std::string::size_type backskipNWs(
const std::string & str_r, std::string::size_type pos_r )
67 for ( ; pos_r != std::string::npos; --pos_r )
69 char ch = str_r[pos_r];
70 if ( ch ==
' ' || ch ==
'\t' )
77 void splitOpEdition( std::string & str_r,
Rel & op_r,
Edition & ed_r )
81 std::string::size_type ch( str_r.size()-1 );
84 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
86 std::string::size_type ee( ch );
87 if ( (ch = backskipNWs( str_r, ch )) != std::string::npos )
89 std::string::size_type eb( ch );
90 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
92 std::string::size_type oe( ch );
93 ch = backskipNWs( str_r, ch );
94 if ( op_r.parseFrom( str_r.substr( ch+1, oe-ch ) ) )
97 ed_r =
Edition( str_r.substr( eb+1, ee-eb ) );
98 if ( ch != std::string::npos )
99 ch = backskipWs( str_r, ch );
109 ch = str_r.find_last_of(
"<=>)" );
110 if ( ch != std::string::npos && str_r[ch] !=
')' )
112 std::string::size_type oe( ch );
115 ch = str_r.find_first_not_of(
" \t", oe+1 );
116 if ( ch != std::string::npos )
117 ed_r =
Edition( str_r.substr( ch ) );
121 if ( str_r[oe] !=
'=' )
123 op_r = ( str_r[oe] ==
'<' ) ?
Rel::LT :
Rel::GT;
127 if ( ch != std::string::npos )
131 case '<': --ch; op_r =
Rel::LE;
break;
132 case '>': --ch; op_r =
Rel::GE;
break;
133 case '!': --ch; op_r =
Rel::NE;
break;
135 default: op_r =
Rel::EQ;
break;
141 if ( ch != std::string::npos )
142 ch = backskipWs( str_r, ch );
153 const std::string & name_r,
166 nid = ::pool_rel2id( pool_r, nid,
IdString(ARCH_SRC).
id(), REL_ARCH,
true );
172 nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH,
true );
178 nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(),
true );
188 const std::string & name_r,
Rel op_r,
const Edition & ed_r,
202 std::string name( name_r );
204 std::string::size_type asep( name_r.rfind(
'.' ) );
205 if ( asep != std::string::npos )
207 Arch ext( name_r.substr( asep+1 ) );
208 if ( ext.isBuiltIn() || ext == srcArch || ext == nosrcArch )
215 return relFromStr( pool_r, arch, name, op_r, ed_r, kind_r );
222 const std::string & str_r,
const ResKind & kind_r,
225 std::string name( str_r );
230 splitOpEdition( name, op, ed );
233 if ( arch_r.empty() )
234 return relFromStr( pool_r, name, op, ed, kind_r );
236 return relFromStr( pool_r, arch_r, name, op, ed, kind_r );
242 if ( str_r[0] ==
'(' ) {
244 if ( res )
return res;
248 return relFromStr( pool_r,
Arch_empty, str_r, prefix_r, flag_r );
261 :
_id( richOrRelFromStr(
myPool().getPool(), str_r, prefix_r, flag_r ) )
265 :
_id( richOrRelFromStr(
myPool().getPool(), str_r, prefix_r, flag_r ) )
269 :
_id( relFromStr(
myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
273 :
_id( relFromStr(
myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
285 :
_id( relFromStr(
myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
289 :
_id( relFromStr(
myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
300 :
_id( relFromStr(
myPool().getPool(), name_r, op_r,
Edition(ed_r), prefix_r ) )
303 :
_id( relFromStr(
myPool().getPool(), name_r, op_r, ed_r, prefix_r ) )
310 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 )
317 :
_id( relFromStr(
myPool().getPool(),
Arch(arch_r), name_r, op_r, ed_r, prefix_r ) )
320 :
_id( relFromStr(
myPool().getPool(), arch_r, name_r,
Rel(op_r),
Edition(ed_r), prefix_r ) )
323 :
_id( relFromStr(
myPool().getPool(), arch_r, name_r, op_r,
Edition(ed_r), prefix_r ) )
326 :
_id( relFromStr(
myPool().getPool(), arch_r, name_r, op_r, ed_r, prefix_r ) )
342 :
_id( ::pool_rel2id(
myPool().getPool(), lhs_r.
id(), rhs_r.
id(), rel_r, true ) )
349 inline const char * opstr(
int op_r )
353 case REL_GT:
return " > ";
354 case REL_EQ:
return " = ";
355 case REL_LT:
return " < ";
356 case REL_GT|REL_EQ:
return " >= ";
357 case REL_LT|REL_EQ:
return " <= ";
358 case REL_GT|REL_LT:
return " != ";
359 case REL_GT|REL_LT|REL_EQ:
return " <=> ";
360 case REL_AND:
return " and ";
361 case REL_OR:
return " or ";
362 case REL_COND:
return " if ";
363 case REL_UNLESS:
return " unless ";
364 case REL_ELSE:
return " else ";
365 case REL_WITH:
return " with ";
366 case REL_WITHOUT:
return " without ";
368 return "UNKNOWNCAPREL";
371 inline bool isBoolOp(
int op_r )
386 inline bool needsBrace(
int op_r,
int parop_r )
388 return ( isBoolOp( parop_r ) || parop_r == 0 ) && isBoolOp( op_r )
389 && ( parop_r != op_r || op_r == REL_COND || op_r == REL_UNLESS || op_r == REL_ELSE )
390 && not ( ( parop_r == REL_COND || parop_r == REL_UNLESS ) && op_r == REL_ELSE );
395 if ( ISRELDEP(id_r) ) {
396 ::Reldep * rd = GETRELDEP( pool_r, id_r );
400 if ( rd->evr == ARCH_SRC || rd->evr == ARCH_NOSRC ) {
407 cap2strHelper( outs_r, pool_r, rd->name, op );
409 cap2strHelper( outs_r, pool_r, rd->evr, op );
414 cap2strHelper( outs_r, pool_r, rd->name, op );
416 cap2strHelper( outs_r, pool_r, rd->evr, op );
421 if ( op == REL_FILECONFLICT )
423 cap2strHelper( outs_r, pool_r, rd->name, op );
427 if ( needsBrace( op, parop_r ) ) {
429 cap2strHelper( outs_r, pool_r, rd->name, op );
430 outs_r += opstr( op );
431 cap2strHelper( outs_r, pool_r, rd->evr, op );
436 cap2strHelper( outs_r, pool_r, rd->name, op );
437 outs_r += opstr( op );
438 cap2strHelper( outs_r, pool_r, rd->evr, op );
448 if ( not
id() )
return "";
451 static TempStrings<5> tempstrs;
453 std::string & outs { tempstrs.getNext() };
454 cap2strHelper( outs,
myPool().getPool(),
id(), 0 );
513 "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
527 if (
detail.isNamed() && !::strpbrk(
detail.name().c_str(),
"*?[{" )
532 std::string guess(
detail.name().asString() );
533 std::string::size_type pos( guess.rfind(
'-' ) );
551 if ( (pos = guess.rfind(
'-', pos-1 )) != std::string::npos )
614 std::optional<
decltype(lvl_r.rbegin())> lastch;
615 if ( not lvl_r.empty() )
616 lastch = lvl_r.rbegin();
618 if ( d.isExpression() ) {
619 static const char* ts =
" +|+ ";
620 const char* t = lastch && **lastch ==
'l' ? ts : ts+2;
621 if ( lastch ) **lastch = t[0];
623 if ( lastch ) **lastch = t[1];
624 str << lvl_r <<
"<" << d.capRel() << endl;
625 if ( lastch ) **lastch = t[2];
628 if ( lastch ) **lastch =
' ';
629 str << lvl_r <<
'"' << d <<
'"';
647 if ( ! ISRELDEP(
_lhs) )
654 ::Reldep * rd = GETRELDEP(
myPool().getPool(),
_lhs );
663 if ( ! ISRELDEP(
_lhs) )
699 static const char archsep =
'.';
700 switch ( obj.
kind() )
703 return str <<
"<NoCap>";
717 return str <<
" " << obj.
op() <<
" " << obj.
ed();
742 return str <<
"<UnknownCap(" << obj.
lhs() <<
" " << obj.
capRel() <<
" " << obj.
rhs() <<
")>";
754 return str <<
"UnknownCap";
760 return str <<
"NoCapRel";
761 return str << static_cast<Capability::CapRel>(obj);
Helper providing more detailed information about a Capability.
sat::detail::IdType _archIfSimple
CapRel
Enum values corresponding with libsolv defines.
@ REL_NONE
Not an expression.
@ CAP_ARCH
Used internally.
Tri state Capability match result.
static const CapMatch irrelevant
static const CapMatch yes
sat::detail::IdType id() const
Expert backdoor.
static const Capability Null
No or Null Capability ( Id 0 ).
Capability()
Default ctor, Empty capability.
bool empty() const
Whether the Capability is empty.
CapRel
Enum values correspond with libsolv defines.
@ CAP_ARCH
Used internally.
CapDetail detail() const
Helper providing more detailed information about a Capability.
const char * c_str() const
Conversion to const char *.
static CapMatch _doMatch(sat::detail::IdType lhs, sat::detail::IdType rhs)
Match two Capabilities.
static bool isInterestingFileSpec(const IdString &name_r)
Test for a filename that is likely being REQUIRED.
static const Capability Empty
Empty Capability.
static Capability guessPackageSpec(const std::string &str_r)
Capability parser also guessing "libzypp-1.2.3-4.5.x86_64" formats.
Edition represents [epoch:]version[-release].
Range< Edition, Match > MatchRange
Edition Range based on Match.
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Access to the sat-pools string space.
const char * c_str() const
Conversion to const char *.
constexpr bool empty() const
Whether the string is empty.
IdType id() const
Expert backdoor.
static const ResKind srcpackage
static ResPool instance()
Singleton ctor.
static Pool instance()
Singleton ctor.
detail::CPool * get() const
Expert backdoor.
Helper that splits an identifier into kind and name or vice versa.
Container of Solvable providing a Capability (read only).
bool empty() const
Whether the container is empty.
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
@ nosubs
Support for substring addressing of matches is not required.
Regular expression match result.
String related utilities and Regular expression matching.
static const IdType emptyId(1)
static const IdType noId(0)
int IdType
Generic Id type.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
std::string numstring(char n, int w=0)
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
void split(ParamVec &pvec, const std::string &pstr, const std::string &psep)
Split into a parameter vector.
Easy-to use interface to the ZYPP dependency resolver.
ResolverNamespace
The resolver's dependency namespaces.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
const Arch Arch_empty(IdString::Empty)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::string asString(const Patch::Category &obj)
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
std::ostream & _dumpRec(std::ostream &str, Capability cap_r, std::string lvl_r="") const
std::ostream & dumpOn(std::ostream &str) const
static PoolImpl & myPool()