Merge branch 'bug_599_picload_fd_leak' into experimental
[vuplus_dvbapp] / main / xmlgenerator.h
1 #ifndef _main_xmlgenerator_h__
2 #define _main_xmlgenerator_h__
3
4 #include <cstdarg>
5 #include <cstdio>
6 #include <stack>
7 #include <string>
8
9 class XmlGenerator
10 {
11 private:
12         FILE *m_file;
13         bool m_indent;
14         unsigned int m_level;
15         std::stack<std::string> m_tags;
16
17         void vprint(const char *fmt, va_list ap, bool newline);
18         void __attribute__ ((__format__(__printf__, 2, 3))) print(const char *fmt, ...);
19         void __attribute__ ((__format__(__printf__, 2, 3))) printLn(const char *fmt, ...);
20
21         void open(const std::string &tag, bool newline);
22         void commentFromErrno(const std::string &tag);
23
24         std::string cDataEscape(const std::string &str);
25
26 public:
27         XmlGenerator(FILE *f);
28         ~XmlGenerator();
29
30         void open(const std::string &tag);
31         void close();
32
33         void comment(const std::string &str);
34
35         void cDataFromCmd(const std::string &tag, const std::string &cmd);
36         void cDataFromFile(const std::string &tag, const std::string &filename, const char *filter = 0);
37         void cDataFromString(const std::string &tag, const std::string &str);
38
39         void string(const std::string &tag, const std::string &str);
40         void stringFromFile(const std::string &tag, const std::string &filename);
41 };
42
43 #endif