From 728f5f70f2ece1e2ac1e70cf5a3512b6cfd8cd83 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Mon, 1 Nov 2010 14:36:06 +0100 Subject: bsod: use simple XML generator --- main/xmlgenerator.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 main/xmlgenerator.h (limited to 'main/xmlgenerator.h') 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 +#include +#include +#include + +class XmlGenerator +{ +private: + FILE *m_file; + bool m_indent; + unsigned int m_level; + std::stack 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 -- cgit v1.2.3