13#include <unordered_map>
19#include <zypp-core/base/InputStream>
20#include <zypp-core/base/DefaultIntegral>
25#include <zypp-core/parser/ParseException>
32#undef ZYPP_BASE_LOGGER_LOGGROUP
33#define ZYPP_BASE_LOGGER_LOGGROUP "parser"
51 void setVar(
const std::string & key_r,
const std::string & val_r )
54 _vars[key_r] = replace( val_r );
58 std::string replace(
const std::string & val_r )
const
60 std::string::size_type vbeg = val_r.find(
"%{", 0 );
61 if ( vbeg == std::string::npos )
65 std::string::size_type cbeg = 0;
66 for( ; vbeg != std::string::npos; vbeg = val_r.find(
"%{", vbeg ) )
68 std::string::size_type nbeg = vbeg+2;
69 std::string::size_type nend = val_r.find(
'}', nbeg );
70 if ( nend == std::string::npos )
72 WAR <<
"Incomplete variable in '" << val_r <<
"'" << endl;
75 const auto & iter =
_vars.find( val_r.substr( nbeg, nend-nbeg ) );
76 if ( iter !=
_vars.end() )
79 ret << val_r.substr( cbeg, vbeg-cbeg );
84 WAR <<
"Undefined variable %{" << val_r.substr( nbeg, nend-nbeg ) <<
"} in '" << val_r <<
"'" << endl;
87 if ( cbeg < val_r.size() )
88 ret << val_r.substr( cbeg );
93 std::unordered_map<std::string,std::string>
_vars;
144 MIL <<
"Reading " <<
is.path() << endl;
166 if (
reader_r->name() ==
"repoindex" )
168 while (
reader_r.nextNodeAttribute() )
170 const std::string & name(
reader_r->localName().asString() );
171 const std::string & value(
reader_r->value().asString() );
172 _replacer.setVar( name, value );
175 _ttl = str::strtonum<Date::Duration>(value);
std::unordered_map< std::string, std::string > _vars
Interface of repoindex.xml file reader.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
What is known about a repository.
void setBaseUrl(Url url)
Clears current base URL list and adds url.
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
void setPath(const Pathname &path)
set the product path.
void setPriority(unsigned newval_r)
Set repository priority for solver.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
DefaultIntegral< Date::Duration, 0 > _ttl
bool consumeNode(Reader &reader_r)
Callback provided to the XML parser.
Impl(const InputStream &is, ProcessResource &&callback)
CTOR.
ProcessResource _callback
Function for processing collected data.
bool getAttrValue(const std::string &key_r, Reader &reader_r, std::string &value_r)
function< bool(const RepoInfo &)> ProcessResource
Callback definition.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
RepoindexFileReader(Pathname repoindexFile, ProcessResource callback)
CTOR.
Date::Duration ttl() const
Metadata TTL (repoindex.xml:xpath:/repoindex@ttl or 0).
~RepoindexFileReader()
DTOR.
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
void setAlias(const std::string &alias)
set the repository alias
void setName(const std::string &name)
set the repository name
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
void setEnabled(bool enabled)
enable or disable the repository
xmlTextReader based interface to iterate xml streams.
const ProcessCredentials & _callback
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Easy-to use interface to the ZYPP dependency resolver.