20 #include <zypp-core/base/DtorReset> 21 #include <zypp-core/base/DefaultIntegral> 83 DBG << tag_r << node_r << endl;
104 shared_ptr<ParseDefConsume> &&target_r =
105 shared_ptr<ParseDefConsume>())
120 it->second->_parent = NULL;
141 SubNodes::const_iterator it =
_subnodes.find( name_r );
160 std::string
exstr(
const std::string & what_r,
const Impl & impl_r )
const 162 std::ostringstream
str;
163 str << impl_r <<
": " << what_r;
166 std::string
exstr(
const std::string & what_r,
const Impl & impl_r,
const Reader & reader_r )
const 168 std::ostringstream
str;
169 str << impl_r <<
": " << what_r <<
" |reading " << *reader_r;
193 std::pair<SubNodes::iterator, bool> res
194 =
_subnodes.insert( std::make_pair( subnode_r->_name, subnode_r ) );
200 if ( res.first->second->_parent )
204 res.first->second->_parent =
this;
214 if ( reader_r->
nodeType() != XML_READER_TYPE_ELEMENT )
216 if ( reader_r->
depth() == 0 )
225 }
while( reader_r->
nodeType() != XML_READER_TYPE_ELEMENT );
232 if ( reader_r->
name() != _name )
243 _parseDepth = reader_r->
depth();
255 for (
bool done =
false; ! done ; )
265 case XML_READER_TYPE_ELEMENT:
273 sub->take( reader_r );
279 WAR <<
"Skip unknown node " << *reader_r <<
" in "<< *
this << endl;
280 skipNode( reader_r );
285 case XML_READER_TYPE_END_ELEMENT:
287 if ( reader_r->
depth() == _parseDepth
288 && reader_r->
name() == _name )
298 case XML_READER_TYPE_TEXT:
303 case XML_READER_TYPE_CDATA:
317 for ( SubNodes::iterator it = _subnodes.begin(); it != _subnodes.end(); ++it )
319 if ( ! it->second->_visited && it->second->isMandatory() )
323 it->second->_visited = 0;
340 ( exstr(
str::form(
"EOF while looking for [%d] <\\%s>",
355 return str <<
"ParseDef(" << obj.
_name 379 : _pimpl( new
Impl(
std::move(name_r), mode_r,
std::move(target_r) ) )
456 #define X(T) case ParseDef::T: return str << #T 459 X(MULTIPLE_OPTIONAL);
460 X(MULTIPLE_MANDTAORY);
std::unordered_set< sat::detail::IdType > _visited
friend std::ostream & operator<<(std::ostream &str, const ParseDef::Impl &obj)
bit::BitField< ModeBitsType > ModeBits
RW_pointer< Impl > _pimpl
Pointer to implementation (shared!)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Define a xml node structure to parse.
Impl(std::string &&name_r, Mode mode_r, shared_ptr< ParseDefConsume > &&target_r=shared_ptr< ParseDefConsume >())
NodeType nodeType() const
Get the node type of the current node.
constPtrType getPtr() const
String related utilities and Regular expression matching.
void start(const Node &_node) override
void text(const Node &_node) override
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
bool skipNode(Reader &reader_r)
Skip the current node.
DefaultIntegral< int,-1 > _parseDepth
shared_ptr< ParseDefConsume > getRedirect() const
shared_ptr< Impl > ImplPtr
Assign a vaiable a certain value when going out of scope.
Parse exceptions related to the documents node structure.
void cdata(const Node &_node) override
std::map< std::string, ImplPtr > SubNodes
xmlTextReader based interface to Reader's current node.
void startSubnode(const Node &_node) override
void take(Reader &reader_r)
Parse the node.
DefaultIntegral< unsigned, 0 > _visited
void addNode(const ImplPtr &subnode_r)
void start(const Node &node_r) override
void done(const Node &node_r) override
Exceptions when building a ParseDef tree.
const char * c_str() const
Explicit conversion to const char *.
void startSubnode(const Node &node_r) override
bool seekToEndNode(int depth_r, const std::string &name_r)
Base class for ParseDef consumer.
std::string exstr(const std::string &what_r, const Impl &impl_r) const
int depth() const
The depth of the node in the tree.
void doneSubnode(const Node &node_r) override
void take(Reader &reader_r)
ParseDefImplConsume _callback
void setRedirect(shared_ptr< ParseDefConsume > target_r)
shared_ptr< ParseDefConsume > getConsumer() const
Get data consumer.
ParseDef & addNode(ParseDef &subnode_r)
Add subnode definition.
const ProcessCredentials & _callback
ImplPtr getNode(const std::string &name_r) const
ParseDef consumer redirecting all events to another consumer.
void done(const Node &_node) override
Impl & operator=(const Impl &)=delete
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
void cancelConsumer()
Unset data consumer.
const std::string & name() const
friend std::ostream & operator<<(std::ostream &str, const ParseDef &obj)
std::string asString() const
Explicit conversion to std::string.
ParseDef operator[](const std::string &name_r)
Get subnode by name.
std::string exstr(const std::string &what_r, const Impl &impl_r, const Reader &reader_r) const
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
void setConsumer(const shared_ptr< ParseDefConsume > &target_r)
Set data consumer.
int isEmptyElement() const
Check if the current node is empty.
void debuglog(const char *const tag_r, const Node &node_r)
Easy-to use interface to the ZYPP dependency resolver.
void cdata(const Node &node_r) override
ParseDef(std::string name_r, Mode mode_r)
Range of bits starting at bit _begin with length _size.
void doneSubnode(const Node &_node) override
xmlTextReader based interface to iterate xml streams.
void text(const Node &node_r) override