Go to the documentation of this file.
29 #undef ZYPP_BASE_LOGGER_LOGGROUP
30 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
68 typedef std::unordered_map<IdString, VendorMatchEntry>
VendorMatch;
89 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
92 {
return new Impl( *
this ); }
141 unsigned targetId = _vendorGroupId + 1;
145 for ( std::string & vendor : vendorList_r )
149 if ( _vendorGroupMap.count( vendor ) )
151 unsigned joinId = _vendorGroupMap[vendor];
152 if ( targetId == _vendorGroupId + 1 ) {
155 else if ( targetId != joinId ) {
157 for (
auto & el : _vendorGroupMap ) {
158 if ( el.second == joinId )
159 el.second = targetId;
167 for ( std::string & vendor : vendorList_r ) {
168 if ( ! vendor.empty() )
169 _vendorGroupMap[vendor] = targetId;
172 if ( targetId == _vendorGroupId + 1 )
176 vendorMatchIdReset();
182 str <<
"Equivalent vendors:";
184 str << endl <<
" [" << p.second <<
"] " << p.first;
210 MIL <<
"Initial: " << *
this << endl;
217 MIL <<
"Initial " << initial_r <<
": " << *
this << endl;
225 if (
PathInfo pi { dirname_r }; ! pi.isDir() ) {
226 MIL <<
"Not a directory " << pi << endl;
231 [
this](
const Pathname & dir_r,
const std::string & str_r )->
bool
242 if (
PathInfo pi { filename_r }; ! pi.isFile() ) {
243 MIL <<
"Not a file " << pi << endl;
248 for (
const auto & el : dict.entries(
"main") )
250 if ( el.first ==
"vendors" )
254 [&tmp]( std::string_view word ) {
255 if ( ! word.empty() )
256 tmp.push_back( std::string(word) );
281 for (
const auto & el : list_r )
282 tmp.push_back( std::string(el) );
RWCOW_pointer< Impl > _pimpl
Implementation class.
Combining sat::Solvable and ResStatus.
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
DefaultIntegral< unsigned, 0 > VendorMatchEntry
A Solvable object within the sat Pool.
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
unsigned vendorMatchId(IdString vendor) const
Helper mapping a vendor string to it's eqivalence class ID.
VendorMatch _vendorMatch
Cache mapping vendor strings to equivalence class ID.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
std::ostream & operator<<(std::ostream &str, const VendorAttr::Impl &obj)
Stream output.
unsigned _nextId
Least equivalence class ID in use (decremented).
bool addVendorDirectory(const Pathname &dirname_r)
Adding new equivalent vendors described in a directory.
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d)
Definition of vendor equivalence.
Parses a INI file and offers its structure as a dictionary.
std::string asString() const
Conversion to std::string
Access to the sat-pools string space.
Impl * clone() const
clone for RWCOW_pointer
Wrapper class for ::stat/::lstat.
unsigned split(std::string_view line_r, std::string_view sep_r, Trim trim_r, std::function< void(std::string_view)> fnc_r)
bool equivalent(IdString lVendor, IdString rVendor) const
Return whether two vendor strings should be treated as equivalent.
bool addVendorFile(const Pathname &filename_r)
Adding new equivalent vendors described in a file.
static ZConfig & instance()
Singleton ctor.
Easy-to use interface to the ZYPP dependency resolver.
std::string toLower(const std::string &s)
Return lowercase version of s.
void vendorMatchIdReset()
Reset vendor match cache if _vendorGroupMap was changed.
void _addVendorList(VendorList &&list_r)
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
std::unordered_map< IdString, VendorMatchEntry > VendorMatch
std::ostream & operator<<(std::ostream &str, const Exception &obj)
std::vector< std::string > VendorList
Preferred type to pass equivalent vendor strings.
unsigned _vendorGroupId
Highest group ID in use (incremented).
static const VendorAttr & instance()
(Pseudo)Singleton, mapped to the current Target::vendorAttr settings or to noTargetInstance.
VendorGroupMap _vendorGroupMap
Vendor group definition. Equivalent groups share the same ID.
VendorAttr implementation.
String related utilities and Regular expression matching.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
std::map< std::string, unsigned > VendorGroupMap
std::string trim(const std::string &s, const Trim trim_r)
void addVendorList(VendorList &&vendorList_r)
Add a new equivalent vendor set.
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.
static VendorAttr & noTargetInstance()
Singleton, settings used if no Target is active.
c++17: std::string_view tools
IdString vendor() const
The vendor.
VendorAttr()
Ctor providing the default set.