12 #ifndef ZYPP_PARSER_XML_PARSEDEFCONSUME_H 13 #define ZYPP_PARSER_XML_PARSEDEFCONSUME_H 43 virtual void text (
const Node & _node );
45 virtual void done (
const Node & _node );
71 void setRedirect(
const shared_ptr<ParseDefConsume> & target_r );
74 void cancelRedirect();
76 shared_ptr<ParseDefConsume> getRedirect()
const;
80 virtual void text (
const Node & _node );
82 virtual void done (
const Node & _node );
107 virtual void start(
const Node & node_r );
108 virtual void text(
const Node & node_r );
109 virtual void cdata(
const Node & node_r );
110 virtual void done(
const Node & node_r );
126 namespace parse_def_assign
138 virtual void assign(
const char * text_r )
152 virtual void assign(
const char * text_r )
153 { *
_value = Tp( text_r ); }
186 inline AssignerRef assigner( Tp & value_r )
189 template <
class Tp, Tp TInitial>
215 void add(
const AssignerRef & assigner_r )
216 { _text.push_back( assigner_r ); }
219 void add(
const std::string & attr_r,
const AssignerRef & assigner_r )
220 { _attr[attr_r].push_back( assigner_r ); }
235 if ( ! _attr.empty() )
236 for_( it, _attr.begin(), _attr.end() )
237 assign( it->second, node_r.
getAttribute( it->first.c_str() ).c_str() );
242 if ( ! _text.empty() )
253 void assign(
const std::vector<AssignerRef> & vec_r,
const char * value_r )
256 for_( it, vec_r.begin(), vec_r.end() )
257 (*it)->assign( value_r );
261 std::unordered_map<std::string, std::vector<AssignerRef> >
_attr;
263 function<void ( const Node & )>
_pre;
264 function<void ( const Node & )>
_post;
291 { operator()( value_r ); }
295 Builder(
const std::string & attr_r, Tp & value_r )
297 { operator()( attr_r, value_r ); }
302 { _ptr->add( assigner( value_r ) );
return *
this; }
307 { _ptr->add( attr_r, assigner( value_r ) );
return *
this; }
310 Builder & operator<<( function<void ( const Node & )> done_r )
311 { _ptr->prenotify( done_r );
return *
this; }
315 { _ptr->postnotify( done_r );
return *
this; }
318 operator shared_ptr<ParseDefConsume> ()
const 373 #endif // ZYPP_PARSER_XML_PARSEDEFCONSUME_H Builder(const std::string &attr_r, Tp &value_r)
Contruct Consumer.
Tp & get()
Conversion to Tp.
function< void(const Node &)> _post
void add(const std::string &attr_r, const AssignerRef &assigner_r)
Extend Consumer.
bool strToBoolNodefault(const C_Str &str, bool &return_r)
Parse str into a bool if it's a legal true or false string.
shared_ptr< ParseDefConsume > _target
shared_ptr< Assigner< void > > AssignerRef
virtual void text(const xml::Node &node_r)
shared_ptr< Consumer > _ptr
virtual void doneSubnode(const Node &_node)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Builder & operator()(Tp &value_r)
Extend Consumer.
virtual void assign(const char *text_r)
ParseDef consumer that invokes callbacks.
Helper class to build a Consumer.
void postnotify(function< void(const Node &)> post_r)
Set post notification callback.
virtual void cdata(const Node &_node)
XmlString value() const
Provides the text value of the node if present.
xmlTextReader based interface to Reader's current node.
virtual void assign(const char *text_r)
virtual ~ParseDefConsume()
virtual void text(const Node &_node)
void assign(const std::vector< AssignerRef > &vec_r, const char *value_r)
function< void(const Node &)> Callback
virtual void start(const xml::Node &node_r)
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Integral type with defined initial value when default constructed.
Base class for ParseDef consumer.
ParseDef consumer assigning Node text and attribues values to variables.
const char * c_str() const
Explicit conversion to const char *.
Builder(Tp &value_r)
Contruct Consumer.
std::vector< AssignerRef > _text
void prenotify(function< void(const Node &)> pre_r)
Set pre notification callback.
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
function< void(const Node &)> _pre
ParseDef consumer redirecting all events to another consumer.
virtual void done(const xml::Node &node_r)
virtual void done(const Node &_node)
virtual void startSubnode(const Node &_node)
virtual void start(const Node &_node)
Builder & operator()(const std::string &attr_r, Tp &value_r)
Extend Consumer.
void add(const AssignerRef &assigner_r)
Extend Consumer.
Easy-to use interface to the ZYPP dependency resolver.
Builder()
Contruct Consumer.
Builder & operator>>(function< void(const Node &)> done_r)
Set post notification callback.
Assigner assigns text to types constructible from char*.
std::unordered_map< std::string, std::vector< AssignerRef > > _attr