X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fxml%2FDocumentMemory.hpp;h=ba4fae7c0dc1451c7564437203ea516aab8b1dd0;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=f67611c3e704aea6d524750b481c3dd22396133f;hpb=93366a0bda79e6fd6e7dad6316bfcf8cc82f5731;p=anna.git diff --git a/include/anna/xml/DocumentMemory.hpp b/include/anna/xml/DocumentMemory.hpp index f67611c..ba4fae7 100644 --- a/include/anna/xml/DocumentMemory.hpp +++ b/include/anna/xml/DocumentMemory.hpp @@ -9,7 +9,9 @@ #ifndef anna_xml_DocumentMemory_hpp #define anna_xml_DocumentMemory_hpp +#include #include +#include namespace anna { @@ -23,11 +25,41 @@ public: /** Constructor. */ - DocumentMemory() {;} + DocumentMemory() : a_rootNode(NULL) {;} + + /** + * Root node after parsing, or NULL if not analyzed by mean parse() + * + * @return XML document root node + */ + const Node * getRootNode() const { return a_rootNode; } + + /** + * Parse xml document and return root node + * \return Root node + * \warning Need previous initialization + */ + const Node* parse() noexcept(false) { return (a_rootNode = Document::parse()); } + + /** + * Parse xml document with dtd and return root node + * \param dtd Validation DTD for XML document + * \return Root node + * \warning Need previous initialization + */ + const Node* parse(const DTD& dtd) noexcept(false) { return (a_rootNode = Document::parse(dtd)); } + + /** + * XML representation from loaded document + * \return XML string + * \warning Need previous initialization and parsing + */ + std::string asXmlString() const { Compiler c; return (c.apply(a_rootNode)); } private: - virtual _xmlDoc* do_initialize(const char* content) throw(RuntimeException); - virtual _xmlDoc* do_initialize(const anna::DataBlock& content) throw(RuntimeException); + const anna::xml::Node * a_rootNode; + virtual _xmlDoc* do_initialize(const char* content) noexcept(false); + virtual _xmlDoc* do_initialize(const anna::DataBlock&) noexcept(false); }; }