mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
Corrected for Xerces 2.2.0 release - depending on the compiler, the Xerces stuff maybe in its own namespace
couple of VC++.Net changes Xerces initialiser stuff does not need to be templated, so isn't :)
This commit is contained in:
parent
0a2b8af351
commit
924103481e
2 changed files with 121 additions and 96 deletions
35
SAX/wrappers/saxxerces.cpp
Normal file
35
SAX/wrappers/saxxerces.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable: 4786 4800)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <SAX/ParserConfig.h>
|
||||||
|
|
||||||
|
namespace SAX
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace xerces_implemenation_helper
|
||||||
|
{
|
||||||
|
void xerces_initializer::doInitialize()
|
||||||
|
{
|
||||||
|
if(!count_)
|
||||||
|
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
|
||||||
|
++count_;
|
||||||
|
} // doInitialize
|
||||||
|
|
||||||
|
void xerces_initializer::doTerminate()
|
||||||
|
{
|
||||||
|
--count_;
|
||||||
|
if (!count_)
|
||||||
|
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate();
|
||||||
|
} // doTerminate
|
||||||
|
|
||||||
|
int xerces_initializer::count_ = 0;
|
||||||
|
} //namespace xerces_implemenation_helper
|
||||||
|
|
||||||
|
} // namespace SAX
|
||||||
|
|
||||||
|
// end of file
|
|
@ -23,6 +23,7 @@
|
||||||
#include <SAX/wrappers/XercesFeatureNames.h>
|
#include <SAX/wrappers/XercesFeatureNames.h>
|
||||||
|
|
||||||
// Xerces Includes
|
// Xerces Includes
|
||||||
|
#include <xercesc/util/XercesDefs.hpp>
|
||||||
#include <xercesc/util/PlatformUtils.hpp>
|
#include <xercesc/util/PlatformUtils.hpp>
|
||||||
#include <xercesc/sax2/SAX2XMLReader.hpp>
|
#include <xercesc/sax2/SAX2XMLReader.hpp>
|
||||||
#include <xercesc/sax2/XMLReaderFactory.hpp>
|
#include <xercesc/sax2/XMLReaderFactory.hpp>
|
||||||
|
@ -34,11 +35,58 @@
|
||||||
#include <xercesc/sax/SAXParseException.hpp>
|
#include <xercesc/sax/SAXParseException.hpp>
|
||||||
#include <xercesc/util/BinInputStream.hpp>
|
#include <xercesc/util/BinInputStream.hpp>
|
||||||
#include <xercesc/sax/InputSource.hpp>
|
#include <xercesc/sax/InputSource.hpp>
|
||||||
|
#include <xercesc/sax/Locator.hpp>
|
||||||
|
#include <xercesc/util/Janitor.hpp>
|
||||||
|
|
||||||
|
#ifndef XERCES_HAS_CPP_NAMESPACE
|
||||||
|
#pragma message("No XERCES namespace")
|
||||||
|
#define XERCES_CPP_NAMESPACE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace SAX
|
namespace SAX
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace xerces_implemenation_helper
|
||||||
|
{
|
||||||
|
///////////////////////////////
|
||||||
|
// Xerces platform initializer
|
||||||
|
/**
|
||||||
|
* Class to handle calls to XMLPlatformUtils::Initialize() and
|
||||||
|
* XMLPlatformUtils::Terminate().
|
||||||
|
*
|
||||||
|
* Without such a class, calls to Initialize() and Terminate() may be nested
|
||||||
|
* and cause evil consequences. Eg. A typical use of the old xerces_wrapper
|
||||||
|
* could have resulted in:
|
||||||
|
* <pre>
|
||||||
|
* // Construct two xerces_wrappers.
|
||||||
|
* XMLPlatformUtils::Initialize()
|
||||||
|
* XMLPlatformUtils::Initialize()
|
||||||
|
*
|
||||||
|
* // do stuff
|
||||||
|
*
|
||||||
|
* // Get rid of one of the xerces_wrappers
|
||||||
|
* XMLPlatformUtils::Terminate()
|
||||||
|
*
|
||||||
|
* // do more stuff -- this is _after_ a call to Terminate()...
|
||||||
|
*
|
||||||
|
* XMLPlatformUtils::Terminate()
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
class xerces_initializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
xerces_initializer() { doInitialize(); count_++; }
|
||||||
|
~xerces_initializer() { doTerminate(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void doInitialize();
|
||||||
|
void doTerminate();
|
||||||
|
|
||||||
|
static int count_;
|
||||||
|
};
|
||||||
|
} // namespace xerces_implemenation_helper
|
||||||
|
|
||||||
template<class string_type, class string_adaptor_type = SAX::default_string_adaptor<string_type> >
|
template<class string_type, class string_adaptor_type = SAX::default_string_adaptor<string_type> >
|
||||||
class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
{
|
{
|
||||||
|
@ -83,63 +131,8 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
virtual void doSetProperty(const stringT& name, std::auto_ptr<typename base::PropertyBase> value);
|
virtual void doSetProperty(const stringT& name, std::auto_ptr<typename base::PropertyBase> value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
///////////////////////////////
|
|
||||||
// Xerces platform initializer
|
|
||||||
/**
|
|
||||||
* Class to handle calls to XMLPlatformUtils::Initialize() and
|
|
||||||
* XMLPlatformUtils::Terminate().
|
|
||||||
*
|
|
||||||
* Without such a class, calls to Initialize() and Terminate() may be nested
|
|
||||||
* and cause evil consequences. Eg. A typical use of the old xerces_wrapper
|
|
||||||
* could have resulted in:
|
|
||||||
* <pre>
|
|
||||||
* // Construct two xerces_wrappers.
|
|
||||||
* XMLPlatformUtils::Initialize()
|
|
||||||
* XMLPlatformUtils::Initialize()
|
|
||||||
*
|
|
||||||
* // do stuff
|
|
||||||
*
|
|
||||||
* // Get rid of one of the xerces_wrappers
|
|
||||||
* XMLPlatformUtils::Terminate()
|
|
||||||
*
|
|
||||||
* // do more stuff -- this is _after_ a call to Terminate()...
|
|
||||||
*
|
|
||||||
* XMLPlatformUtils::Terminate()
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
class xerces_initializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
xerces_initializer() { doInitialize(); }
|
|
||||||
~xerces_initializer() { doTerminate(); }
|
|
||||||
|
|
||||||
static bool isInitialized() { return count_ > 0; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void doInitialize()
|
|
||||||
{
|
|
||||||
if (!count_)
|
|
||||||
{
|
|
||||||
XMLPlatformUtils::Initialize();
|
|
||||||
}
|
|
||||||
++count_;
|
|
||||||
}
|
|
||||||
void doTerminate()
|
|
||||||
{
|
|
||||||
--count_;
|
|
||||||
if (!count_)
|
|
||||||
{
|
|
||||||
XMLPlatformUtils::Terminate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int count_;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// String adaptor for XMLCh
|
// String adaptor for XMLCh
|
||||||
|
|
||||||
// * For the null-terminated version, we convert the array of XMLCh to a
|
// * For the null-terminated version, we convert the array of XMLCh to a
|
||||||
// null-terminated vector of wchar_t. We then pass &vector[0] to the
|
// null-terminated vector of wchar_t. We then pass &vector[0] to the
|
||||||
// parent method.
|
// parent method.
|
||||||
|
@ -199,7 +192,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
XMLCh* asXMLChString(const stringT& s) const
|
XMLCh* asXMLChString(const stringT& s) const
|
||||||
{
|
{
|
||||||
std::string str = base::asStdString(s);
|
std::string str = base::asStdString(s);
|
||||||
return ::XMLString::transcode(str.c_str());
|
return XERCES_CPP_NAMESPACE::XMLString::transcode(str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -210,7 +203,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocatorAdaptor() : locator_(0) { }
|
LocatorAdaptor() : locator_(0) { }
|
||||||
LocatorAdaptor(const ::Locator* const locator) : locator_(locator) { }
|
LocatorAdaptor(const XERCES_CPP_NAMESPACE::Locator* const locator) : locator_(locator) { }
|
||||||
~LocatorAdaptor() { }
|
~LocatorAdaptor() { }
|
||||||
|
|
||||||
stringT getPublicId() const
|
stringT getPublicId() const
|
||||||
|
@ -245,17 +238,17 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
return locator_->getColumnNumber();
|
return locator_->getColumnNumber();
|
||||||
} // getColumnNumber
|
} // getColumnNumber
|
||||||
|
|
||||||
void setLocator(const ::Locator* const locator)
|
void setLocator(const XERCES_CPP_NAMESPACE::Locator* const locator)
|
||||||
{
|
{
|
||||||
locator_ = locator;
|
locator_ = locator;
|
||||||
} // setLocator
|
} // setLocator
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ::Locator* locator_;
|
const XERCES_CPP_NAMESPACE::Locator* locator_;
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
}; // class LocatorAdaptor
|
}; // class LocatorAdaptor
|
||||||
|
|
||||||
class DTDHandlerAdaptor : public ::DTDHandler
|
class DTDHandlerAdaptor : public XERCES_CPP_NAMESPACE::DTDHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DTDHandlerAdaptor() : dtdHandler_(0) { }
|
DTDHandlerAdaptor() : dtdHandler_(0) { }
|
||||||
|
@ -295,7 +288,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
}; // class DTDHandlerAdaptor
|
}; // class DTDHandlerAdaptor
|
||||||
|
|
||||||
class ContentHandlerAdaptor : public ::ContentHandler
|
class ContentHandlerAdaptor : public XERCES_CPP_NAMESPACE::ContentHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContentHandlerAdaptor() : contentHandler_(0) { }
|
ContentHandlerAdaptor() : contentHandler_(0) { }
|
||||||
|
@ -304,7 +297,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
void setContentHandler(SAX::basic_ContentHandler<stringT>& handler) { contentHandler_ = &handler; }
|
void setContentHandler(SAX::basic_ContentHandler<stringT>& handler) { contentHandler_ = &handler; }
|
||||||
SAX::basic_ContentHandler<stringT>* getContentHandler() const { return contentHandler_; }
|
SAX::basic_ContentHandler<stringT>* getContentHandler() const { return contentHandler_; }
|
||||||
|
|
||||||
virtual void setDocumentLocator(const ::Locator* const locator)
|
virtual void setDocumentLocator(const XERCES_CPP_NAMESPACE::Locator* const locator)
|
||||||
{
|
{
|
||||||
locator_.setLocator(locator);
|
locator_.setLocator(locator);
|
||||||
if(contentHandler_)
|
if(contentHandler_)
|
||||||
|
@ -338,7 +331,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
virtual void startElement(const XMLCh* const namespaceUri,
|
virtual void startElement(const XMLCh* const namespaceUri,
|
||||||
const XMLCh* const localName,
|
const XMLCh* const localName,
|
||||||
const XMLCh* const rawName,
|
const XMLCh* const rawName,
|
||||||
const ::Attributes& attrs)
|
const XERCES_CPP_NAMESPACE::Attributes& attrs)
|
||||||
{
|
{
|
||||||
if(contentHandler_)
|
if(contentHandler_)
|
||||||
{
|
{
|
||||||
|
@ -398,7 +391,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
class AttributesAdaptor : public SAX::basic_Attributes<stringT>
|
class AttributesAdaptor : public SAX::basic_Attributes<stringT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AttributesAdaptor(const ::Attributes& attrs) : attributes_(attrs) { }
|
AttributesAdaptor(const XERCES_CPP_NAMESPACE::Attributes& attrs) : attributes_(attrs) { }
|
||||||
~AttributesAdaptor() { }
|
~AttributesAdaptor() { }
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
@ -432,47 +425,47 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
// name based query
|
// name based query
|
||||||
virtual int getIndex(const stringT& uri, const stringT& localName) const
|
virtual int getIndex(const stringT& uri, const stringT& localName) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
||||||
::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
||||||
return attributes_.getIndex(&wUri[0], &wLocalName[0]);
|
return attributes_.getIndex(&wUri[0], &wLocalName[0]);
|
||||||
} // getIndex
|
} // getIndex
|
||||||
virtual int getIndex(const stringT& qName) const
|
virtual int getIndex(const stringT& qName) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qName));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qName));
|
||||||
return attributes_.getIndex(&wQName[0]);
|
return attributes_.getIndex(&wQName[0]);
|
||||||
} // getIndex
|
} // getIndex
|
||||||
virtual stringT getType(const stringT& uri, const stringT& localName) const
|
virtual stringT getType(const stringT& uri, const stringT& localName) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
||||||
::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
||||||
return SA_.makeStringT(attributes_.getType(&wUri[0], &wLocalName[0]));
|
return SA_.makeStringT(attributes_.getType(&wUri[0], &wLocalName[0]));
|
||||||
} // getType
|
} // getType
|
||||||
virtual stringT getType(const stringT& qName) const
|
virtual stringT getType(const stringT& qName) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qName));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qName));
|
||||||
return SA_.makeStringT(attributes_.getType(&wQName[0]));
|
return SA_.makeStringT(attributes_.getType(&wQName[0]));
|
||||||
} // getType
|
} // getType
|
||||||
virtual stringT getValue(const stringT& uri, const stringT& localName) const
|
virtual stringT getValue(const stringT& uri, const stringT& localName) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wUri(SA_.asXMLChString(uri));
|
||||||
::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wLocalName(SA_.asXMLChString(localName));
|
||||||
return SA_.makeStringT(attributes_.getValue(&wUri[0], &wLocalName[0]));
|
return SA_.makeStringT(attributes_.getValue(&wUri[0], &wLocalName[0]));
|
||||||
} // getValue
|
} // getValue
|
||||||
virtual stringT getValue(const stringT& qname) const
|
virtual stringT getValue(const stringT& qname) const
|
||||||
{
|
{
|
||||||
::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qname));
|
XERCES_CPP_NAMESPACE::ArrayJanitor<XMLCh> wQName(SA_.asXMLChString(qname));
|
||||||
return SA_.makeStringT(attributes_.getValue(&wQName[0]));
|
return SA_.makeStringT(attributes_.getValue(&wQName[0]));
|
||||||
} // getValue
|
} // getValue
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ::Attributes& attributes_;
|
const XERCES_CPP_NAMESPACE::Attributes& attributes_;
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
|
|
||||||
AttributesAdaptor();
|
AttributesAdaptor();
|
||||||
}; // class AttributesAdaptor
|
}; // class AttributesAdaptor
|
||||||
}; // class ContentHandlerAdaptor
|
}; // class ContentHandlerAdaptor
|
||||||
|
|
||||||
class ErrorHandlerAdaptor : public ::ErrorHandler
|
class ErrorHandlerAdaptor : public XERCES_CPP_NAMESPACE::ErrorHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorHandlerAdaptor() : errorHandler_(0) { }
|
ErrorHandlerAdaptor() : errorHandler_(0) { }
|
||||||
|
@ -481,17 +474,17 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
void setErrorHandler(SAX::ErrorHandler& handler) { errorHandler_ = &handler; }
|
void setErrorHandler(SAX::ErrorHandler& handler) { errorHandler_ = &handler; }
|
||||||
SAX::ErrorHandler* getErrorHandler() const { return errorHandler_; }
|
SAX::ErrorHandler* getErrorHandler() const { return errorHandler_; }
|
||||||
|
|
||||||
virtual void warning(const ::SAXParseException& exception)
|
virtual void warning(const XERCES_CPP_NAMESPACE::SAXParseException& exception)
|
||||||
{
|
{
|
||||||
handleError(exception, &SAX::ErrorHandler::warning);
|
handleError(exception, &SAX::ErrorHandler::warning);
|
||||||
} // warning
|
} // warning
|
||||||
|
|
||||||
virtual void error(const ::SAXParseException& exception)
|
virtual void error(const XERCES_CPP_NAMESPACE::SAXParseException& exception)
|
||||||
{
|
{
|
||||||
handleError(exception, &SAX::ErrorHandler::error);
|
handleError(exception, &SAX::ErrorHandler::error);
|
||||||
} // error
|
} // error
|
||||||
|
|
||||||
virtual void fatalError(const ::SAXParseException& exception)
|
virtual void fatalError(const XERCES_CPP_NAMESPACE::SAXParseException& exception)
|
||||||
{
|
{
|
||||||
handleError(exception, &SAX::ErrorHandler::fatalError);
|
handleError(exception, &SAX::ErrorHandler::fatalError);
|
||||||
} // fatalError
|
} // fatalError
|
||||||
|
@ -504,7 +497,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
private:
|
private:
|
||||||
typedef void(SAX::ErrorHandler::* ErrorFn)(const SAX::SAXParseException&);
|
typedef void(SAX::ErrorHandler::* ErrorFn)(const SAX::SAXParseException&);
|
||||||
|
|
||||||
void handleError(const ::SAXParseException& exception, ErrorFn fn)
|
void handleError(const XERCES_CPP_NAMESPACE::SAXParseException& exception, ErrorFn fn)
|
||||||
{
|
{
|
||||||
if(!errorHandler_)
|
if(!errorHandler_)
|
||||||
return;
|
return;
|
||||||
|
@ -522,7 +515,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
}; // class ErrorHandlerAdaptor
|
}; // class ErrorHandlerAdaptor
|
||||||
|
|
||||||
class LexicalHandlerAdaptor : public ::LexicalHandler
|
class LexicalHandlerAdaptor : public XERCES_CPP_NAMESPACE::LexicalHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LexicalHandlerAdaptor() : lexicalHandler_(0) { }
|
LexicalHandlerAdaptor() : lexicalHandler_(0) { }
|
||||||
|
@ -582,7 +575,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
}; // class LexicalHandlerAdaptor
|
}; // class LexicalHandlerAdaptor
|
||||||
|
|
||||||
class DeclHandlerAdaptor : public ::DeclHandler
|
class DeclHandlerAdaptor : public XERCES_CPP_NAMESPACE::DeclHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeclHandlerAdaptor() : declHandler_(0) { }
|
DeclHandlerAdaptor() : declHandler_(0) { }
|
||||||
|
@ -636,7 +629,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
xerces_string_adaptor SA_;
|
xerces_string_adaptor SA_;
|
||||||
}; // class DeclHandlerAdaptor
|
}; // class DeclHandlerAdaptor
|
||||||
|
|
||||||
class IStreamAdaptor : public ::BinInputStream
|
class IStreamAdaptor : public XERCES_CPP_NAMESPACE::BinInputStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IStreamAdaptor(std::istream* istream) : istream_(istream), curPos_(0) { }
|
IStreamAdaptor(std::istream* istream) : istream_(istream), curPos_(0) { }
|
||||||
|
@ -659,7 +652,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
unsigned int curPos_;
|
unsigned int curPos_;
|
||||||
}; // IStreamAdaptor
|
}; // IStreamAdaptor
|
||||||
|
|
||||||
class InputSourceAdaptor : public ::InputSource
|
class InputSourceAdaptor : public XERCES_CPP_NAMESPACE::InputSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputSourceAdaptor(SAX::basic_InputSource<stringT>& source) : inputSource_(source)
|
InputSourceAdaptor(SAX::basic_InputSource<stringT>& source) : inputSource_(source)
|
||||||
|
@ -669,7 +662,7 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
} // InputSourceAdaptor
|
} // InputSourceAdaptor
|
||||||
virtual ~InputSourceAdaptor() { }
|
virtual ~InputSourceAdaptor() { }
|
||||||
|
|
||||||
virtual BinInputStream* makeStream() const
|
virtual XERCES_CPP_NAMESPACE::BinInputStream* makeStream() const
|
||||||
{
|
{
|
||||||
return new IStreamAdaptor(inputSource_.getByteStream());
|
return new IStreamAdaptor(inputSource_.getByteStream());
|
||||||
} // makeStream
|
} // makeStream
|
||||||
|
@ -682,8 +675,8 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// Member variables
|
// Member variables
|
||||||
std::auto_ptr<xerces_initializer> initializer_;
|
std::auto_ptr<xerces_implemenation_helper::xerces_initializer> initializer_;
|
||||||
::SAX2XMLReader* xerces_;
|
XERCES_CPP_NAMESPACE::SAX2XMLReader* xerces_;
|
||||||
ContentHandlerAdaptor contentHandlerAdaptor_;
|
ContentHandlerAdaptor contentHandlerAdaptor_;
|
||||||
DTDHandlerAdaptor dtdHandlerAdaptor_;
|
DTDHandlerAdaptor dtdHandlerAdaptor_;
|
||||||
ErrorHandlerAdaptor errorHandlerAdaptor_;
|
ErrorHandlerAdaptor errorHandlerAdaptor_;
|
||||||
|
@ -698,16 +691,16 @@ xerces_wrapper<stringT, string_adaptorT>::xerces_wrapper()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::auto_ptr<xerces_initializer> init(new xerces_initializer);
|
std::auto_ptr<xerces_implemenation_helper::xerces_initializer> init(new xerces_implemenation_helper::xerces_initializer);
|
||||||
initializer_ = init;
|
initializer_ = init;
|
||||||
}
|
}
|
||||||
catch(const XMLException& toCatch)
|
catch(const XERCES_CPP_NAMESPACE::XMLException& toCatch)
|
||||||
{
|
{
|
||||||
stringT s = SA_.makeStringT(toCatch.getMessage());
|
stringT s = SA_.makeStringT(toCatch.getMessage());
|
||||||
throw SAX::SAXException(SA_.asStdString(s));
|
throw SAX::SAXException(SA_.asStdString(s));
|
||||||
} // catch
|
} // catch
|
||||||
|
|
||||||
xerces_ = XMLReaderFactory::createXMLReader();
|
xerces_ = XERCES_CPP_NAMESPACE::XMLReaderFactory::createXMLReader();
|
||||||
|
|
||||||
xerces_->setContentHandler(&contentHandlerAdaptor_);
|
xerces_->setContentHandler(&contentHandlerAdaptor_);
|
||||||
xerces_->setDTDHandler(&dtdHandlerAdaptor_);
|
xerces_->setDTDHandler(&dtdHandlerAdaptor_);
|
||||||
|
@ -729,11 +722,11 @@ bool xerces_wrapper<stringT, string_adaptorT>::getFeature(const stringT& name) c
|
||||||
{
|
{
|
||||||
return xerces_->getFeature(SA_.asXMLChString(name));
|
return xerces_->getFeature(SA_.asXMLChString(name));
|
||||||
} // try
|
} // try
|
||||||
catch(::SAXNotSupportedException& e)
|
catch(XERCES_CPP_NAMESPACE::SAXNotSupportedException& e)
|
||||||
{
|
{
|
||||||
throw SAX::SAXNotSupportedException(SA_.makeStringT(e.getMessage()));
|
throw SAX::SAXNotSupportedException(SA_.makeStringT(e.getMessage()));
|
||||||
} // catch(SAXNotSupportedException& e)
|
} // catch(SAXNotSupportedException& e)
|
||||||
catch(::SAXNotRecognizedException& e)
|
catch(XERCES_CPP_NAMESPACE::SAXNotRecognizedException& e)
|
||||||
{
|
{
|
||||||
throw SAX::SAXNotRecognizedException(SA_.makeStringT(e.getMessage()));
|
throw SAX::SAXNotRecognizedException(SA_.makeStringT(e.getMessage()));
|
||||||
} // catch(SAXNotRecognizedException& e)
|
} // catch(SAXNotRecognizedException& e)
|
||||||
|
@ -746,11 +739,11 @@ void xerces_wrapper<stringT, string_adaptorT>::setFeature(const stringT& name, b
|
||||||
{
|
{
|
||||||
xerces_->setFeature(SA_.asXMLChString(name), value);
|
xerces_->setFeature(SA_.asXMLChString(name), value);
|
||||||
} // try
|
} // try
|
||||||
catch(::SAXNotSupportedException& e)
|
catch(XERCES_CPP_NAMESPACE::SAXNotSupportedException& e)
|
||||||
{
|
{
|
||||||
throw SAX::SAXNotSupportedException(SA_.makeStringT(e.getMessage()));
|
throw SAX::SAXNotSupportedException(SA_.makeStringT(e.getMessage()));
|
||||||
} // catch(SAXNotSupportedException& e)
|
} // catch(SAXNotSupportedException& e)
|
||||||
catch(::SAXNotRecognizedException& e)
|
catch(XERCES_CPP_NAMESPACE::SAXNotRecognizedException& e)
|
||||||
{
|
{
|
||||||
throw SAX::SAXNotRecognizedException(SA_.makeStringT(e.getMessage()));
|
throw SAX::SAXNotRecognizedException(SA_.makeStringT(e.getMessage()));
|
||||||
} // catch(SAXNotRecognizedException& e)
|
} // catch(SAXNotRecognizedException& e)
|
||||||
|
@ -823,9 +816,6 @@ void xerces_wrapper<stringT, string_adaptorT>::parse(SAX::basic_InputSource<stri
|
||||||
} // if ...
|
} // if ...
|
||||||
} // parse
|
} // parse
|
||||||
|
|
||||||
template<class stringT, class string_adaptorT>
|
|
||||||
int xerces_wrapper<stringT, string_adaptorT>::xerces_initializer::count_ = 0;
|
|
||||||
|
|
||||||
} // namespace SAX
|
} // namespace SAX
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue