libzeep

PrevUpHomeNext

Class tag_processor_v2

zeep::http::tag_processor_v2 — version two of the tag_processor in libzeep

Synopsis

// 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);
};

Description

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 construct/copy/destruct

  1. tag_processor_v2(const char * ns = tag_processor_v2::ns());
    constructor with default namespace

tag_processor_v2 public static functions

  1. static constexpr const char * ns();
    default namespace for this processor

tag_processor_v2 public member functions

  1. virtual 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
  2. 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 functions

  1. void process_node(xml::node * node, const scope & scope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader);
  2. void process_text(xml::text & t, const scope & scope);
  3. void post_process(xml::element * e, const scope & parentScope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader);
  4. 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);
  5. 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);
  6. AttributeAction 
    process_attr_if(xml::element * node, xml::attribute * attr, scope & scope, 
                    std::filesystem::path dir, basic_template_processor & loader, 
                    bool unless);
  7. AttributeAction 
    process_attr_assert(xml::element * node, xml::attribute * attr, scope & scope, 
                        std::filesystem::path dir, 
                        basic_template_processor & loader);
  8. AttributeAction 
    process_attr_text(xml::element * node, xml::attribute * attr, scope & scope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader, bool escaped);
  9. AttributeAction 
    process_attr_switch(xml::element * node, xml::attribute * attr, scope & scope, 
                        std::filesystem::path dir, 
                        basic_template_processor & loader);
  10. AttributeAction 
    process_attr_each(xml::element * node, xml::attribute * attr, scope & scope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader);
  11. AttributeAction 
    process_attr_attr(xml::element * node, xml::attribute * attr, scope & scope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader);
  12. AttributeAction 
    process_attr_with(xml::element * node, xml::attribute * attr, scope & scope, 
                      std::filesystem::path dir, 
                      basic_template_processor & loader);
  13. AttributeAction 
    process_attr_generic(xml::element * node, xml::attribute * attr, 
                         scope & scope, std::filesystem::path dir, 
                         basic_template_processor & loader);
  14. AttributeAction 
    process_attr_boolean_value(xml::element * node, xml::attribute * attr, 
                               scope & scope, std::filesystem::path dir, 
                               basic_template_processor & loader);
  15. AttributeAction 
    process_attr_inline(xml::element * node, xml::attribute * attr, scope & scope, 
                        std::filesystem::path dir, 
                        basic_template_processor & loader);
  16. 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);
  17. AttributeAction 
    process_attr_classappend(xml::element * node, xml::attribute * attr, 
                             scope & scope, std::filesystem::path dir, 
                             basic_template_processor & loader);
  18. AttributeAction 
    process_attr_styleappend(xml::element * node, xml::attribute * attr, 
                             scope & scope, std::filesystem::path dir, 
                             basic_template_processor & loader);
  19. AttributeAction 
    process_attr_remove(xml::element * node, xml::attribute * attr, scope & scope, 
                        std::filesystem::path dir, 
                        basic_template_processor & loader);
  20. AttributeAction 
    process_attr_include(xml::element * node, xml::attribute * attr, 
                         scope & scope, std::filesystem::path dir, 
                         basic_template_processor & loader, 
                         TemplateIncludeAction tia);

PrevUpHomeNext