libzeep

PrevUpHomeNext

Class basic_template_processor

zeep::http::basic_template_processor — base class for template processors

Synopsis

// In header: <zeep/http/template-processor.hpp>


class basic_template_processor {
public:
  // construct/copy/destruct
  basic_template_processor(const std::string &);
  ~basic_template_processor();

  // public member functions
  virtual void set_docroot(const std::filesystem::path &);
  std::filesystem::path get_docroot() const;
  virtual void process_tags(xml::node *, const scope &);
  template<typename TagProcessor> 
    void register_tag_processor(const std::string & = TagProcessor::ns());
  tag_processor * create_tag_processor(const std::string &) const;
  virtual void handle_file(const request &, const scope &, reply &);
  virtual std::filesystem::file_time_type 
  file_time(const std::string &, std::error_code &) = 0;
  virtual std::istream * load_file(const std::string &, std::error_code &) = 0;
  virtual void load_template(const std::string &, xml::document &);
  virtual std::tuple< bool, std::filesystem::path > 
  is_template_file(const std::string &);
  virtual void 
  create_reply_from_template(const std::string &, const scope &, reply &);
  virtual void init_scope(scope &);

  // protected member functions
  virtual void 
  process_tags(xml::element *, const scope &, std::set< std::string >);
};

Description

template_processor is used to create XHTML web pages based on the contents of a template file and the parameters passed in the request and calculated data stored in a scope object.

basic_template_processor public construct/copy/destruct

  1. basic_template_processor(const std::string & docroot);
  2. ~basic_template_processor();

basic_template_processor public member functions

  1. virtual void set_docroot(const std::filesystem::path & docroot);
    set the docroot for this processor
  2. std::filesystem::path get_docroot() const;
    get the current docroot of this processor
  3. virtual void process_tags(xml::node * node, const scope & scope);
    process all the tags in this node
  4. template<typename TagProcessor> 
      void register_tag_processor(const std::string & ns = TagProcessor::ns());
    Use to register a new tag_processor and couple it to a namespace.
  5. tag_processor * create_tag_processor(const std::string & ns) const;
    Create a tag_processor.
  6. virtual void 
    handle_file(const request & request, const scope & scope, reply & reply);
    Default handler for serving files out of our doc root.
  7. virtual std::filesystem::file_time_type 
    file_time(const std::string & file, std::error_code & ec) = 0;
    return last_write_time of file
  8. virtual std::istream * 
    load_file(const std::string & file, std::error_code & ec) = 0;
    return error in ec if file was not found
  9. virtual void load_template(const std::string & file, xml::document & doc);
    Use load_template to fetch the XHTML template file.
  10. virtual std::tuple< bool, std::filesystem::path > 
    is_template_file(const std::string & file);
    Check if the argument file contains a valid reference to an XHTML template file and return the path, if any.
  11. virtual void 
    create_reply_from_template(const std::string & file, const scope & scope, 
                               reply & reply);
    create a reply based on a template
  12. virtual void init_scope(scope & scope);
    Initialize the scope object.

basic_template_processor protected member functions

  1. virtual void 
    process_tags(xml::element * node, const scope & scope, 
                 std::set< std::string > registeredNamespaces);
    process only the tags with the specified namespace prefixes

PrevUpHomeNext