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 )
145 template <
class _Type>
152 virtual void assign(
const char * text_r )
153 { *
_value = _Type( text_r ); }
186 template <
class _Type>
187 inline AssignerRef assigner( _Type & value_r )
190 template <
class _Tp, _Tp _Initial>
216 void add(
const AssignerRef & assigner_r )
217 { _text.push_back( assigner_r ); }
220 void add(
const std::string & attr_r,
const AssignerRef & assigner_r )
221 { _attr[attr_r].push_back( assigner_r ); }
236 if ( ! _attr.empty() )
237 for_( it, _attr.begin(), _attr.end() )
238 assign( it->second, node_r.
getAttribute( it->first.c_str() ).c_str() );
243 if ( ! _text.empty() )
254 void assign(
const std::vector<AssignerRef> & vec_r,
const char * value_r )
257 for_( it, vec_r.begin(), vec_r.end() )
258 (*it)->assign( value_r );
262 std::tr1::unordered_map<std::string, std::vector<AssignerRef> >
_attr;
264 function<void ( const Node & )>
_pre;
265 function<void ( const Node & )>
_post;
289 template <
class _Type>
292 { operator()( value_r ); }
295 template <
class _Type>
296 Builder(
const std::string & attr_r, _Type & value_r )
298 { operator()( attr_r, value_r ); }
301 template <
class _Type>
303 { _ptr->add( assigner( value_r ) );
return *
this; }
306 template <
class _Type>
308 { _ptr->add( attr_r, assigner( value_r ) );
return *
this; }
311 Builder & operator<<( function<void ( const Node & )> done_r )
312 { _ptr->prenotify( done_r );
return *
this; }
316 { _ptr->postnotify( done_r );
return *
this; }
319 operator shared_ptr<ParseDefConsume> ()
const 359 template <
class _Type>
363 template <
class _Type>
374 #endif // ZYPP_PARSER_XML_PARSEDEFCONSUME_H
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.
Builder & operator()(_Type &value_r)
Extend Consumer.
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.
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)
std::tr1::unordered_map< std::string, std::vector< AssignerRef > > _attr
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 assign(const char *text_r)
virtual void text(const Node &_node)
void assign(const std::vector< AssignerRef > &vec_r, const char *value_r)
_Tp & get()
Conversion to _Tp.
function< void(const Node &)> Callback
virtual void start(const xml::Node &node_r)
Integral type with defined initial value when default constructed.
Builder(const std::string &attr_r, _Type &value_r)
Contruct Consumer.
Builder(_Type &value_r)
Contruct Consumer.
Base class for ParseDef consumer.
_It strtonum(const C_Str &str)
Parsing numbers from string.
ParseDef consumer assigning Node text and attribues values to variables.
const char * c_str() const
Explicit conversion to const char *.
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)
Builder & operator()(const std::string &attr_r, _Type &value_r)
Extend Consumer.
virtual void done(const Node &_node)
virtual void startSubnode(const Node &_node)
virtual void start(const Node &_node)
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*.