diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-07 16:17:53 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-07 16:17:53 +0100 |
commit | 981dc0626b71e309f6e27d4161620b762bed8545 (patch) | |
tree | f394605eeb64aad0e6a39c3b8c9b130199b5cbd6 /src/lib/expat | |
parent | 8986d14e985d3459ca761df97c1eb2bd7f614f2a (diff) |
lib/expat/ExpatParser: add constructor overload for XML_ParserCreateNS()
Diffstat (limited to 'src/lib/expat')
-rw-r--r-- | src/lib/expat/ExpatParser.hxx | 15 |
1 files changed, 15 insertions, 0 deletions
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); } |