1
0

xmlwrite.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _XML_H
  2. #define _XML_H
  3. #include <bfc/wasabi_std.h>
  4. #include <bfc/stack.h>
  5. #include <bfc/string/StringW.h>
  6. class XMLWrite
  7. {
  8. public:
  9. XMLWrite(const wchar_t *filename, const wchar_t *doctype, const wchar_t *dtddoctype = NULL, int no_hi_chars_conversion = 0);
  10. XMLWrite(FILE *file, const wchar_t *doctype, const wchar_t *dtddoctype = NULL, int no_hi_chars_conversion = 0);
  11. ~XMLWrite();
  12. void Init(FILE *file, const wchar_t *doctype, const wchar_t *dtddoctype);
  13. void comment(const wchar_t *comment);
  14. void pushCategory(const wchar_t *title, int wantcr = 1, int wantindent = 1);
  15. void pushCategoryAttrib(const wchar_t *title, int nodata = FALSE);
  16. void writeCategoryAttrib(const wchar_t *title, const int val);
  17. void writeCategoryAttrib(const wchar_t *title, const wchar_t *val);
  18. void closeCategoryAttrib(int wantcr = 1);
  19. void writeAttribEmpty(const wchar_t *title, int wantcr = 1, int wantindent = 1);
  20. void writeAttrib(const wchar_t *title, const wchar_t *text, int wantcr = 1, int wantindent = 1);
  21. void writeAttrib(const wchar_t *title, int val, int wantcr = 1, int wantindent = 1);
  22. int popCategory(int wantcr = 1, int wantindent = 1); // returns nonzero if more categories are open
  23. static int efprintf(FILE *fp, const wchar_t *format, ...);
  24. static int utf8fprintf(FILE *fp, const wchar_t *format, ...);
  25. static int eutf8fprintf(FILE *fp, const wchar_t *format, ...);
  26. private:
  27. FILE *fp;
  28. StringW indenter;
  29. // int indent;
  30. Stack<wchar_t *>titles;
  31. int nohicharconversion;
  32. };
  33. #endif