27 #undef ZYPP_BASE_LOGGER_LOGGROUP 28 #define ZYPP_BASE_LOGGER_LOGGROUP "parser::yum" 52 Reader reader( repomd_file );
53 MIL <<
"Reading " << repomd_file << endl;
54 reader.
foreachNode( bind( &RepomdFileReader::Impl::consumeNode,
this, _1 ) );
60 bool consumeNode(
Reader & reader_r );
102 bool RepomdFileReader::Impl::consumeNode(
Reader & reader_r )
104 if ( reader_r->
nodeType() == XML_READER_TYPE_ELEMENT )
107 if ( reader_r->
name() ==
"repomd" )
113 if ( reader_r->
name() ==
"data" )
120 if ( reader_r->
name() ==
"location" )
128 if ( reader_r->
name() ==
"checksum" )
130 _location.setChecksum( getChecksum( reader_r ) );
135 if ( reader_r->
name() ==
"header-checksum" )
137 _location.setHeaderChecksum( getChecksum( reader_r ) );
142 if ( reader_r->
name() ==
"timestamp" )
149 if ( reader_r->
name() ==
"size" )
151 _location.setDownloadSize( getSize( reader_r ) );
156 if ( reader_r->
name() ==
"header-size" )
158 _location.setHeaderSize( getSize( reader_r ) );
163 if ( reader_r->
name() ==
"content" )
165 const auto & tag = reader_r.
nodeText();
166 if ( tag.c_str() && *tag.c_str() )
167 _keywords.insert( tag.asString() );
172 else if ( reader_r->
nodeType() == XML_READER_TYPE_END_ELEMENT )
175 if ( reader_r->
name() ==
"data" )
178 _callback( std::move(_location), _typeStr );
197 : _pimpl( new
Impl(repomd_file,
std::move(callback)) )
208 {
return _pimpl->keywords(); }
212 std::vector<std::pair<std::string,std::string>> ret;
213 for (
const std::string & tag :
keywords() ) {
217 if ( tag.compare( 0,10,
"gpg-pubkey" ) != 0 )
220 static const str::regex rx(
"^(gpg-pubkey([^?]*))(\\?fpr=([[:xdigit:]]{8,}))?$" );
223 std::string keyfile { what[1] };
224 std::string keyident;
225 if ( what.
size(4) != std::string::npos ) {
229 static const str::regex rx(
"^-([[:xdigit:]]{8,})" );
234 DBG <<
"Tag " << tag <<
" does not contain a keyident. ignore it." << endl;
238 ret.push_back( std::make_pair( std::move(keyfile), std::move(keyident) ) );
std::string _typeStr
The resource type string.
Store and operate with byte count.
NodeType nodeType() const
Get the node type of the current node.
Impl(const Pathname &repomd_file, ProcessResource &&callback)
Ctro taking a ProcessResource callback.
ByteCount getSize(Reader &reader_r)
Retrieve a size node.
OnMediaLocation _location
Location of metadata file.
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
std::vector< std::pair< std::string, std::string > > keyhints() const
gpg key hits shipped in keywords (bsc#1184326)
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
RepomdFileReader(const Pathname &repomd_file, ProcessResource callback)
CTOR.
const std::set< std::string > & keywords() const
repo keywords parsed on the fly
function< bool(OnMediaLocation &&, const std::string &)> ProcessResource
Callback taking OnMediaLocation and the resource type string.
const ProcessCredentials & _callback
Regular expression match result.
bool foreachNode(const ProcessNode &fnc_r)
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value...
CheckSum getChecksum(Reader &reader_r)
Retrieve a checksum node.
std::string asString() const
Explicit conversion to std::string.
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
std::set< std::string > _keywords
repo keywords parsed on the fly
Interface of repomd.xml file reader.
ProcessResource _callback
Function for processing collected data.
Easy-to use interface to the ZYPP dependency resolver.
const std::set< std::string > & keywords() const
repo keywords parsed on the fly
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
xmlTextReader based interface to iterate xml streams.