![]() |
zeep::http::basic_template_processor — base class for template processors
// 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 >); };
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 member functionsvirtual void set_docroot(const std::filesystem::path & docroot);set the docroot for this processor
std::filesystem::path get_docroot() const;get the current docroot of this processor
virtual void process_tags(xml::node * node, const scope & scope);process all the tags in this node
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. tag_processor * create_tag_processor(const std::string & ns) const;Create a
tag_processor
. virtual void handle_file(const request & request, const scope & scope, reply & reply);Default handler for serving files out of our doc root.
virtual std::filesystem::file_time_type file_time(const std::string & file, std::error_code & ec) = 0;return last_write_time of file
virtual std::istream * load_file(const std::string & file, std::error_code & ec) = 0;return error in ec if file was not found
virtual void load_template(const std::string & file, xml::document & doc);Use load_template to fetch the XHTML template file.
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.
virtual void create_reply_from_template(const std::string & file, const scope & scope, reply & reply);create a reply based on a template
virtual void init_scope(scope & scope);Initialize the scope object.
basic_template_processor
protected member functionsvirtual void process_tags(xml::element * node, const scope & scope, std::set< std::string > registeredNamespaces);process only the tags with the specified namespace prefixes