From 981dc0626b71e309f6e27d4161620b762bed8545 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Jan 2017 16:17:53 +0100 Subject: [PATCH] lib/expat/ExpatParser: add constructor overload for XML_ParserCreateNS() --- src/lib/expat/ExpatParser.hxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib/expat/ExpatParser.hxx b/src/lib/expat/ExpatParser.hxx index 681b1b28b..1215b8bc4 100644 --- a/src/lib/expat/ExpatParser.hxx +++ b/src/lib/expat/ExpatParser.hxx @@ -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); }