27#include <zypp-core/parser/IniDict>
29#undef ZYPP_BASE_LOGGER_LOGGROUP
30#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
80 std::map<unsigned,VendorList>
lists;
103 using VendorMatch = std::unordered_map<IdString, VendorMatchEntry>;
127 {
return new Impl( *
this ); }
176 unsigned targetId = _vendorGroupId + 1;
184 if ( _vendorGroupMap.count( vendor ) )
186 unsigned joinId = _vendorGroupMap[vendor];
187 if (
targetId == _vendorGroupId + 1 ) {
192 for (
auto &
el : _vendorGroupMap ) {
203 if ( ! vendor.empty() )
207 if (
targetId == _vendorGroupId + 1 )
211 vendorMatchIdReset();
217 str <<
"Equivalent vendors:";
218 for(
const auto &
p :
obj._vendorGroupMap ) {
219 str << endl <<
" [" <<
p.second <<
"] " <<
p.first;
245 MIL <<
"Initial: " << *
this << endl;
252 MIL <<
"Initial " <<
initial_r <<
": " << *
this << endl;
261 MIL <<
"Not a directory " <<
pi << endl;
278 MIL <<
"Not a file " <<
pi << endl;
283 for (
const auto &
el :
dict.entries(
"main") )
285 if (
el.first ==
"vendors" )
288 strv::split(
el.second,
",", strv::Trim::trim,
289 [&
tmp]( std::string_view
word ) {
290 if ( ! word.empty() )
291 tmp.push_back( std::string(word) );
304 {
return _pimpl->foreachVendorList( std::move(
fnc_r) ); }
320 {
return _pimpl->equivalent(
lVendor.satSolvable().vendor(),
rVendor.satSolvable().vendor() ); }
333 {
return _pimpl->relaxedEquivalent(
lVendor.satSolvable().vendor(),
rVendor.satSolvable().vendor() ); }
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
shared_ptr< Impl > _pimpl
Access to the sat-pools string space.
std::string asString() const
Conversion to std::string
Combining sat::Solvable and ResStatus.
VendorAttr implementation.
bool relaxedEquivalent(IdString lVendor, IdString rVendor) const
Return whether two vendor strings should be treated as equivalent or are (suse/opensuse).
VendorMatch _vendorMatch
Cache mapping vendor strings to equivalence class ID.
std::map< std::string, unsigned > VendorGroupMap
unsigned vendorMatchId(IdString vendor) const
Helper mapping a vendor string to its eqivalence class ID.
bool equivalent(IdString lVendor, IdString rVendor) const
Return whether two vendor strings should be treated as equivalent.
Impl * clone() const
clone for RWCOW_pointer
void vendorMatchIdReset()
Reset vendor match cache if _vendorGroupMap was changed.
VendorGroupMap _vendorGroupMap
Vendor group definition. Equivalent groups share the same ID.
std::ostream & operator<<(std::ostream &str, const VendorAttr::Impl &obj)
Stream output.
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
unsigned _nextId
Least equivalence class ID in use (decremented).
unsigned _vendorGroupId
Highest group ID in use (incremented).
unsigned foreachVendorList(const std::function< bool(VendorList)> &fnc_r) const
std::unordered_map< IdString, VendorMatchEntry > VendorMatch
void addVendorList(VendorList &&vendorList_r)
Add a new equivalent vendor set.
Definition of vendor equivalence.
VendorAttr()
Ctor providing the default set.
static VendorAttr & noTargetInstance()
Singleton, settings used if no Target is active.
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
std::vector< std::string > VendorList
Preferred type to pass equivalent vendor strings.
bool addVendorFile(const Pathname &filename_r)
Adding new equivalent vendors described in a file.
RWCOW_pointer< Impl > _pimpl
Implementation class.
unsigned foreachVendorList(std::function< bool(VendorList)> fnc_r) const
Call fnc_r for each equivalent vendor list (return false to break).
bool relaxedEquivalent(const Vendor &lVendor, const Vendor &rVendor) const
Like equivalent but always unifies suse and openSUSE vendor.
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
void _addVendorList(VendorList &&list_r)
bool addVendorDirectory(const Pathname &dirname_r)
Adding new equivalent vendors described in a directory.
static ZConfig & instance()
Singleton ctor.
Wrapper class for stat/lstat.
Parses a INI file and offers its structure as a dictionary.
A Solvable object within the sat Pool.
String related utilities and Regular expression matching.
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
std::string toLower(const std::string &s)
Return lowercase version of s.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
c++17: std::string_view tools