![]() |
zeep::http::tag_processor_v2 — version two of the tag_processor in libzeep
// In header: <zeep/http/tag-processor.hpp> class tag_processor_v2 : public zeep::http::tag_processor { public: // types typedef std::function< AttributeAction(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &loader)> attr_handler; // each handler returns a code telling the processor what to do with the node enum AttributeAction { none, remove, replace }; // construct/copy/destruct tag_processor_v2(const char * = tag_processor_v2::ns()); // public static functions static constexpr const char * ns(); // public member functions virtual void process_xml(xml::node *, const scope &, std::filesystem::path, basic_template_processor &); void register_attr_handler(const std::string &, attr_handler &&); // protected member functions void process_node(xml::node *, const scope &, std::filesystem::path, basic_template_processor &); void process_text(xml::text &, const scope &); void post_process(xml::element *, const scope &, std::filesystem::path, basic_template_processor &); std::vector< std::unique_ptr< xml::node > > resolve_fragment_spec(xml::element *, std::filesystem::path, basic_template_processor &, const json::element &, const scope &); std::vector< std::unique_ptr< xml::node > > resolve_fragment_spec(xml::element *, std::filesystem::path, basic_template_processor &, const std::string &, const std::string &, bool); AttributeAction process_attr_if(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &, bool); AttributeAction process_attr_assert(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_text(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &, bool); AttributeAction process_attr_switch(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_each(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_attr(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_with(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_generic(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_boolean_value(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_inline(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_append(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &, std::string, bool); AttributeAction process_attr_classappend(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_styleappend(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_remove(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &); AttributeAction process_attr_include(xml::element *, xml::attribute *, scope &, std::filesystem::path, basic_template_processor &, TemplateIncludeAction); };
This is the new tag_processor. It is designed to look a bit like Thymeleaf (https://www.thymeleaf.org/) This processor works on attributes mostly, but can process inline el constructs as well.
The documentention contains a section describing all the xml tags and attributes this processor handles.
tag_processor_v2
public member functionsvirtual void process_xml(xml::node * node, const scope & scope, std::filesystem::path dir, basic_template_processor & loader);process xml parses the XHTML and fills in the special tags and evaluates the el constructs
void register_attr_handler(const std::string & attr, attr_handler && handler);It is possible to extend this processor with custom handlers.
tag_processor_v2
protected member functionsvoid process_node(xml::node * node, const scope & scope, std::filesystem::path dir, basic_template_processor & loader);
void process_text(xml::text & t, const scope & scope);
void post_process(xml::element * e, const scope & parentScope, std::filesystem::path dir, basic_template_processor & loader);
std::vector< std::unique_ptr< xml::node > > resolve_fragment_spec(xml::element * node, std::filesystem::path dir, basic_template_processor & loader, const json::element & spec, const scope & scope);
std::vector< std::unique_ptr< xml::node > > resolve_fragment_spec(xml::element * node, std::filesystem::path dir, basic_template_processor & loader, const std::string & file, const std::string & selector, bool byID);
AttributeAction process_attr_if(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader, bool unless);
AttributeAction process_attr_assert(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_text(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader, bool escaped);
AttributeAction process_attr_switch(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_each(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_attr(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_with(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_generic(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_boolean_value(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_inline(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_append(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader, std::string dest, bool prepend);
AttributeAction process_attr_classappend(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_styleappend(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_remove(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader);
AttributeAction process_attr_include(xml::element * node, xml::attribute * attr, scope & scope, std::filesystem::path dir, basic_template_processor & loader, TemplateIncludeAction tia);