1 #ifndef __XMLWRITER_H__
2 #define __XMLWRITER_H__
8 /** This class is a class which helps printing formated xml output.
11 * xml.openTag("world");
12 * xml.writeAttribute("name", "foo");
13 * xml.writeTag("bar");
14 * xml.writeTag("baz");
15 * xml.writeAttribute("name", "boo");
16 * xml.writeAttribute("style", "old");
18 * xml.closeTag("world");
19 * results in this output:
22 * <baz name="boo" style="old">text</baz>
27 XmlWriter(std::ostream& out);
30 /** Start a xml tag which contains subtags */
31 void openTag(const char* name);
32 /** Closes an xml tag with subtags */
33 void closeTag(const char* name);
35 void writeTag(const char* name);
38 void comment(const T& outp)
39 { // This routine writes just about anything as an XML comment.
41 out << "<!-- " << outp ;
47 void write(const T& text)
49 if (closetag[0]=='>') {
52 } else if (closetag[0]=='/') {
53 out << ">"; // eventually we should place a \n here
62 void writeAttribute(const char* name, T value)
64 out << " " << name << "=\"" << value << "\"";
75 std::vector<std::string> sections;