X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7723eaf21d7d3d0d865545a890d74f3724bf23d2..95d54ec2f747d0b89fff42965a781689e7d4db1e:/projects/sgconf/xml.cpp?ds=sidebyside diff --git a/projects/sgconf/xml.cpp b/projects/sgconf/xml.cpp index 9e1d8f80..bf5589fe 100644 --- a/projects/sgconf/xml.cpp +++ b/projects/sgconf/xml.cpp @@ -1,5 +1,7 @@ #include "xml.h" +#include + #include namespace @@ -10,7 +12,7 @@ struct ParserState size_t level; }; -std::string Indent(size_t size) +std::string Indent(size_t level) { return std::string(level * 4, ' '); } @@ -34,16 +36,16 @@ void Start(void * data, const char * el, const char ** attr) { ParserState * state = static_cast(data); if (el != NULL) - std::cout << Indent(state->level) << "<" << el << PrintAttrs(attr) << ">\n"; + std::cout << Indent(state->level) << "<" << el << PrintAttr(attr) << ">\n"; ++state->level; } void End(void * data, const char * el) { ParserState * state = static_cast(data); +--state->level; if (el != NULL) std::cout << Indent(state->level) << "\n"; ---state->level; } } @@ -58,8 +60,8 @@ XML_SetElementHandler(parser, Start, End); XML_SetUserData(parser, &state); if (XML_Parse(parser, xml.c_str(), xml.length(), true) == XML_STATUS_ERROR) - std::cerr << "XML parse error at line " << XML_GetCurrentLineNumber(sc->parser) - << ": '" << XML_ErrorString(XML_GetErrorCode(sc->parser)) << "'" + std::cerr << "XML parse error at line " << XML_GetCurrentLineNumber(parser) + << ": '" << XML_ErrorString(XML_GetErrorCode(parser)) << "'" << std::endl; XML_ParserFree(parser);