diff --git a/include/Swiften/Parser/StringTreeParser.cpp b/include/Swiften/Parser/StringTreeParser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..92412d14a429d831e93f94289fd0e3b5c369ba5a --- /dev/null +++ b/include/Swiften/Parser/StringTreeParser.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include +#include +#include +#include + +namespace Swift { + +class DefaultStringTreeParser : public StringTreeParser { + public: + void handleTree(ParserElement::ref root) { + root_ = root; + } + + ParserElement::ref getRoot() { + return root_; + } + + private: + ParserElement::ref root_; +}; + +ParserElement::ref StringTreeParser::parse(const std::string &xml) { + PlatformXMLParserFactory factory; + DefaultStringTreeParser client; + XMLParser *parser = factory.createXMLParser(&client); + + parser->parse(xml); + ParserElement::ref root = client.getRoot(); + delete parser; + return root; +} + +}