Commit 981dc062 authored by Max Kellermann's avatar Max Kellermann

lib/expat/ExpatParser: add constructor overload for XML_ParserCreateNS()

parent 8986d14e
......@@ -38,6 +38,10 @@ public:
:ExpatError(XML_GetErrorCode(parser)) {}
};
struct ExpatNamespaceSeparator {
char separator;
};
class ExpatParser final {
const XML_Parser parser;
......@@ -47,6 +51,11 @@ public:
XML_SetUserData(parser, userData);
}
ExpatParser(ExpatNamespaceSeparator ns, void *userData)
:parser(XML_ParserCreateNS(nullptr, ns.separator)) {
XML_SetUserData(parser, userData);
}
~ExpatParser() {
XML_ParserFree(parser);
}
......@@ -89,6 +98,12 @@ public:
parser.SetCharacterDataHandler(CharacterData);
}
explicit CommonExpatParser(ExpatNamespaceSeparator ns)
:parser(ns, this) {
parser.SetElementHandler(StartElement, EndElement);
parser.SetCharacterDataHandler(CharacterData);
}
void Parse(const char *data, size_t length, bool is_final) {
parser.Parse(data, length, is_final);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment