12e5b6d6dSopenharmony_ci// © 2017 and later: Unicode, Inc. and others.
22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
32e5b6d6dSopenharmony_ci// Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
42e5b6d6dSopenharmony_ci#include <stdio.h>
52e5b6d6dSopenharmony_ci#include "unicode/utypes.h"
62e5b6d6dSopenharmony_ci#include <string.h>
72e5b6d6dSopenharmony_ci
82e5b6d6dSopenharmony_ciclass XMLFile {
92e5b6d6dSopenharmony_ci    public:
102e5b6d6dSopenharmony_ci    XMLFile(FILE *f);
112e5b6d6dSopenharmony_ci     ~XMLFile();
122e5b6d6dSopenharmony_ci     /**
132e5b6d6dSopenharmony_ci      * Write indent at current level, increment level, and then return what the initial level was
142e5b6d6dSopenharmony_ci      */
152e5b6d6dSopenharmony_ci     int indent(const char *s, bool single = false);
162e5b6d6dSopenharmony_ci     /**
172e5b6d6dSopenharmony_ci      * Decrement level, write indent of 'outer' level, and return what the new level is. Should match your earlier call to indent.
182e5b6d6dSopenharmony_ci      */
192e5b6d6dSopenharmony_ci     int outdent(const char *s);
202e5b6d6dSopenharmony_ci
212e5b6d6dSopenharmony_ci     /**
222e5b6d6dSopenharmony_ci      * Write some string
232e5b6d6dSopenharmony_ci      */
242e5b6d6dSopenharmony_ci     void writeln(const char *s);
252e5b6d6dSopenharmony_ci
262e5b6d6dSopenharmony_ci     private:
272e5b6d6dSopenharmony_ci       void writeIndent();
282e5b6d6dSopenharmony_ci     /**
292e5b6d6dSopenharmony_ci      * Write some string without indent. */
302e5b6d6dSopenharmony_ci     void write(const char *s);
312e5b6d6dSopenharmony_ci
322e5b6d6dSopenharmony_ci    int level;
332e5b6d6dSopenharmony_ci    FILE *file;
342e5b6d6dSopenharmony_ci};
352e5b6d6dSopenharmony_ci
362e5b6d6dSopenharmony_ciclass XMLElement {
372e5b6d6dSopenharmony_ci    public:
382e5b6d6dSopenharmony_ci        XMLElement(XMLFile &f, const char *name, const char *attribs  = NULL, bool single=false);
392e5b6d6dSopenharmony_ci        ~XMLElement();
402e5b6d6dSopenharmony_ci
412e5b6d6dSopenharmony_ci        const char *name;
422e5b6d6dSopenharmony_ci        int oldlevel;
432e5b6d6dSopenharmony_ci        XMLFile &file;
442e5b6d6dSopenharmony_ci        bool single;
452e5b6d6dSopenharmony_ci};
462e5b6d6dSopenharmony_ci
472e5b6d6dSopenharmony_ci
482e5b6d6dSopenharmony_ci
492e5b6d6dSopenharmony_ci
50