[jdev] A rapidxml fork for XMPP
Dave Cridland
dave at cridland.net
Wed Dec 4 22:49:21 UTC 2013
Since we've been discussing XML parsers a lot...
https://github.com/dwd/rapidxml contains a fork of rapidxml that's been
randomly hacked^W^Wcarefully optimized to make it more useful in XMPP
projects that need particularly fine and/or controlled XML handling.
RapidXML is a C++ XML parser written from scratch by Marcin Kalicinski. It
is written as template code based around C++03, though I'm actually using
it within C++11 (hence the limited testing I've added is C++11).
RapidXML on its own is pretty fast - I think the second fastest XML parser
out there - and can operate in a non-destructive in-place mode, where it
skips entity decoding and hands you back unterminated string pointers into
the source buffer. This is all you need for low-level stanza handling, of
course. It seems to be impressively low in memory footprint, as it
(generally) uses in-buffer rewriting.
This fork adds the ability to then run through the already semi-parsed XML
and terminate strings, decode entities, etc. It will do this either
recursively, or element-by-element, allowing you to do hideous things like
parse out the stanza outer layer, terminate and decode, leaving the inner
XML intact for later forwarding. It's possible this may leave XML purists
in a state of horror, but it's handy in a server.
It also adds the excitement of partial XMLNS support - I've not yet done
namespace well-formedness checking.
Also, various XMPP-specific kinds of parsing have been added. In
particular, it can parse just an open tag (useful for <stream:stream>), and
just one element (useful for stanzas and other TLEs), as well as keeping a
document element "hanging about" (useful for, well, XML streams). This is
absolutely certain to leave XML purists hiding behind the sofa.
It is offered without any kind of warranty, and as is traditional, it may
not work at all. Caveat compiler, and all that. I've not yet bothered
documenting any of the additions I've made, either; this makes it feel more
like an adventure, I think.
It is licensed under the same terms as the original; that is, either the
Boost license or the MIT one. I have probably forgotten to add my copyright
to the relevant files; I do nevertheless have a copyright claim.
Patches are welcome. I might manage to figure out github pull requests one
day, too.
If anyone wishes to produce language-specific wrappers, I'd be keen to see
them too.
Dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.jabber.org/jdev/attachments/20131204/4d8a76c2/attachment.html>
More information about the JDev
mailing list