libzypp: zypp::parser::Reader Class Reference

libzypp 17.38.14

zypp::parser::Reader Class Reference

xmlTextReader based interface to iterate xml streams. More...

`#include <zypp/parser/xml/Reader.h>`

Inheritance diagram for zypp::parser::Reader:

## Public Types
using | ProcessNode = function<bool (Reader &)>

## Public Member Functions
| Reader (const InputStream &stream_r, const Validate &validate_r=Validate::none())
| Ctor.
| ~Reader ()
| Dtor.
XmlString | nodeText ()
| If the current node is not empty, advances the reader to the next node, and returns the value.
bool | nextNode ()
bool | nextNodeAttribute ()
bool | nextNodeOrAttribute ()
bool | atEnd () const
const Node & | operator* () const
const Node * | operator-> () const
bool | foreachNode (const ProcessNode &fnc_r)
bool | foreachNodeAttribute (const ProcessNode &fnc_r)
bool | foreachNodeOrAttribute (const ProcessNode &fnc_r)
bool | seekToNode (int depth_r, const std::string &name_r)
bool | seekToEndNode (int depth_r, const std::string &name_r)

## Private Member Functions
void | close ()

## Private Attributes
InputStream | _stream
xmlTextReaderPtr | _reader
Node | _node

## Detailed Description

xmlTextReader based interface to iterate xml streams.

// Consume a node.
bool consumeNode( xml::Reader & reader_r )
{
DBG << *reader_r << endl;
return true;
}
// Consume all nodes (omitting attributes)
void example()
{
try
{
xml::Reader reader( "/Local/repodata/repomd.xml" );
reader.foreachNode( consumeNode );
}
catch ( const Exception & )
{ ; } // parse error
}
DBG
#define DBG
Definition Logger.h:102
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::xml::Reader
xmlTextReader based interface to iterate xml streams.
Definition Reader.h:96
// Consume a node.
bool consumeNodeAndAttribute( xml::Reader & reader_r )
{
consumeNode( reader_r );
return reader_r.foreachNodeAttribute( consumeNode );
}
// Consume all nodes and their attributes.
void example()
{
Pathname repodata( "/Local/repodata/repomd.xml" );
try
{
xml::Reader reader( "/Local/repodata/repomd.xml" );
reader.foreachNode( consumeNodeAndAttribute );
// or:
// reader.foreachNodeOrAttribute( consumeNode )
}
catch ( const Exception & )
{ ; } // parse error
}
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::xml::Reader::foreachNodeAttribute
bool foreachNodeAttribute(const ProcessNode &fnc_r)
Definition Reader.h:157

Definition at line 95 of file Reader.h.

## Member Typedef Documentation

## ◆ ProcessNode

using zypp::xml::Reader::ProcessNode = function<bool (Reader &)>

Definition at line 141 of file Reader.h.

## Constructor & Destructor Documentation

## ◆ Reader()

zypp::xml::Reader::Reader | ( | const InputStream & | stream_r,
|  | const Validate & | validate_r = Validate::none() )

Ctor.

Setup xmlTextReader and advance to the 1st Node.

Definition at line 88 of file Reader.cc.

## ◆ ~Reader()

zypp::xml::Reader::~Reader | ( |  | ) |

Dtor.

Definition at line 113 of file Reader.cc.

## Member Function Documentation

## ◆ nodeText()

XmlString zypp::xml::Reader::nodeText | ( |  | ) |

If the current node is not empty, advances the reader to the next node, and returns the value.

Note
  if the node has a xml subtree you will probably jump to that node and get a empty text value back. Use it only if you are sure the node has no XML subtree.

Definition at line 122 of file Reader.cc.

## ◆ nextNode()

bool zypp::xml::Reader::nextNode | ( |  | ) |

Definition at line 142 of file Reader.cc.

## ◆ nextNodeAttribute()

bool zypp::xml::Reader::nextNodeAttribute | ( |  | ) |

Definition at line 162 of file Reader.cc.

## ◆ nextNodeOrAttribute()

bool zypp::xml::Reader::nextNodeOrAttribute | ( |  | ) |
| inline

Definition at line 124 of file Reader.h.

## ◆ atEnd()

bool zypp::xml::Reader::atEnd | ( |  | ) | const
| inline

Definition at line 128 of file Reader.h.

## ◆ operator*()

const Node & zypp::xml::Reader::operator* | ( |  | ) | const
| inline

Definition at line 132 of file Reader.h.

## ◆ operator->()

const Node * zypp::xml::Reader::operator-> | ( |  | ) | const
| inline

Definition at line 136 of file Reader.h.

## ◆ foreachNode()

bool zypp::xml::Reader::foreachNode | ( | const ProcessNode & | fnc_r | ) |
| inline

Definition at line 144 of file Reader.h.

## ◆ foreachNodeAttribute()

bool zypp::xml::Reader::foreachNodeAttribute | ( | const ProcessNode & | fnc_r | ) |
| inline

Definition at line 157 of file Reader.h.

## ◆ foreachNodeOrAttribute()

bool zypp::xml::Reader::foreachNodeOrAttribute | ( | const ProcessNode & | fnc_r | ) |
| inline

Definition at line 170 of file Reader.h.

## ◆ seekToNode()

bool zypp::xml::Reader::seekToNode | ( | int | depth_r,
|  | const std::string & | name_r )

Definition at line 194 of file Reader.cc.

## ◆ seekToEndNode()

bool zypp::xml::Reader::seekToEndNode | ( | int | depth_r,
|  | const std::string & | name_r )

Definition at line 214 of file Reader.cc.

## ◆ close()

void zypp::xml::Reader::close | ( |  | ) |
| private

Definition at line 181 of file Reader.cc.

## Member Data Documentation

## ◆ _stream

InputStream zypp::xml::Reader::_stream
| private

Definition at line 191 of file Reader.h.

## ◆ _reader

xmlTextReaderPtr zypp::xml::Reader::_reader
| private

Definition at line 192 of file Reader.h.

## ◆ _node

Node zypp::xml::Reader::_node
| private

Definition at line 193 of file Reader.h.

The documentation for this class was generated from the following files:

- zypp/parser/xml/Reader.h
- zypp/parser/xml/Reader.cc