X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=c%2B%2B0x%2Fxml-template.h;h=7cfa0d8dc1a3de85ffc2fdae41e3d41108dc1062;hb=6d6f69fcdf45c3afc82212c5c3d8085c93ec4717;hp=4728dbf088379b5edc998285408e28ed07e06aff;hpb=29f0ad69120092c93021e37f764777d5ccd84d3e;p=xml-template diff --git a/c++0x/xml-template.h b/c++0x/xml-template.h index 4728dbf..7cfa0d8 100644 --- a/c++0x/xml-template.h +++ b/c++0x/xml-template.h @@ -25,15 +25,30 @@ class Replace : public Directive { const std::string str; }; +class ReplaceInclude : public Directive { + public: + ReplaceInclude(xmlNodePtr included_node); + ReplaceInclude(xmlDocPtr included_doc); + ~ReplaceInclude(); + virtual void process(xmlNode *node, bool clean); + + private: + xmlNodePtr included_node; + xmlDocPtr included_doc; +}; + +class Substitute; + class Clone : public Directive { public: Clone(const std::vector &subdirectives); + Clone(const std::vector &subdirectives); Clone(std::initializer_list subdirectives); ~Clone(); virtual void process(xmlNode *node, bool clean); private: - const std::vector subdirectives; + std::vector subdirectives; }; class Substitute : public Directive { @@ -45,11 +60,21 @@ class Substitute : public Directive { virtual void process(xmlNode *node, bool clean); private: - const std::unordered_map substitution_map; + friend class Alternate; + std::unordered_map substitution_map; +}; + +class Alternate : public Clone { + public: + Alternate(const std::string &attribute, + const std::vector &subdirectives_subs, + const std::vector &alternatives); }; -void process_file(const std::string &input_filename, - const std::string &output_filename, - Directive *root_directive); +xmlDocPtr process_file(const std::string &input_filename, + Directive *root_directive, + bool clean = true); + +void output_to_fd_and_free(xmlDocPtr doc, int fd); #endif // !defined(_XML_TEMPLATE_H)