1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ServiceInfo.cc
15 #include "zypp/parser/xml/XmlEscape.h"
17 #include "zypp/RepoInfo.h"
18 #include "zypp/parser/RepoindexFileReader.h"
19 #include "zypp/repo/RepoInfoBaseImpl.h"
21 #include "zypp/ServiceInfo.h"
24 using zypp::xml::escape;
26 ///////////////////////////////////////////////////////////////////////////////
28 {//////////////////////////////////////////////////////////////////////////////
31 struct RepoInfoCollector
33 vector<RepoInfo> repos;
34 bool collect(const RepoInfo & info)
36 repos.push_back(info);
41 ///////////////////////////////////////////////////////////////////
43 // CLASS NAME : ServiceInfo::Impl
45 struct ServiceInfo::Impl : public repo::RepoInfoBase::Impl
47 typedef ServiceInfo::CatalogsToEnable CatalogsToEnable;
51 CatalogsToEnable catalogsToEnable;
54 Impl() : repo::RepoInfoBase::Impl() {}
56 Impl(const Url & url_) : url(url_) {}
59 friend Impl * rwcowClone<Impl>( const Impl * rhs );
61 /** clone for RWCOW_pointer */
63 { return new Impl( *this ); }
65 ///////////////////////////////////////////////////////////////////
68 ///////////////////////////////////////////////////////////////////
70 // CLASS NAME : ServiceInfo::Impl
72 ///////////////////////////////////////////////////////////////////
74 const ServiceInfo ServiceInfo::noService;
76 ServiceInfo::ServiceInfo() : _pimpl( new Impl() ) {}
78 ServiceInfo::ServiceInfo(const string & alias)
79 : repo::RepoInfoBase(alias), _pimpl( new Impl() )
82 ServiceInfo::ServiceInfo(const string & alias, const Url & url)
83 : repo::RepoInfoBase(alias), _pimpl( new Impl(url) )
86 Url ServiceInfo::url() const { return _pimpl->url; }
87 void ServiceInfo::setUrl( const Url& url ) { _pimpl->url = url; }
90 bool catalogsToEnableEmpty() const
91 { return _pimpl->catalogsToEnable.empty(); }
93 CatalogsToEnable::size_type catalogsToEnableSize() const
94 { return _pimpl->catalogsToEnable.size(); }
96 CatalogsToEnable::const_iterator catalogsToEnableBegin() const
97 { return _pimpl->catalogsToEnable.begin(); }
99 CatalogsToEnable::const_iterator catalogsToEnableEnd() const
100 { return _pimpl->catalogsToEnable.end(); }
102 bool catalogToEnableFind( const std::string & alias_r ) const
103 { return( _pimpl->catalogsToEnable.find( alias_r ) != _pimpl->catalogsToEnable.end() ); }
105 void addCatalogToEnable( const std::string & alias_r )
106 { return _pimpl->catalogsToEnable.insert( alias_r ); }
108 void delCatalogToEnable( const std::string & alias_r )
109 { return _pimpl->catalogsToEnable.erase( alias_r ); }
112 std::ostream & ServiceInfo::dumpAsIniOn( std::ostream & str ) const
114 return RepoInfoBase::dumpAsIniOn(str)
115 << "url = " << url() << endl;
118 std::ostream & ServiceInfo::dumpAsXMLOn( std::ostream & str) const
122 << " alias=\"" << escape(alias()) << "\""
123 << " name=\"" << escape(name()) << "\""
124 << " enabled=\"" << enabled() << "\""
125 << " autorefresh=\"" << autorefresh() << "\""
126 << " url=\"" << escape(url().asString()) << "\""
130 std::ostream & operator<<( std::ostream& str, const ServiceInfo &obj )
132 return obj.dumpAsIniOn(str);
136 ///////////////////////////////////////////////////////////////////////////////
138 ///////////////////////////////////////////////////////////////////////////////