5 #include "xmlwriter.hpp"
7 XmlWriter::XmlWriter(std::ostream& outstream) :
16 XmlWriter::~XmlWriter()
18 if(sections.size() > 0) {
19 std::cerr << "WARNING: NOT CLOSED: ";
20 for(std::vector<std::string>::iterator i = sections.begin();
21 i != sections.end(); ++i)
22 std::cerr << *i << " ";
29 void XmlWriter::openTag(const char* name)
36 sections.push_back(name);
39 void XmlWriter::closeTag(const char* name)
41 if(sections.size() == 0)
42 throw std::runtime_error("got closeSection without prior openSection.");
44 const std::string& lastsection = sections.back();
45 if (lastsection != name) {
46 std::ostringstream msg;
47 msg << "mismatch in open/closeSection. Expected '"
48 << lastsection << "' got '" << name << "'";
49 throw std::runtime_error(msg.str());
55 // XXX: We should check for consistency here
60 void XmlWriter::writeTag(const char* name)
68 void XmlWriter::newLine()
72 for (int i=0;i<indent;i++)
77 void XmlWriter::closeTag()
80 out << closetag << "\n";