29 #undef ZYPP_BASE_LOGGER_LOGGROUP 30 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr" 63 std::map<unsigned,VendorList> lists;
65 lists[el.second].push_back( el.first );
68 for (
auto el : lists ) {
73 if ( fnc_r && !fnc_r( std::move(vlist) ) )
86 typedef std::unordered_map<IdString, VendorMatchEntry>
VendorMatch;
107 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
110 {
return new Impl( *
this ); }
159 unsigned targetId = _vendorGroupId + 1;
163 for ( std::string & vendor : vendorList_r )
167 if ( _vendorGroupMap.count( vendor ) )
169 unsigned joinId = _vendorGroupMap[vendor];
170 if ( targetId == _vendorGroupId + 1 ) {
173 else if ( targetId != joinId ) {
175 for (
auto & el : _vendorGroupMap ) {
176 if ( el.second == joinId )
177 el.second = targetId;
185 for ( std::string & vendor : vendorList_r ) {
186 if ( ! vendor.empty() )
187 _vendorGroupMap[vendor] = targetId;
190 if ( targetId == _vendorGroupId + 1 )
194 vendorMatchIdReset();
200 str <<
"Equivalent vendors:";
202 str << endl <<
" [" << p.second <<
"] " << p.first;
228 MIL <<
"Initial: " << *
this << endl;
235 MIL <<
"Initial " << initial_r <<
": " << *
this << endl;
243 if (
PathInfo pi { dirname_r }; ! pi.isDir() ) {
244 MIL <<
"Not a directory " << pi << endl;
249 [
this](
const Pathname & dir_r,
const std::string & str_r )->
bool 260 if (
PathInfo pi { filename_r }; ! pi.isFile() ) {
261 MIL <<
"Not a file " << pi << endl;
266 for (
const auto & el : dict.entries(
"main") )
268 if ( el.first ==
"vendors" )
272 [&tmp]( std::string_view word ) {
273 if ( ! word.empty() )
274 tmp.push_back( std::string(word) );
302 for (
const auto & el : list_r )
303 tmp.push_back( std::string(el) );
VendorMatch _vendorMatch
Cache mapping vendor strings to equivalence class ID.
A Solvable object within the sat Pool.
IdString vendor() const
The vendor.
std::ostream & operator<<(std::ostream &str, const VendorAttr::Impl &obj)
c++17: std::string_view tools
unsigned _nextId
Least equivalence class ID in use (decremented).
static ZConfig & instance()
Singleton ctor.
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
VendorAttr()
Ctor providing the default set.
void addVendorList(VendorList &&vendorList_r)
Add a new equivalent vendor set.
RWCOW_pointer< Impl > _pimpl
Implementation class.
DefaultIntegral< unsigned, 0 > VendorMatchEntry
unsigned foreachVendorList(std::function< bool(VendorList)> fnc_r) const
std::vector< std::string > VendorList
Preferred type to pass equivalent vendor strings.
String related utilities and Regular expression matching.
unsigned foreachVendorList(std::function< bool(VendorList)> fnc_r) const
Call fnc_r for each equivalent vendor list (return false to break).
bool addVendorDirectory(const Pathname &dirname_r)
Adding new equivalent vendors described in a directory.
Access to the sat-pools string space.
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d)
void _addVendorList(VendorList &&list_r)
bool addVendorFile(const Pathname &filename_r)
Adding new equivalent vendors described in a file.
Impl * clone() const
clone for RWCOW_pointer
VendorAttr implementation.
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
std::ostream & operator<<(std::ostream &str, const Exception &obj)
std::string trim(const std::string &s, const Trim trim_r)
static VendorAttr & noTargetInstance()
Singleton, settings used if no Target is active.
void vendorMatchIdReset()
Reset vendor match cache if _vendorGroupMap was changed.
Definition of vendor equivalence.
bool equivalent(IdString lVendor, IdString rVendor) const
Return whether two vendor strings should be treated as equivalent.
std::string toLower(const std::string &s)
Return lowercase version of s.
Parses a INI file and offers its structure as a dictionary.
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
std::unordered_map< IdString, VendorMatchEntry > VendorMatch
unsigned _vendorGroupId
Highest group ID in use (incremented).
VendorGroupMap _vendorGroupMap
Vendor group definition. Equivalent groups share the same ID.
Wrapper class for ::stat/::lstat.
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
Combining sat::Solvable and ResStatus.
std::string asString() const
Conversion to std::string
std::map< std::string, unsigned > VendorGroupMap
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
unsigned vendorMatchId(IdString vendor) const
Helper mapping a vendor string to it's eqivalence class ID.
Easy-to use interface to the ZYPP dependency resolver.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
unsigned split(std::string_view line_r, std::string_view sep_r, Trim trim_r, std::function< void(std::string_view)> fnc_r)