From f2ec36ab5fa04e11dee655d9c623baac95db1eba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 13 Nov 2013 07:46:45 +0200 Subject: Drop support for Xerces-C++ 2-series --- .../xsd/cxx/xml/dom/bits/error-handler-proxy.txx | 12 -- libxsd/xsd/cxx/xml/dom/parsing-source.txx | 139 +-------------------- libxsd/xsd/cxx/xml/dom/serialization-header.txx | 6 +- libxsd/xsd/cxx/xml/dom/serialization-source.hxx | 4 - libxsd/xsd/cxx/xml/dom/serialization-source.txx | 42 +------ libxsd/xsd/cxx/xml/elements.hxx | 5 + .../xsd/cxx/xml/sax/bits/error-handler-proxy.txx | 11 -- libxsd/xsd/cxx/xml/sax/std-input-source.hxx | 29 +---- libxsd/xsd/cxx/xml/std-memory-manager.hxx | 6 - 9 files changed, 18 insertions(+), 236 deletions(-) (limited to 'libxsd/xsd/cxx/xml') diff --git a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx index 109c0e7..d5dff65 100644 --- a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx +++ b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx @@ -53,24 +53,12 @@ namespace xsd xercesc::DOMLocator* loc (e.getLocation ()); -#if _XERCES_VERSION >= 30000 return eh_->handle ( transcode (loc->getURI ()), static_cast (loc->getLineNumber ()), static_cast (loc->getColumnNumber ()), s, transcode (e.getMessage ())); -#else - XMLSSize_t l (loc->getLineNumber ()); - XMLSSize_t c (loc->getColumnNumber ()); - - return eh_->handle ( - transcode (loc->getURI ()), - (l == -1 ? 0 : static_cast (l)), - (c == -1 ? 0 : static_cast (c)), - s, - transcode (e.getMessage ())); -#endif } } } diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx index 545eb82..cde2179 100644 --- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx +++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx @@ -3,12 +3,9 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#if _XERCES_VERSION >= 30000 -# include -# include -#else -# include -#endif +#include +#include + #include #include #include @@ -94,12 +91,8 @@ namespace xsd using xercesc::DOMImplementationLS; using xercesc::DOMImplementation; using xercesc::DOMDocument; -#if _XERCES_VERSION >= 30000 using xercesc::DOMLSParser; using xercesc::DOMConfiguration; -#else - using xercesc::DOMBuilder; -#endif using xercesc::Wrapper4InputSource; using xercesc::XMLUni; @@ -116,7 +109,6 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 auto_ptr parser ( impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); @@ -163,7 +155,6 @@ namespace xsd if (!(flags & no_muliple_imports)) conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); #endif - // This feature checks the schema grammar for additional // errors. We most likely do not need it when validating // instances (assuming the schema is valid). @@ -214,64 +205,9 @@ namespace xsd bits::error_handler_proxy ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr parser ( - impl->createDOMBuilder (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - parser->setFeature (XMLUni::fgDOMComments, false); - parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true); - parser->setFeature (XMLUni::fgDOMEntities, false); - parser->setFeature (XMLUni::fgDOMNamespaces, true); - parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false); - - if (flags & dont_validate) - { - parser->setFeature (XMLUni::fgDOMValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - else - { - parser->setFeature (XMLUni::fgDOMValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - - parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - if (!prop.schema_location ().empty ()) - { - xml::string sl (prop.schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalSchemaLocation, - const_cast (v)); - } - - if (!prop.no_namespace_schema_location ().empty ()) - { - xml::string sl (prop.no_namespace_schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, - const_cast (v)); - } - - bits::error_handler_proxy ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - xercesc::Wrapper4InputSource wrap (&is, false); -#if _XERCES_VERSION >= 30000 auto_ptr doc; - try { doc.reset (parser->parse (&wrap)); @@ -279,9 +215,7 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr doc (parser->parse (wrap)); -#endif + if (ehp.failed ()) doc.reset (); @@ -312,12 +246,8 @@ namespace xsd using xercesc::DOMImplementationLS; using xercesc::DOMImplementation; using xercesc::DOMDocument; -#if _XERCES_VERSION >= 30000 using xercesc::DOMLSParser; using xercesc::DOMConfiguration; -#else - using xercesc::DOMBuilder; -#endif using xercesc::XMLUni; @@ -332,7 +262,6 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 auto_ptr parser ( impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); @@ -430,63 +359,7 @@ namespace xsd bits::error_handler_proxy ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr parser ( - impl->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - parser->setFeature (XMLUni::fgDOMComments, false); - parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true); - parser->setFeature (XMLUni::fgDOMEntities, false); - parser->setFeature (XMLUni::fgDOMNamespaces, true); - parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false); - - if (flags & dont_validate) - { - parser->setFeature (XMLUni::fgDOMValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - else - { - parser->setFeature (XMLUni::fgDOMValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - - parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - if (!prop.schema_location ().empty ()) - { - xml::string sl (prop.schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalSchemaLocation, - const_cast (v)); - } - - if (!prop.no_namespace_schema_location ().empty ()) - { - xml::string sl (prop.no_namespace_schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, - const_cast (v)); - } - - bits::error_handler_proxy ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - - -#if _XERCES_VERSION >= 30000 auto_ptr doc; - try { doc.reset (parser->parseURI (string (uri).c_str ())); @@ -494,10 +367,6 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr doc ( - parser->parseURI (string (uri).c_str ())); -#endif if (ehp.failed ()) doc.reset (); diff --git a/libxsd/xsd/cxx/xml/dom/serialization-header.txx b/libxsd/xsd/cxx/xml/dom/serialization-header.txx index 567581a..cce3c52 100644 --- a/libxsd/xsd/cxx/xml/dom/serialization-header.txx +++ b/libxsd/xsd/cxx/xml/dom/serialization-header.txx @@ -33,12 +33,8 @@ namespace xsd prefix (const C* ns, xercesc::DOMElement& e, const C* hint) { string xns (ns); - -#if _XERCES_VERSION >= 30000 const XMLCh* p (e.lookupPrefix (xns.c_str ())); -#else - const XMLCh* p (e.lookupNamespacePrefix (xns.c_str (), false)); -#endif + if (p != 0) return transcode (p); diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx index ce81f2a..9bfd27b 100644 --- a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx +++ b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx @@ -108,11 +108,7 @@ namespace xsd // virtual void writeChars (const XMLByte* const buf, -#if _XERCES_VERSION >= 30000 const XMLSize_t size, -#else - const unsigned int size, -#endif xercesc::XMLFormatter* const) { // Ignore the write request if there was a stream failure and the diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/libxsd/xsd/cxx/xml/dom/serialization-source.txx index 2caf361..da0dbb7 100644 --- a/libxsd/xsd/cxx/xml/dom/serialization-source.txx +++ b/libxsd/xsd/cxx/xml/dom/serialization-source.txx @@ -7,12 +7,9 @@ #include // chLatin_L, etc #include -#if _XERCES_VERSION >= 30000 -# include -# include -#else -# include -#endif +#include +#include + #include #include #include @@ -298,13 +295,9 @@ namespace xsd // using xercesc::DOMImplementationRegistry; using xercesc::DOMImplementation; -#if _XERCES_VERSION >= 30000 using xercesc::DOMLSSerializer; using xercesc::DOMConfiguration; using xercesc::DOMLSOutput; -#else - using xercesc::DOMWriter; -#endif using xercesc::XMLUni; const XMLCh ls[] = {xercesc::chLatin_L, @@ -316,7 +309,6 @@ namespace xsd bits::error_handler_proxy ehp (eh); -#if _XERCES_VERSION >= 30000 xml::dom::auto_ptr writer ( impl->createLSSerializer ()); @@ -345,33 +337,7 @@ namespace xsd out->setEncoding (xml::string (encoding).c_str ()); out->setByteStream (&target); - bool r (writer->write (&doc, out.get ())); -#else - xml::dom::auto_ptr writer (impl->createDOMWriter ()); - - writer->setErrorHandler (&ehp); - writer->setEncoding (xml::string (encoding).c_str ()); - - // Set some nice features if the serializer supports them. - // - if (writer->canSetFeature ( - XMLUni::fgDOMWRTDiscardDefaultContent, true)) - writer->setFeature (XMLUni::fgDOMWRTDiscardDefaultContent, true); - - if (!(flags & dont_pretty_print) && - writer->canSetFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true)) - writer->setFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true); - - // See if we need to write XML declaration. - // - if ((flags & no_xml_declaration) && - writer->canSetFeature (XMLUni::fgDOMXMLDeclaration, false)) - writer->setFeature (XMLUni::fgDOMXMLDeclaration, false); - - bool r (writer->writeNode (&target, doc)); -#endif - - if (!r || ehp.failed ()) + if (!writer->write (&doc, out.get ()) || ehp.failed ()) return false; return true; diff --git a/libxsd/xsd/cxx/xml/elements.hxx b/libxsd/xsd/cxx/xml/elements.hxx index 990a2aa..4c6e887 100644 --- a/libxsd/xsd/cxx/xml/elements.hxx +++ b/libxsd/xsd/cxx/xml/elements.hxx @@ -8,8 +8,13 @@ #include +#include #include +#if _XERCES_VERSION < 30000 +# error Xerces-C++ 2-series is not supported +#endif + namespace xsd { namespace cxx diff --git a/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx b/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx index 8487e74..31b1a34 100644 --- a/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx +++ b/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx @@ -65,22 +65,11 @@ namespace xsd if (id == 0) id = e.getSystemId (); -#if _XERCES_VERSION >= 30000 eh_->handle (transcode (id), static_cast (e.getLineNumber ()), static_cast (e.getColumnNumber ()), s, transcode (e.getMessage ())); -#else - XMLSSize_t l (e.getLineNumber ()); - XMLSSize_t c (e.getColumnNumber ()); - - eh_->handle (transcode (id), - (l == -1 ? 0 : static_cast (l)), - (c == -1 ? 0 : static_cast (c)), - s, - transcode (e.getMessage ())); -#endif } } } diff --git a/libxsd/xsd/cxx/xml/sax/std-input-source.hxx b/libxsd/xsd/cxx/xml/sax/std-input-source.hxx index 6b0af98..6f3ee38 100644 --- a/libxsd/xsd/cxx/xml/sax/std-input-source.hxx +++ b/libxsd/xsd/cxx/xml/sax/std-input-source.hxx @@ -29,27 +29,14 @@ namespace xsd { } -#if _XERCES_VERSION >= 30000 virtual XMLFilePos curPos () const { return static_cast (is_.tellg ()); } -#else - virtual unsigned int - curPos () const - { - return static_cast (is_.tellg ()); - } -#endif -#if _XERCES_VERSION >= 30000 virtual XMLSize_t readBytes (XMLByte* const buf, const XMLSize_t size) -#else - virtual unsigned int - readBytes (XMLByte* const buf, const unsigned int size) -#endif { // Some implementations don't clear gcount if you // call read() on a stream that is in the eof state. @@ -78,25 +65,17 @@ namespace xsd // Make sure that if we failed, readBytes won't be called // again. // - if (!is_.fail ()) - { -#if _XERCES_VERSION >= 30000 - return static_cast (is_.gcount ()); -#else - return static_cast (is_.gcount ()); -#endif - } - else - return 0; + return !is_.fail () + ? static_cast (is_.gcount ()) + : 0; } -#if _XERCES_VERSION >= 30000 virtual const XMLCh* getContentType () const { return 0; } -#endif + private: std::istream& is_; }; diff --git a/libxsd/xsd/cxx/xml/std-memory-manager.hxx b/libxsd/xsd/cxx/xml/std-memory-manager.hxx index 7598e22..bd8fbab 100644 --- a/libxsd/xsd/cxx/xml/std-memory-manager.hxx +++ b/libxsd/xsd/cxx/xml/std-memory-manager.hxx @@ -19,11 +19,7 @@ namespace xsd { public: virtual void* -#if _XERCES_VERSION >= 30000 allocate(XMLSize_t size) -#else - allocate(size_t size) -#endif { return operator new (size); } @@ -35,13 +31,11 @@ namespace xsd operator delete (p); } -#if _XERCES_VERSION >= 30000 virtual xercesc::MemoryManager* getExceptionMemoryManager() { return xercesc::XMLPlatformUtils::fgMemoryManager; } -#endif }; } } -- cgit v1.1