36 using zyppng::sat::StringPool;
41 template <
unsigned TLen = 5>
45 std::string & getNext()
46 {
unsigned c = _next; _next = (_next+1) % TLen; _buf[c].clear();
return _buf[c]; }
50 std::string _buf[TLen];
54 inline std::string::size_type backskipWs(
const std::string & str_r, std::string::size_type pos_r )
56 for ( ; pos_r != std::string::npos; --pos_r )
58 char ch = str_r[pos_r];
59 if ( ch !=
' ' && ch !=
'\t' )
66 inline std::string::size_type backskipNWs(
const std::string & str_r, std::string::size_type pos_r )
68 for ( ; pos_r != std::string::npos; --pos_r )
70 char ch = str_r[pos_r];
71 if ( ch ==
' ' || ch ==
'\t' )
78 void splitOpEdition( std::string & str_r, Rel & op_r, Edition & ed_r )
82 std::string::size_type ch( str_r.size()-1 );
85 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
87 std::string::size_type ee( ch );
88 if ( (ch = backskipNWs( str_r, ch )) != std::string::npos )
90 std::string::size_type eb( ch );
91 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
93 std::string::size_type oe( ch );
94 ch = backskipNWs( str_r, ch );
95 if ( op_r.parseFrom( str_r.substr( ch+1, oe-ch ) ) )
98 ed_r =
Edition( str_r.substr( eb+1, ee-eb ) );
99 if ( ch != std::string::npos )
100 ch = backskipWs( str_r, ch );
110 ch = str_r.find_last_of(
"<=>)" );
111 if ( ch != std::string::npos && str_r[ch] !=
')' )
113 std::string::size_type oe( ch );
116 ch = str_r.find_first_not_of(
" \t", oe+1 );
117 if ( ch != std::string::npos )
118 ed_r =
Edition( str_r.substr( ch ) );
122 if ( str_r[oe] !=
'=' )
124 op_r = ( str_r[oe] ==
'<' ) ?
Rel::LT : Rel::GT;
128 if ( ch != std::string::npos )
132 case '<': --ch; op_r =
Rel::LE;
break;
133 case '>': --ch; op_r =
Rel::GE;
break;
134 case '!': --ch; op_r =
Rel::NE;
break;
136 default: op_r =
Rel::EQ;
break;
142 if ( ch != std::string::npos )
143 ch = backskipWs( str_r, ch );
154 const std::string & name_r,
156 const Edition & ed_r,
157 const ResKind & kind_r )
167 nid = ::pool_rel2id( pool_r, nid,
IdString(ARCH_SRC).
id(), REL_ARCH,
true );
173 nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH,
true );
179 nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(),
true );
189 const std::string & name_r, Rel op_r,
const Edition & ed_r,
190 const ResKind & kind_r )
203 std::string name( name_r );
205 std::string::size_type asep( name_r.rfind(
'.' ) );
206 if ( asep != std::string::npos )
208 Arch ext( name_r.substr( asep+1 ) );
209 if ( ext.isBuiltIn() || ext == srcArch || ext == nosrcArch )
216 return relFromStr( pool_r, arch, name, op_r, ed_r, kind_r );
223 const std::string & str_r,
const ResKind & kind_r,
226 std::string name( str_r );
231 splitOpEdition( name, op, ed );
234 if ( arch_r.empty() )
235 return relFromStr( pool_r, name, op, ed, kind_r );
237 return relFromStr( pool_r, arch_r, name, op, ed, kind_r );
243 if ( str_r[0] ==
'(' ) {
245 if ( res )
return res;
249 return relFromStr( pool_r,
Arch_empty, str_r, prefix_r, flag_r );
262 :
_id( richOrRelFromStr(
StringPool::instance().getPool(), str_r, prefix_r, flag_r ) )
266 :
_id( richOrRelFromStr(
StringPool::instance().getPool(), str_r, prefix_r, flag_r ) )
270 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, str_r, prefix_r, flag_r ) )
274 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, str_r, prefix_r, flag_r ) )
286 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, str_r, prefix_r, flag_r ) )
290 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, str_r, prefix_r, flag_r ) )
304 :
_id( relFromStr(
StringPool::instance().getPool(), name_r, op_r, ed_r, prefix_r ) )
311 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 )
318 :
_id( relFromStr(
StringPool::instance().getPool(),
Arch(arch_r), name_r, op_r, ed_r, prefix_r ) )
324 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, name_r, op_r,
Edition(ed_r), prefix_r ) )
327 :
_id( relFromStr(
StringPool::instance().getPool(), arch_r, name_r, op_r, ed_r, prefix_r ) )
331 :
_id( ::pool_rel2id(
StringPool::instance().getPool(), lhs_r.
id(), rhs_r.
id(), rel_r, true ) )
339 :
_id( ::pool_rel2id(
StringPool::instance().getPool(),
asIdString(namespace_r).
id(), (value_r.
empty() ? STRID_NULL : value_r.
id() ), REL_NAMESPACE, true ) )
402 "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
408#if MOVE_CODE_FROM_LEGACY
417 if (
detail.isNamed() && !::strpbrk(
detail.name().c_str(),
"*?[{" )
418 && ::strrchr(
detail.name().c_str(),
'-' ) && sat::WhatProvides( cap ).empty() )
422 std::string guess(
detail.name().asString() );
423 std::string::size_type pos( guess.rfind(
'-' ) );
427 detail = guesscap.detail();
441 if ( (pos = guess.rfind(
'-', pos-1 )) != std::string::npos )
446 detail = guesscap.detail();
465 return guessPackageSpec( str_r, dummy );
482 if ( ! ISRELDEP(
_lhs) )
498 if ( ! ISRELDEP(
_lhs) )
Tri state Capability match result.
static const Capability Null
No or Null Capability ( Id 0 ).
Capability()
Default ctor, Empty 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].
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Access to the sat-pools string space.
constexpr bool empty() const
Whether the string is empty.
IdType id() const
Expert backdoor.
static const ResKind srcpackage
static ResPool instance()
Singleton ctor.
static StringPool & instance()
Access the global StringPool instance.
@ nosubs
Support for substring addressing of matches is not required.
Regular expression match result.
static const CapMatch irrelevant
static const CapMatch yes
Range< Edition, Match > MatchRange
Edition Range based on Match.
static const ResKind srcpackage
Helper providing more detailed information about a Capability.
@ CAP_ARCH
Used internally.
sat::detail::IdType _archIfSimple
CapRel
Enum values correspond with libsolv defines.
CapDetail detail() const
Helper providing more detailed information about a Capability.
sat::detail::IdType id() const
Expert backdoor.
Capability()
Default ctor, Empty capability.
bool empty() const
Whether the Capability is empty.
Helper that splits an identifier into kind and name or vice versa.
Singleton manager for the underlying libsolv string pool.
static StringPool & instance()
Access the global StringPool instance.
detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
bool regex_match(const char *s, smatch &matches, const regex ®ex) ZYPP_API
Regular expression matching.
@ Edition
Editions with v-r setparator highlighted.
int IdType
Generic Id type.
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void split(ParamVec &pvec, const std::string &pstr, const std::string &psep)
Split into a parameter vector.
ResolverNamespace
The resolver's dependency namespaces.
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
const Arch Arch_empty(IdString::Empty)
constexpr IdString asIdString(ResolverNamespace obj)
relates: ResolverNamespace The underlying libsolv ID
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
CLASS NAME : detail::DIWrap.
static const IdType emptyId(1)
static const IdType noId(0)
zypp::sat::detail::IdType IdType
void cap2str(std::string &outs_r, CPool *pool_r, IdType id_r, int parop_r)
Shared logic to convert a sat ID into a human readable string.
This file contains private API, this might break at any time between releases.
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).