]> git.sesse.net Git - xml-template/blob - c++0x/xml-template.h
95d485f62bef446262480a104ef5bce8ec904377
[xml-template] / c++0x / xml-template.h
1 #ifndef _XML_TEMPLATE_H
2 #define _XML_TEMPLATE_H 1
3
4 #include <libxml/tree.h>
5
6 #include <string>
7 #include <utility>
8 #include <unordered_map>
9
10 class Directive {
11  public:
12         virtual void process(xmlNode *node, bool clean) = 0;
13 };
14
15 class Replace : public Directive {
16  public:
17         Replace(const std::string &str);
18         virtual void process(xmlNode *node, bool clean);
19
20  private:
21         const std::string str;
22 };
23
24 class Substitute : public Directive {
25  public:
26         Substitute(const std::unordered_map<std::string, Directive*> &substitution_map);
27
28         virtual void process(xmlNode *node, bool clean);
29
30  private:
31         const std::unordered_map<std::string, Directive*> &substitution_map;
32 };
33
34 void process_file(const std::string &input_filename,
35                   const std::string &output_filename,
36                   Directive *root_directive);
37
38 #endif  // !defined(_XML_TEMPLATE_H)