diff options
Diffstat (limited to 'main/xmlgenerator.h')
| -rw-r--r-- | main/xmlgenerator.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/main/xmlgenerator.h b/main/xmlgenerator.h new file mode 100644 index 00000000..0dbb2628 --- /dev/null +++ b/main/xmlgenerator.h @@ -0,0 +1,43 @@ +#ifndef _main_xmlgenerator_h__ +#define _main_xmlgenerator_h__ + +#include <cstdarg> +#include <cstdio> +#include <stack> +#include <string> + +class XmlGenerator +{ +private: + FILE *m_file; + bool m_indent; + unsigned int m_level; + std::stack<std::string> m_tags; + + void vprint(const char *fmt, va_list ap, bool newline); + void __attribute__ ((__format__(__printf__, 2, 3))) print(const char *fmt, ...); + void __attribute__ ((__format__(__printf__, 2, 3))) printLn(const char *fmt, ...); + + void open(const std::string &tag, bool newline); + void commentFromErrno(const std::string &tag); + + std::string cDataEscape(const std::string &str); + +public: + XmlGenerator(FILE *f); + ~XmlGenerator(); + + void open(const std::string &tag); + void close(); + + void comment(const std::string &str); + + void cDataFromCmd(const std::string &tag, const std::string &cmd); + void cDataFromFile(const std::string &tag, const std::string &filename, const char *filter = 0); + void cDataFromString(const std::string &tag, const std::string &str); + + void string(const std::string &tag, const std::string &str); + void stringFromFile(const std::string &tag, const std::string &filename); +}; + +#endif |
