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 --- libxsd/xsd/cxx/parser/xerces/elements.hxx | 11 +- libxsd/xsd/cxx/parser/xerces/elements.txx | 32 +---- libxsd/xsd/cxx/tree/elements.hxx | 6 + libxsd/xsd/cxx/tree/types.txx | 65 +--------- .../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 - 13 files changed, 33 insertions(+), 335 deletions(-) (limited to 'libxsd/xsd/cxx') diff --git a/libxsd/xsd/cxx/parser/xerces/elements.hxx b/libxsd/xsd/cxx/parser/xerces/elements.hxx index aa21a0b..5fe3688 100644 --- a/libxsd/xsd/cxx/parser/xerces/elements.hxx +++ b/libxsd/xsd/cxx/parser/xerces/elements.hxx @@ -16,6 +16,8 @@ #include #include +#include + #include #include @@ -23,6 +25,10 @@ #include #include +#if _XERCES_VERSION < 30000 +# error Xerces-C++ 2-series is not supported +#endif + namespace xsd { namespace cxx @@ -403,13 +409,8 @@ namespace xsd const XMLCh* const lname, const XMLCh* const qname); -#if _XERCES_VERSION >= 30000 virtual void characters (const XMLCh* const s, const XMLSize_t length); -#else - virtual void - characters (const XMLCh* const s, const unsigned int length); -#endif virtual void startPrefixMapping (const XMLCh* const prefix, diff --git a/libxsd/xsd/cxx/parser/xerces/elements.txx b/libxsd/xsd/cxx/parser/xerces/elements.txx index 6ea728c..bc7f1e5 100644 --- a/libxsd/xsd/cxx/parser/xerces/elements.txx +++ b/libxsd/xsd/cxx/parser/xerces/elements.txx @@ -528,14 +528,8 @@ namespace xsd xml::string (e.message ()).c_str (), id.c_str (), id.c_str (), -#if _XERCES_VERSION >= 30000 static_cast (e.line ()), - static_cast (e.column ()) -#else - static_cast (e.line ()), - static_cast (e.column ()) -#endif - ); + static_cast (e.column ())); eh.fatalError (se); } @@ -566,14 +560,8 @@ namespace xsd xml::string (e.message ()).c_str (), id.c_str (), id.c_str (), -#if _XERCES_VERSION >= 30000 static_cast (e.line ()), - static_cast (e.column ()) -#else - static_cast (e.line ()), - static_cast (e.column ()) -#endif - ); + static_cast (e.column ())); eh.fatalError (se); } @@ -796,11 +784,7 @@ namespace xsd } } -#if _XERCES_VERSION >= 30000 for (XMLSize_t i (0), end (attributes.getLength()); i < end; ++i) -#else - for (unsigned int i (0), end (attributes.getLength()); i < end; ++i) -#endif { const XMLCh* xns (attributes.getURI (i)); @@ -882,11 +866,7 @@ namespace xsd template void event_router:: -#if _XERCES_VERSION >= 30000 characters (const XMLCh* const s, const XMLSize_t n) -#else - characters (const XMLCh* const s, const unsigned int n) -#endif { typedef std::basic_string string; @@ -963,16 +943,8 @@ namespace xsd if (id != 0) e.id (xml::transcode (id)); -#if _XERCES_VERSION >= 30000 e.line (static_cast (loc_->getLineNumber ())); e.column (static_cast (loc_->getColumnNumber ())); -#else - XMLSSize_t l (loc_->getLineNumber ()); - XMLSSize_t c (loc_->getColumnNumber ()); - - e.line (l == -1 ? 0 : static_cast (l)); - e.column (c == -1 ? 0: static_cast (c)); -#endif } } } diff --git a/libxsd/xsd/cxx/tree/elements.hxx b/libxsd/xsd/cxx/tree/elements.hxx index 40c3e01..040284f 100644 --- a/libxsd/xsd/cxx/tree/elements.hxx +++ b/libxsd/xsd/cxx/tree/elements.hxx @@ -30,6 +30,8 @@ #include #include +#include + #include // xml::properties #include // dom::auto_ptr @@ -37,6 +39,10 @@ #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/tree/types.txx b/libxsd/xsd/cxx/tree/types.txx index 1a59ed3..be893af 100644 --- a/libxsd/xsd/cxx/tree/types.txx +++ b/libxsd/xsd/cxx/tree/types.txx @@ -5,7 +5,6 @@ #include #include -#include #include @@ -335,7 +334,6 @@ namespace xsd using xercesc::Base64; std::basic_string str; -#if _XERCES_VERSION >= 30000 XMLSize_t n; xml::std_memory_manager mm; @@ -359,31 +357,6 @@ namespace xsd { //@@ throw } -#else - unsigned int n; - - xml::std_memory_manager mm; - auto_array r ( - Base64::encode ( - reinterpret_cast (this->data ()), - static_cast (this->size ()), - &n, - &mm), - mm); - - if (r) - { - str.reserve (n + 1); - str.resize (n); - - for (unsigned int i (0); i < n; ++i) - str[i] = C (r[i]); - } - else - { - //@@ throw - } -#endif return str; } @@ -397,23 +370,11 @@ namespace xsd using xercesc::Base64; xml::std_memory_manager mm; - - // Xerces 2.6.0 and earlier do not have decodeToXMLByte which - // makes my life harder and your code slower. - // -#if _XERCES_VERSION >= 20700 - -#if _XERCES_VERSION >= 30000 XMLSize_t size; + auto_array data ( Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045), mm); -#else - unsigned int size; - auto_array data ( - Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045), - mm); -#endif // _XERCES_VERSION >= 30000 if (data) { @@ -425,30 +386,6 @@ namespace xsd { //@@ throw } -#else - unsigned int size; - -#if _XERCES_VERSION >= 20600 // Xerces 2.5.0 does not have Conf_RFC2045. - auto_array data ( - Base64::decode (src, &size, &mm, Base64::Conf_RFC2045), - mm); -#else - auto_array data ( - Base64::decode (src, &size, &mm), mm); -#endif // _XERCES_VERSION >= 20600 - - if (data) - { - buffer tmp (size); - for (unsigned int i (0); i < size; ++i) - tmp.data ()[i] = static_cast (data[i]); - this->swap (tmp); // g++ 4.1 likes it qualified, not sure why. - } - else - { - //@@ throw - } -#endif //_XERCES_VERSION >= 20700 } 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