1 // © 2017 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 // Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved. 4 #include <stdio.h> 5 #include "unicode/utypes.h" 6 #include <string.h> 7 8 class XMLFile { 9 public: 10 XMLFile(FILE *f); 11 ~XMLFile(); 12 /** 13 * Write indent at current level, increment level, and then return what the initial level was 14 */ 15 int indent(const char *s, bool single = false); 16 /** 17 * Decrement level, write indent of 'outer' level, and return what the new level is. Should match your earlier call to indent. 18 */ 19 int outdent(const char *s); 20 21 /** 22 * Write some string 23 */ 24 void writeln(const char *s); 25 26 private: 27 void writeIndent(); 28 /** 29 * Write some string without indent. */ 30 void write(const char *s); 31 32 int level; 33 FILE *file; 34 }; 35 36 class XMLElement { 37 public: 38 XMLElement(XMLFile &f, const char *name, const char *attribs = NULL, bool single=false); 39 ~XMLElement(); 40 41 const char *name; 42 int oldlevel; 43 XMLFile &file; 44 bool single; 45 }; 46 47 48 49 50