diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
commit | bada6666c70977a058755ccf232e7d67b24adeed (patch) | |
tree | 1e92d50cebce96abaf9bce19e36026c47f77b9ba /xsd/examples/cxx/tree/streaming/parser.hxx | |
parent | eaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff) |
New upstream release
Diffstat (limited to 'xsd/examples/cxx/tree/streaming/parser.hxx')
-rw-r--r-- | xsd/examples/cxx/tree/streaming/parser.hxx | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/xsd/examples/cxx/tree/streaming/parser.hxx b/xsd/examples/cxx/tree/streaming/parser.hxx index 000d022..cb34f92 100644 --- a/xsd/examples/cxx/tree/streaming/parser.hxx +++ b/xsd/examples/cxx/tree/streaming/parser.hxx @@ -1,13 +1,10 @@ -// file : examples/cxx/tree/streaming/parser.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : not copyrighted - public domain - #ifndef PARSER_HXX #define PARSER_HXX #include <string> #include <iosfwd> -#include <memory> // std::auto_ptr +#include <cstddef> // std::size_t +#include <memory> // std::auto_ptr #include <xercesc/dom/DOMDocument.hpp> @@ -18,20 +15,44 @@ class parser_impl; class parser { public: + // We can specify embedded XML Schema grammar to be used by the parser + // that was created by the xsdbin utility from the 'embedded' example. + // + parser (const XMLByte* grammar = 0, std::size_t grammar_size = 0); ~parser (); - parser (); - // The start function returns a "carcase" of the complete document. That - // is, the root element with all the attributes but without any content. + // The start function prepares everything for parsing a new document. // - xsd::cxx::xml::dom::auto_ptr<xercesc::DOMDocument> + void start (std::istream& is, const std::string& id, bool validate); - // The next function returns next first-level element with all its - // attributes and content or 0 if no more available. + typedef xsd::cxx::xml::dom::auto_ptr<xercesc::DOMDocument> document_ptr; + + // The peek function parses just the next element (ignoring any + // preceding content assuming it is whitespace) without parsing + // any of its nested content (but it includes the element's + // attributes). It returns NULL if there are no more elements + // at this level (there could still be on outer levels in case + // of nested streaming). + // + document_ptr + peek (); + + // The next function parses (or finishes parsing after peek) the + // next element including its nested content. It returns NULL if + // there are no more elements at this level (there could still + // be on outer levels in case of nested streaming). + // + // If doc is not NULL, then it should be the document returned + // by peek(). That is, a document with only the root element. + // In this case next() finishes parsing this element. + // + // If outer_doc is not NULL, then next() will first add doc to + // outer_doc as a child of the document root. // - xsd::cxx::xml::dom::auto_ptr<xercesc::DOMDocument> - next (); + document_ptr + next (document_ptr doc = document_ptr (), + document_ptr outer_doc = document_ptr ()); private: parser (const parser&); |