13 #include <zypp/base/Logger.h> 15 #include <zypp/base/String.h> 16 #include <zypp/base/Regex.h> 17 #include <zypp/base/Gettext.h> 18 #include <zypp/base/Exception.h> 25 #include <zypp/sat/detail/PoolImpl.h> 41 for ( ; pos_r != std::string::npos; --pos_r )
43 char ch = str_r[pos_r];
44 if ( ch !=
' ' && ch !=
'\t' )
53 for ( ; pos_r != std::string::npos; --pos_r )
55 char ch = str_r[pos_r];
56 if ( ch ==
' ' || ch ==
'\t' )
63 void splitOpEdition( std::string & str_r, Rel & op_r, Edition & ed_r )
70 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
73 if ( (ch = backskipNWs( str_r, ch )) != std::string::npos )
76 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
79 ch = backskipNWs( str_r, ch );
80 if ( op_r.parseFrom( str_r.substr( ch+1, oe-ch ) ) )
83 ed_r = Edition( str_r.substr( eb+1, ee-eb ) );
84 if ( ch != std::string::npos )
85 ch = backskipWs( str_r, ch );
95 ch = str_r.find_last_of(
"<=>)" );
96 if ( ch != std::string::npos && str_r[ch] !=
')' )
101 ch = str_r.find_first_not_of(
" \t", oe+1 );
102 if ( ch != std::string::npos )
103 ed_r = Edition( str_r.substr( ch ) );
107 if ( str_r[oe] !=
'=' )
113 if ( ch != std::string::npos )
117 case '<': --ch; op_r =
Rel::LE;
break;
118 case '>': --ch; op_r =
Rel::GE;
break;
119 case '!': --ch; op_r =
Rel::NE;
break;
121 default: op_r =
Rel::EQ;
break;
127 if ( ch != std::string::npos )
128 ch = backskipWs( str_r, ch );
139 const std::string & name_r,
141 const Edition & ed_r,
142 const ResKind & kind_r )
145 sat::Solvable::SplitIdent
split( kind_r, name_r );
152 nid = ::pool_rel2id( pool_r, nid, IdString(ARCH_SRC).
id(), REL_ARCH,
true );
158 nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH, true );
164 nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(), true );
174 const std::string & name_r, Rel op_r,
const Edition & ed_r,
175 const ResKind & kind_r )
177 static const Arch srcArch( IdString(ARCH_SRC).
asString() );
187 std::string name( name_r );
190 if ( asep != std::string::npos )
192 Arch ext( name_r.substr( asep+1 ) );
193 if ( ext.isBuiltIn() || ext == srcArch )
200 return relFromStr( pool_r, arch, name, op_r, ed_r, kind_r );
207 const std::string & str_r,
const ResKind & kind_r,
210 std::string name( str_r );
215 splitOpEdition( name, op, ed );
218 if ( arch_r.empty() )
219 return relFromStr( pool_r, name, op, ed, kind_r );
221 return relFromStr( pool_r, arch_r, name, op, ed, kind_r );
234 : _id( relFromStr( myPool().getPool(),
Arch_empty, str_r, prefix_r, flag_r ) )
238 : _id( relFromStr( myPool().getPool(),
Arch_empty, str_r.c_str(), prefix_r, flag_r ) )
242 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
246 : _id( relFromStr( myPool().getPool(), arch_r, str_r.c_str(), prefix_r, flag_r ) )
250 : _id( relFromStr( myPool().getPool(),
Arch_empty, str_r, prefix_r, flag_r ) )
254 : _id( relFromStr( myPool().getPool(),
Arch_empty, str_r, prefix_r, flag_r ) )
258 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
262 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
270 : _id( relFromStr( myPool().getPool(), name_r,
Rel(op_r),
Edition(ed_r), prefix_r ) )
273 : _id( relFromStr( myPool().getPool(), name_r, op_r,
Edition(ed_r), prefix_r ) )
276 : _id( relFromStr( myPool().getPool(), name_r, op_r, ed_r, prefix_r ) )
283 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 )
284 : _id( relFromStr( myPool().getPool(),
Arch(arch_r), name_r,
Rel(op_r),
Edition(ed_r), prefix_r ) )
287 : _id( relFromStr( myPool().getPool(),
Arch(arch_r), name_r, op_r,
Edition(ed_r), prefix_r ) )
290 : _id( relFromStr( myPool().getPool(),
Arch(arch_r), name_r, op_r, ed_r, prefix_r ) )
293 : _id( relFromStr( myPool().getPool(), arch_r, name_r,
Rel(op_r),
Edition(ed_r), prefix_r ) )
296 : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r,
Edition(ed_r), prefix_r ) )
299 : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r, ed_r, prefix_r ) )
307 : _id( ::pool_rel2id( myPool().getPool(), asIdString(namespace_r).id(), (value_r.empty() ? STRID_NULL : value_r.id() ), REL_NAMESPACE, true ) )
312 {
return(
_id ? ::pool_dep2str(
myPool().getPool(),
_id ) :
"" ); }
369 "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
407 if ( (pos = guess.rfind(
'-', pos-1 )) != std::string::npos )
462 if ( ! ISRELDEP(
_lhs) )
469 ::Reldep * rd = GETRELDEP(
myPool().getPool(),
_lhs );
478 if ( ! ISRELDEP(
_lhs) )
514 static const char archsep =
'.';
515 switch ( obj.
kind() )
518 return str <<
"<NoCap>";
530 return str <<
" " << obj.
op() <<
" " << obj.
ed();
547 return str <<
"<UnknownCap>";
559 return str <<
"UnknownCap";
573 return str <<
"UnknownCapRel";
int IdType
Generic Id type.
Container of Solvable providing a Capability (read only).
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
bool empty() const
Whether the container is empty.
static CapMatch _doMatch(sat::detail::IdType lhs, sat::detail::IdType rhs)
Match two Capabilities.
static Capability guessPackageSpec(const std::string &str_r)
Capability parser also guessing "libzypp-1.2.3-4.5.x86_64" formats.
Helper providing more detailed information about a Capability.
std::ostream & operator<<(std::ostream &str, const InputStream &obj)
IdType id() const
Expert backdoor.
const Arch Arch_empty(IdString::Empty)
String related utilities and Regular expression matching.
static const ResKind srcpackage
Access to the sat-pools string space.
Edition represents [epoch:]version[-release]
static bool isInterestingFileSpec(const IdString &name_r)
Test for a filename that is likely being REQUIRED.
Support for substring addressing of matches is not required.
ResolverNamespace
The resolvers dependency namespaces.
static const CapMatch irrelevant
constexpr bool empty() const
Whether the string is empty.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
static const IdType emptyId(1)
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
static PoolImpl & myPool()
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
const char * c_str() const
Conversion to const char *
Tri state Capability match result.
static const Capability Null
No or Null Capability ( Id 0 ).
Regular expression match result.
sat::detail::IdType _archIfSimple
static const IdType noId(0)
static const Capability Empty
Empty Capability.
Capability()
Default ctor, Empty capability.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
std::string asString() const
Conversion to std::string
CapRel
Enum values corresponding with libsolv defines.
static const CapMatch yes
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
CapDetail detail() const
Helper providing more detailed information about a Capability.
Easy-to use interface to the ZYPP dependency resolver.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
const char * c_str() const
Conversion to const char *
static ResPool instance()
Singleton ctor.