Page MenuHomePhorge

XMLParserWrapper.h
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

XMLParserWrapper.h

#ifndef XMLPARSER_WRAPPER_H
#define XMLPARSER_WRAPPER_H
#include <string>
#include <auto_ptr.h>
#include <bindings/kolabformat-xcal.hxx>
#include <xsd/cxx/tree/error-handler.hxx>
#include <boost/scoped_ptr.hpp>
#include <xsd/cxx/xml/dom/bits/error-handler-proxy.hxx>
#if _XERCES_VERSION >= 30000
# include <xercesc/dom/DOMLSParser.hpp>
# include <xercesc/dom/DOMLSException.hpp>
#else
# include <xercesc/dom/DOMBuilder.hpp>
#endif
#if _XERCES_VERSION >= 30000
# include <xercesc/framework/XMLGrammarPool.hpp>
#else
# include <xercesc/internal/XMLGrammarPool.hpp>
#endif
/**
* This wrapper controls the lifetime of the parser object.
*
* Initializing the parser is much more expensive than parsing a single XML document, therefore the parser should be reused if possible.
*
* It might make sense to use a singleton internally to keep the parser alive between usages. Alternatively this object can be kept alive for as long as it makes sense.
*
* This class also encapsulates the initialization of the whole parser, which must be done manually because precomiled schemas are used (which greatly improves the initialization performance).
*
* Writing the document is static and doesn't need any initialization and is therefore not wrapped by this object.
*
*/
class XMLParserWrapper {
public:
XMLParserWrapper();
~XMLParserWrapper();
static XMLParserWrapper &inst(){
static XMLParserWrapper instance;
return instance;
};
xml_schema::dom::auto_ptr<xercesc::DOMDocument> parseFile(const std::string &url);
xml_schema::dom::auto_ptr<xercesc::DOMDocument> parseString(const std::string &s);
xml_schema::dom::auto_ptr<xercesc::DOMDocument> parse(std::istream &ifs, const std::string &name);
private:
void init();
xsd::cxx::tree::error_handler<char> eh;
xsd::cxx::xml::dom::bits::error_handler_proxy<char> ehp;
#if _XERCES_VERSION >= 30000
xercesc::DOMLSParser *parser;
#else
xercesc::DOMBuilder *parser;
#endif
xercesc::XMLGrammarPool *gp;
};
#endif

File Metadata

Mime Type
text/x-c++
Expires
Mon, Apr 6, 3:05 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827168
Default Alt Text
XMLParserWrapper.h (2 KB)

Event Timeline