1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/parser/WebpinResultFileReader.cc
13
#include "zypp/base/Logger.h"
14
#include "zypp/base/String.h"
15
#include "zypp/base/InputStream.h"
16
#include "zypp/base/UserRequestException.h"
18
#include "zypp/parser/xml/Reader.h"
19
#include "zypp/parser/ws/WebpinResultFileReader.h"
20
#include "zypp/ws/WebpinResult.h"
23
using namespace zypp::xml;
24
using namespace zypp::ws;
33
class WebpinResultFileReader::Impl
36
Impl( const Pathname &result_file,
37
const ProcessWebpinResult &callback );
40
* Callback provided to the XML parser.
42
bool consumeNode( Reader & reader_r );
44
shared_ptr<WebpinResult> _result;
45
ProcessWebpinResult _callback;
48
bool WebpinResultFileReader::Impl::consumeNode(Reader & reader_r)
50
if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT )
53
if ( reader_r->name() == "packages" )
58
// xpath: /packages/package (+)
59
if ( reader_r->name() == "package" )
60
{ _result.reset( new WebpinResult() ); }
62
// xpath: /packages/name
63
if ( reader_r->name() == "name" )
64
{ _result->setName(reader_r.nodeText().asString());}
66
// xpath: /packages/version
67
if ( reader_r->name() == "version" )
68
{ _result->setEdition(Edition(reader_r.nodeText().asString())); }
70
// xpath: /packages/summary
71
if ( reader_r->name() == "summary" )
72
{ _result->setSummary(reader_r.nodeText().asString()); }
74
// xpath: /packages/repoURL
75
if ( reader_r->name() == "repoURL" )
76
{ _result->setRepositoryUrl(Url(reader_r.nodeText().asString())); }
78
// xpath: /packages/checksum
79
if ( reader_r->name() == "checksum" )
80
{ _result->setChecksum(CheckSum::sha1(reader_r.nodeText().asString())); }
81
// xpath: /packages/distro
82
if ( reader_r->name() == "distro" )
83
{ _result->setDistribution(reader_r.nodeText().asString());}
87
else if ( reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT )
89
// xpath: /packages/package (+)
90
if ( reader_r->name() == "package" )
100
WebpinResultFileReader::Impl::Impl( const Pathname &result_file,
101
const ProcessWebpinResult &callback )
102
: _callback(callback)
104
Reader reader( result_file );
105
MIL << "Reading " << result_file << endl;
106
reader.foreachNode( bind( &WebpinResultFileReader::Impl::consumeNode, this, _1 ) );
110
WebpinResultFileReader::WebpinResultFileReader( const Pathname & result_file,
111
const ProcessWebpinResult & callback )
112
: _pimpl(new WebpinResultFileReader::Impl(result_file, callback))
116
WebpinResultFileReader::~WebpinResultFileReader()
119
std::ostream & operator<<( std::ostream & str, const WebpinResultFileReader & obj )
126
} // namespace parser