Go to the documentation of this file.
13 #include <unordered_map>
31 #undef ZYPP_BASE_LOGGER_LOGGROUP
32 #define ZYPP_BASE_LOGGER_LOGGROUP "parser"
50 void setVar(
const std::string & key_r,
const std::string & val_r )
53 _vars[key_r] = replace( val_r );
57 std::string replace(
const std::string & val_r )
const
60 if ( vbeg == std::string::npos )
65 for( ; vbeg != std::string::npos; vbeg = val_r.find(
"%{", vbeg ) )
69 if ( nend == std::string::npos )
71 WAR <<
"Incomplete variable in '" << val_r <<
"'" << endl;
74 const auto & iter =
_vars.find( val_r.substr( nbeg, nend-nbeg ) );
75 if ( iter !=
_vars.end() )
78 ret << val_r.substr( cbeg, vbeg-cbeg );
83 WAR <<
"Undefined variable %{" << val_r.substr( nbeg, nend-nbeg ) <<
"} in '" << val_r <<
"'" << endl;
86 if ( cbeg < val_r.size() )
87 ret << val_r.substr( cbeg );
92 std::unordered_map<std::string,std::string>
_vars;
125 return !value_r.empty();
143 MIL <<
"Reading " << is.
path() << endl;
162 if ( reader_r->
nodeType() == XML_READER_TYPE_ELEMENT )
165 if ( reader_r->
name() ==
"repoindex" )
171 _replacer.setVar( name, value );
174 _ttl = str::strtonum<Date::Duration>(value);
180 if ( reader_r->
name() ==
"repo" )
187 std::string attrValue;
191 if ( getAttrValue(
"alias", reader_r, attrValue ) )
194 _replacer.setVar(
"alias", attrValue );
204 getAttrValue(
"url", reader_r, urlstr );
205 getAttrValue(
"path", reader_r, pathstr );
206 if ( urlstr.empty() )
208 if ( pathstr.empty() )
215 if ( pathstr.empty() )
220 url.setPathName(
Pathname(
url.getPathName()) /
"repo" / pathstr );
227 if ( getAttrValue(
"name", reader_r, attrValue ) )
231 if ( getAttrValue(
"distro_target", reader_r, attrValue ) )
235 if ( getAttrValue(
"priority", reader_r, attrValue ) )
236 info.
setPriority( str::strtonum<unsigned>( attrValue ) );
240 if ( getAttrValue(
"enabled", reader_r, attrValue ) )
244 if ( getAttrValue(
"autorefresh", reader_r, attrValue ) )
270 : _pimpl(new
Impl(is, callback))
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
xmlTextReader based interface to iterate xml streams.
std::string asString() const
Explicit conversion to std::string.
const ProcessCredentials & _callback
What is known about a repository.
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
void setName(const std::string &name)
set the repository name
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
ProcessResource _callback
Function for processing collected data.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
bool foreachNode(ProcessNode fnc_r)
void setPath(const Pathname &path)
set the product path.
void setPriority(unsigned newval_r)
Set repository priority for solver.
const xmlChar * get() const
Access the xmlChar *.
RepoindexFileReader(const zypp::Pathname &repoindexFile, const ProcessResource &callback)
CTOR.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
NodeType nodeType() const
Get the node type of the current node.
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Date::Duration ttl() const
Metadata TTL (repoindex.xml:xpath:/repoindex@ttl or 0).
XmlString localName() const
The local name of the node.
bool getAttrValue(const std::string &key_r, Reader &reader_r, std::string &value_r)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Easy-to use interface to the ZYPP dependency resolver.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
void setEnabled(bool enabled)
enable or disable the repository
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
std::unordered_map< std::string, std::string > _vars
Impl(const InputStream &is, const ProcessResource &callback)
CTOR.
XmlString value() const
Provides the text value of the node if present.
Interface of repoindex.xml file reader.
void setAlias(const std::string &alias)
set the repository alias
~RepoindexFileReader()
DTOR.
DefaultIntegral< Date::Duration, 0 > _ttl
function< bool(const RepoInfo &)> ProcessResource
Callback definition.
bool consumeNode(Reader &reader_r)
Callback provided to the XML parser.