X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=c%2B%2B0x%2Fxml-template.h;h=35671869868cb35d662250b9c0a5546df6373f5b;hb=ad45bc892752571fec46b21564e4683c074f1d46;hp=f0da0b8b0cdd1d007aca0b35f2b33457b2d47c3b;hpb=4465ec1a182b3e2ebc6a681e2e53a185e774cb0a;p=xml-template diff --git a/c++0x/xml-template.h b/c++0x/xml-template.h index f0da0b8..3567186 100644 --- a/c++0x/xml-template.h +++ b/c++0x/xml-template.h @@ -10,41 +10,58 @@ class Directive { public: + virtual ~Directive(); virtual void process(xmlNode *node, bool clean) = 0; + virtual std::string get_contents(); // Only makes sense for Replace. }; class Replace : public Directive { public: Replace(const std::string &str); virtual void process(xmlNode *node, bool clean); + virtual std::string get_contents(); private: const std::string str; }; +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 { public: Substitute(const std::unordered_map &substitution_map); Substitute(std::initializer_list> substitution_map); + ~Substitute(); 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); + +void output_to_fd_and_free(xmlDocPtr doc, int fd); #endif // !defined(_XML_TEMPLATE_H)