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/libxsd/xsd/cxx/xml | |
parent | eaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff) |
New upstream release
Diffstat (limited to 'xsd/libxsd/xsd/cxx/xml')
34 files changed, 384 insertions, 467 deletions
diff --git a/xsd/libxsd/xsd/cxx/xml/bits/literals.hxx b/xsd/libxsd/xsd/cxx/xml/bits/literals.hxx index 5b9fe99..51d08ad 100644 --- a/xsd/libxsd/xsd/cxx/xml/bits/literals.hxx +++ b/xsd/libxsd/xsd/cxx/xml/bits/literals.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/bits/literals.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_BITS_LITERALS_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/bits/literals.ixx b/xsd/libxsd/xsd/cxx/xml/bits/literals.ixx index f0ec6eb..bd8f4ed 100644 --- a/xsd/libxsd/xsd/cxx/xml/bits/literals.ixx +++ b/xsd/libxsd/xsd/cxx/xml/bits/literals.ixx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/bits/literals.ixx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_BITS_LITERALS_IXX diff --git a/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.hxx b/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.hxx index c8ab507..309e8ef 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.hxx +++ b/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/char-iso8859-1.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_TRANSCODER diff --git a/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.txx b/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.txx index cbf7cd8..acef18c 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.txx +++ b/xsd/libxsd/xsd/cxx/xml/char-iso8859-1.txx @@ -1,9 +1,14 @@ // file : xsd/cxx/xml/char-iso8859-1.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <xsd/cxx/auto-array.hxx> +#include <xsd/cxx/config.hxx> // XSD_CXX11 + +#ifdef XSD_CXX11 +# include <memory> // std::unique_ptr +#else +# include <xsd/cxx/auto-array.hxx> +#endif namespace xsd { @@ -87,7 +92,12 @@ namespace xsd { const C* end (s + len); - auto_array<XMLCh> r (new XMLCh[len + 1]); +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> r ( +#else + auto_array<XMLCh> r ( +#endif + new XMLCh[len + 1]); XMLCh* ir (r.get ()); for (const C* p (s); p < end; ++p) diff --git a/xsd/libxsd/xsd/cxx/xml/char-lcp.hxx b/xsd/libxsd/xsd/cxx/xml/char-lcp.hxx index c100bab..ce46229 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-lcp.hxx +++ b/xsd/libxsd/xsd/cxx/xml/char-lcp.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/char-lcp.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_TRANSCODER diff --git a/xsd/libxsd/xsd/cxx/xml/char-lcp.txx b/xsd/libxsd/xsd/cxx/xml/char-lcp.txx index 4603537..c71d92f 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-lcp.txx +++ b/xsd/libxsd/xsd/cxx/xml/char-lcp.txx @@ -1,13 +1,19 @@ // file : xsd/cxx/xml/char-lcp.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <cstring> // std::memcpy #include <xercesc/util/XMLString.hpp> -#include <xsd/cxx/auto-array.hxx> +#include <xsd/cxx/config.hxx> // XSD_CXX11 + +#ifdef XSD_CXX11 +# include <memory> // std::unique_ptr +#else +# include <xsd/cxx/auto-array.hxx> +#endif + #include <xsd/cxx/xml/std-memory-manager.hxx> namespace xsd @@ -21,7 +27,11 @@ namespace xsd to (const XMLCh* s) { std_memory_manager mm; +#ifdef XSD_CXX11 + std::unique_ptr<C[], std_memory_manager&> r ( +#else auto_array<C, std_memory_manager> r ( +#endif xercesc::XMLString::transcode (s, &mm), mm); return std::basic_string<C> (r.get ()); } @@ -30,12 +40,21 @@ namespace xsd std::basic_string<C> char_lcp_transcoder<C>:: to (const XMLCh* s, std::size_t len) { - auto_array<XMLCh> tmp (new XMLCh[len + 1]); +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> tmp ( +#else + auto_array<XMLCh> tmp ( +#endif + new XMLCh[len + 1]); std::memcpy (tmp.get (), s, len * sizeof (XMLCh)); tmp[len] = XMLCh (0); std_memory_manager mm; +#ifdef XSD_CXX11 + std::unique_ptr<C[], std_memory_manager&> r ( +#else auto_array<C, std_memory_manager> r ( +#endif xercesc::XMLString::transcode (tmp.get (), &mm), mm); tmp.reset (); diff --git a/xsd/libxsd/xsd/cxx/xml/char-utf8.hxx b/xsd/libxsd/xsd/cxx/xml/char-utf8.hxx index 719881b..afc923a 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-utf8.hxx +++ b/xsd/libxsd/xsd/cxx/xml/char-utf8.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/char-utf8.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_TRANSCODER diff --git a/xsd/libxsd/xsd/cxx/xml/char-utf8.txx b/xsd/libxsd/xsd/cxx/xml/char-utf8.txx index 9935daf..a6511be 100644 --- a/xsd/libxsd/xsd/cxx/xml/char-utf8.txx +++ b/xsd/libxsd/xsd/cxx/xml/char-utf8.txx @@ -1,9 +1,14 @@ // file : xsd/cxx/xml/char-utf8.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include <xsd/cxx/auto-array.hxx> +#include <xsd/cxx/config.hxx> // XSD_CXX11 + +#ifdef XSD_CXX11 +# include <memory> // std::unique_ptr +#else +# include <xsd/cxx/auto-array.hxx> +#endif namespace xsd { @@ -184,7 +189,12 @@ namespace xsd if (!valid) throw invalid_utf8_string (); - auto_array<XMLCh> r (new XMLCh[rl + 1]); +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> r ( +#else + auto_array<XMLCh> r ( +#endif + new XMLCh[rl + 1]); XMLCh* ir (r.get ()); unsigned int u (0); // Four byte UCS-4 char. diff --git a/xsd/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx b/xsd/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx index f22e652..fc8f194 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx @@ -1,11 +1,18 @@ // file : xsd/cxx/xml/dom/auto-ptr.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_AUTO_PTR_HXX #define XSD_CXX_XML_DOM_AUTO_PTR_HXX +#include <xsd/cxx/config.hxx> // XSD_CXX11_* + +#ifdef XSD_CXX11 +# include <memory> // std::unique_ptr +# include <utility> // std::move +# include <type_traits> // std::remove_const +#endif + namespace xsd { namespace cxx @@ -14,9 +21,73 @@ namespace xsd { namespace dom { - // Simple auto_ptr version that calls release() instead of delete. - // +#ifdef XSD_CXX11 + template <typename T> + struct deleter + { + void + operator() (T* p) const + { + if (p != 0) + const_cast<typename std::remove_const<T>::type*> (p)->release (); + } + }; + +#ifdef XSD_CXX11_TEMPLATE_ALIAS + template <typename T> + using unique_ptr = std::unique_ptr<T, deleter<T>>; +#else + template <typename T> + class unique_ptr: public std::unique_ptr<T, deleter<T>> + { + public: + typedef std::unique_ptr<T, deleter<T>> base; + + typedef typename base::pointer pointer; + typedef T element_type; + typedef deleter<T> deleter_type; + + unique_ptr (): base () {} + explicit unique_ptr (pointer p): base (p) {} + unique_ptr (pointer p, const deleter_type& d): base (p, d) {} + unique_ptr (pointer p, deleter_type&& d): base (p, std::move (d)) {} + unique_ptr (unique_ptr&& p): base (std::move (p)) {} + template <class T1> + unique_ptr (unique_ptr<T1>&& p): base (std::move (p)) {} + template <class T1> + unique_ptr (std::auto_ptr<T1>&& p): base (std::move (p)) {} + + unique_ptr& operator= (unique_ptr&& p) + { + static_cast<base&> (*this) = std::move (p); + return *this; + } + template <class T1> + unique_ptr& operator= (unique_ptr<T1>&& p) + { + static_cast<base&> (*this) = std::move (p); + return *this; + } + +#ifdef XSD_CXX11_NULLPTR + unique_ptr (std::nullptr_t p): base (p) {} + + unique_ptr& operator= (std::nullptr_t p) + { + static_cast<base&> (*this) = p; + return *this; + } +#endif + }; +#endif // XSD_CXX11_TEMPLATE_ALIAS + +#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::unique_ptr + +#else + // Simple auto_ptr version for C++98 that calls release() instead + // of delete. + // template <typename T> struct remove_c { @@ -150,6 +221,10 @@ namespace xsd private: T* x_; }; + +#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::auto_ptr + +#endif // XSD_CXX11 } } } diff --git a/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx b/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx index 83e9a7e..01111e1 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/bits/error-handler-proxy.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_BITS_ERROR_HANDLER_PROXY_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx b/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx index 23e71cd..7e5579b 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/bits/error-handler-proxy.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <xsd/cxx/xml/string.hxx> @@ -53,24 +52,12 @@ namespace xsd xercesc::DOMLocator* loc (e.getLocation ()); -#if _XERCES_VERSION >= 30000 return eh_->handle ( transcode<C> (loc->getURI ()), static_cast<unsigned long> (loc->getLineNumber ()), static_cast<unsigned long> (loc->getColumnNumber ()), s, transcode<C> (e.getMessage ())); -#else - XMLSSize_t l (loc->getLineNumber ()); - XMLSSize_t c (loc->getColumnNumber ()); - - return eh_->handle ( - transcode<C> (loc->getURI ()), - (l == -1 ? 0 : static_cast<unsigned long> (l)), - (c == -1 ? 0 : static_cast<unsigned long> (c)), - s, - transcode<C> (e.getMessage ())); -#endif } } } diff --git a/xsd/libxsd/xsd/cxx/xml/dom/elements.hxx b/xsd/libxsd/xsd/cxx/xml/dom/elements.hxx index e8ce8d2..613b978 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/elements.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/elements.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/elements.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_ELEMENTS_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/dom/elements.txx b/xsd/libxsd/xsd/cxx/xml/dom/elements.txx index 540d0fb..c493676 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/elements.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/elements.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/elements.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <xsd/cxx/xml/string.hxx> diff --git a/xsd/libxsd/xsd/cxx/xml/dom/parsing-header.hxx b/xsd/libxsd/xsd/cxx/xml/dom/parsing-header.hxx index d9a3695..f9ec033 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/parsing-header.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/parsing-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/parsing-header.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_PARSING_HEADER_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.hxx b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.hxx index 2c90cf3..fac1006 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/parsing-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_PARSING_SOURCE_HXX @@ -19,7 +18,6 @@ #include <xsd/cxx/xml/elements.hxx> // properies #include <xsd/cxx/xml/error-handler.hxx> - #include <xsd/cxx/xml/dom/auto-ptr.hxx> #include <xsd/cxx/xml/dom/elements.hxx> // name #include <xsd/cxx/xml/dom/parsing-header.hxx> @@ -32,30 +30,47 @@ namespace xsd { namespace dom { - // Parser state object. Can be used for parsing element, attributes, - // or both. + // Parser state object. Can be used for parsing elements (and + // optionally text), attributes, or both. // template <typename C> class parser { public: - parser (const xercesc::DOMElement& e, bool ep, bool ap); + parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap); + // Content parsing. + // bool - more_elements () + more_content () { - return next_element_ != 0; + return next_content_ != 0; } const xercesc::DOMElement& cur_element () { - return *static_cast<const xercesc::DOMElement*> (next_element_); + return *static_cast<const xercesc::DOMElement*> (next_content_); + } + + const xercesc::DOMText& + cur_text () + { + return *static_cast<const xercesc::DOMText*> (next_content_); + } + + bool + cur_is_text () + { + return next_content_->getNodeType () != + xercesc::DOMNode::ELEMENT_NODE; } void - next_element (); + next_content (bool text); + // Attribute parsing. + // bool more_attributes () { @@ -88,7 +103,7 @@ namespace xsd private: const xercesc::DOMElement& element_; - const xercesc::DOMNode* next_element_; + const xercesc::DOMNode* next_content_; const xercesc::DOMNamedNodeMap* a_; XMLSize_t ai_; // Index of the next DOMAttr. @@ -102,28 +117,28 @@ namespace xsd const unsigned long no_muliple_imports = 0x00000800UL; template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (xercesc::InputSource&, error_handler<C>&, const properties<C>&, unsigned long flags); template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (xercesc::InputSource&, xercesc::DOMErrorHandler&, const properties<C>&, unsigned long flags); template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (const std::basic_string<C>& uri, error_handler<C>&, const properties<C>&, unsigned long flags); template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (const std::basic_string<C>& uri, xercesc::DOMErrorHandler&, const properties<C>&, diff --git a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx index 50fa285..c789fa6 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx @@ -1,14 +1,10 @@ // file : xsd/cxx/xml/dom/parsing-source.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#if _XERCES_VERSION >= 30000 -# include <xercesc/dom/DOMLSParser.hpp> -# include <xercesc/dom/DOMLSException.hpp> -#else -# include <xercesc/dom/DOMBuilder.hpp> -#endif +#include <xercesc/dom/DOMLSParser.hpp> +#include <xercesc/dom/DOMLSException.hpp> + #include <xercesc/dom/DOMNamedNodeMap.hpp> #include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/dom/DOMImplementationRegistry.hpp> @@ -33,9 +29,9 @@ namespace xsd // template <typename C> parser<C>:: - parser (const xercesc::DOMElement& e, bool ep, bool ap) + parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap) : element_ (e), - next_element_ (0), + next_content_ (0), a_ (0), ai_ (0) { @@ -43,10 +39,21 @@ namespace xsd if (ep) { - for (next_element_ = e.getFirstChild (); - next_element_ != 0 && - next_element_->getNodeType () != DOMNode::ELEMENT_NODE; - next_element_ = next_element_->getNextSibling ()) /*noop*/; + for (next_content_ = e.getFirstChild ();; + next_content_ = next_content_->getNextSibling ()) + { + if (next_content_ == 0) + break; + + DOMNode::NodeType t (next_content_->getNodeType ()); + + if (t == DOMNode::ELEMENT_NODE) + break; + + if (tp && (t == DOMNode::TEXT_NODE || + t == DOMNode::CDATA_SECTION_NODE)) + break; + } } if (ap) @@ -58,20 +65,31 @@ namespace xsd template <typename C> void parser<C>:: - next_element () + next_content (bool tp) { using xercesc::DOMNode; - for (next_element_ = next_element_->getNextSibling (); - next_element_ != 0 && - next_element_->getNodeType () != DOMNode::ELEMENT_NODE; - next_element_ = next_element_->getNextSibling ())/*noop*/; + for (next_content_ = next_content_->getNextSibling ();; + next_content_ = next_content_->getNextSibling ()) + { + if (next_content_ == 0) + break; + + DOMNode::NodeType t (next_content_->getNodeType ()); + + if (t == DOMNode::ELEMENT_NODE) + break; + + if (tp && (t == DOMNode::TEXT_NODE || + t == DOMNode::CDATA_SECTION_NODE)) + break; + } } // parse() // template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (xercesc::InputSource& is, error_handler<C>& eh, const properties<C>& prop, @@ -82,28 +100,13 @@ namespace xsd } template <typename C> - auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (xercesc::InputSource& is, xercesc::DOMErrorHandler& eh, const properties<C>& prop, unsigned long flags) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMImplementationRegistry; - 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; - + using namespace xercesc; // Instantiate the DOM parser. // @@ -116,8 +119,7 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 - auto_ptr<DOMLSParser> parser ( + XSD_DOM_AUTO_PTR<DOMLSParser> parser ( impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); DOMConfiguration* conf (parser->getDomConfig ()); @@ -163,7 +165,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 +215,9 @@ namespace xsd bits::error_handler_proxy<C> ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr<DOMBuilder> 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<void*> (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<void*> (v)); - } - - bits::error_handler_proxy<C> ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - xercesc::Wrapper4InputSource wrap (&is, false); -#if _XERCES_VERSION >= 30000 - auto_ptr<DOMDocument> doc; - + XSD_DOM_AUTO_PTR<DOMDocument> doc; try { doc.reset (parser->parse (&wrap)); @@ -279,9 +225,7 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr<DOMDocument> doc (parser->parse (wrap)); -#endif + if (ehp.failed ()) doc.reset (); @@ -289,7 +233,7 @@ namespace xsd } template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (const std::basic_string<C>& uri, error_handler<C>& eh, const properties<C>& prop, @@ -300,26 +244,13 @@ namespace xsd } template <typename C> - auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> parse (const std::basic_string<C>& uri, xercesc::DOMErrorHandler& eh, const properties<C>& prop, unsigned long flags) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMImplementationRegistry; - 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; - + using namespace xercesc; // Instantiate the DOM parser. // @@ -332,8 +263,7 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 - auto_ptr<DOMLSParser> parser ( + XSD_DOM_AUTO_PTR<DOMLSParser> parser ( impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); DOMConfiguration* conf (parser->getDomConfig ()); @@ -430,63 +360,7 @@ namespace xsd bits::error_handler_proxy<C> ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr<DOMBuilder> 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<void*> (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<void*> (v)); - } - - bits::error_handler_proxy<C> ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - - -#if _XERCES_VERSION >= 30000 - auto_ptr<DOMDocument> doc; - + XSD_DOM_AUTO_PTR<DOMDocument> doc; try { doc.reset (parser->parseURI (string (uri).c_str ())); @@ -494,10 +368,6 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr<DOMDocument> doc ( - parser->parseURI (string (uri).c_str ())); -#endif if (ehp.failed ()) doc.reset (); diff --git a/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.hxx b/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.hxx index 3b879b1..a3cbff4 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/serialization-header.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_SERIALIZATION_HEADER_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.txx b/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.txx index 3052b7e..6e58cfd 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/serialization-header.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/serialization-header.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <vector> @@ -33,12 +32,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<C> (p); @@ -125,13 +120,7 @@ namespace xsd void clear (xercesc::DOMElement& e) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMNode; - using xercesc::DOMAttr; - using xercesc::DOMNamedNodeMap; - using xercesc::XMLString; - using xercesc::SchemaSymbols; + using namespace xercesc; // Remove child nodes. // diff --git a/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.hxx index 325c1ec..9056917 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/serialization-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX @@ -47,13 +46,19 @@ namespace xsd xercesc::DOMElement& create_element (const C* name, const C* ns, xercesc::DOMElement&); + // Add namespace declarations and schema locations. + // + template <typename C> + void + add_namespaces (xercesc::DOMElement&, const namespace_infomap<C>&); + // Serialization flags. // const unsigned long no_xml_declaration = 0x00010000UL; const unsigned long dont_pretty_print = 0x00020000UL; template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> serialize (const std::basic_string<C>& root_element, const std::basic_string<C>& root_element_namespace, const namespace_infomap<C>& map, @@ -62,7 +67,7 @@ namespace xsd // This one helps Sun C++ to overcome its fears. // template <typename C> - inline xml::dom::auto_ptr<xercesc::DOMDocument> + inline XSD_DOM_AUTO_PTR<xercesc::DOMDocument> serialize (const C* root_element, const C* root_element_namespace, const namespace_infomap<C>& map, @@ -103,16 +108,12 @@ namespace xsd public: // I know, some of those consts are stupid. But that's what - // Xerces folks put into their interfaces and VC-7.1 thinks - // there are different signatures if one strips this fluff off. + // Xerces folks put into their interfaces and VC thinks there + // are different signatures if one strips this fluff off. // 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/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.txx index 2b27dd5..eed1196 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/serialization-source.txx @@ -1,18 +1,14 @@ // file : xsd/cxx/xml/dom/serialization-source.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <xercesc/util/XMLUni.hpp> // xercesc::fg* #include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc #include <xercesc/validators/schema/SchemaSymbols.hpp> -#if _XERCES_VERSION >= 30000 -# include <xercesc/dom/DOMLSOutput.hpp> -# include <xercesc/dom/DOMLSSerializer.hpp> -#else -# include <xercesc/dom/DOMWriter.hpp> -#endif +#include <xercesc/dom/DOMLSOutput.hpp> +#include <xercesc/dom/DOMLSSerializer.hpp> + #include <xercesc/dom/DOMElement.hpp> #include <xercesc/dom/DOMImplementation.hpp> #include <xercesc/dom/DOMImplementationRegistry.hpp> @@ -109,70 +105,19 @@ namespace xsd return *e; } - - // - // template <typename C> - auto_ptr<xercesc::DOMDocument> - serialize (const std::basic_string<C>& el, - const std::basic_string<C>& ns, - const namespace_infomap<C>& map, - unsigned long) + void + add_namespaces (xercesc::DOMElement& el, + const namespace_infomap<C>& map) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMImplementationRegistry; - using xercesc::DOMImplementation; - using xercesc::DOMDocument; - using xercesc::DOMElement; + using namespace xercesc; - // - // typedef std::basic_string<C> string; typedef namespace_infomap<C> infomap; typedef typename infomap::const_iterator infomap_iterator; C colon (':'), space (' '); - string prefix; - - if (!ns.empty ()) - { - infomap_iterator i (map.begin ()), e (map.end ()); - - for ( ;i != e; ++i) - { - if (i->second.name == ns) - { - prefix = i->first; - break; - } - } - - // Since this is the first namespace in document we don't - // need to worry about conflicts. - // - if (i == e) - prefix = xml::bits::first_prefix<C> (); - } - - const XMLCh ls[] = {xercesc::chLatin_L, - xercesc::chLatin_S, - xercesc::chNull}; - - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - auto_ptr<DOMDocument> doc ( - impl->createDocument ( - (ns.empty () ? 0 : xml::string (ns).c_str ()), - xml::string ((prefix.empty () - ? el - : prefix + colon + el)).c_str (), - 0)); - - DOMElement* root (doc->getDocumentElement ()); - // Check if we need to provide xsi mapping. // bool xsi (false); @@ -214,14 +159,14 @@ namespace xsd // Empty prefix. // if (!i->second.name.empty ()) - root->setAttributeNS ( + el.setAttributeNS ( xercesc::XMLUni::fgXMLNSURIName, xml::string (xmlns_prefix).c_str (), xml::string (i->second.name).c_str ()); } else { - root->setAttributeNS ( + el.setAttributeNS ( xercesc::XMLUni::fgXMLNSURIName, xml::string (xmlns_prefix + colon + i->first).c_str (), xml::string (i->second.name).c_str ()); @@ -233,7 +178,7 @@ namespace xsd // if (xsi) xsi_prefix = dom::prefix (xml::bits::xsi_namespace<C> (), - *root, + el, xml::bits::xsi_prefix<C> ()); // Create xsi:schemaLocation and xsi:noNamespaceSchemaLocation @@ -265,7 +210,7 @@ namespace xsd if (!schema_location.empty ()) { - root->setAttributeNS ( + el.setAttributeNS ( xercesc::SchemaSymbols::fgURI_XSI, xml::string (xsi_prefix + colon + xml::bits::schema_location<C> ()).c_str (), @@ -274,13 +219,68 @@ namespace xsd if (!no_namespace_schema_location.empty ()) { - root->setAttributeNS ( + el.setAttributeNS ( xercesc::SchemaSymbols::fgURI_XSI, xml::string ( xsi_prefix + colon + xml::bits::no_namespace_schema_location<C> ()).c_str (), xml::string (no_namespace_schema_location).c_str ()); } + } + + // + // + template <typename C> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> + serialize (const std::basic_string<C>& el, + const std::basic_string<C>& ns, + const namespace_infomap<C>& map, + unsigned long) + { + using namespace xercesc; + + typedef std::basic_string<C> string; + typedef namespace_infomap<C> infomap; + typedef typename infomap::const_iterator infomap_iterator; + + string prefix; + + if (!ns.empty ()) + { + infomap_iterator i (map.begin ()), e (map.end ()); + + for ( ;i != e; ++i) + { + if (i->second.name == ns) + { + prefix = i->first; + break; + } + } + + // Since this is the first namespace in document we don't + // need to worry about conflicts. + // + if (i == e) + prefix = xml::bits::first_prefix<C> (); + } + + const XMLCh ls[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + XSD_DOM_AUTO_PTR<DOMDocument> doc ( + impl->createDocument ( + (ns.empty () ? 0 : xml::string (ns).c_str ()), + xml::string ((prefix.empty () + ? el + : prefix + C (':') + el)).c_str (), + 0)); + + add_namespaces (*doc->getDocumentElement (), map); return doc; } @@ -294,18 +294,7 @@ namespace xsd xercesc::DOMErrorHandler& eh, unsigned long flags) { - // HP aCC cannot handle using namespace xercesc; - // - 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; + using namespace xercesc; const XMLCh ls[] = {xercesc::chLatin_L, xercesc::chLatin_S, @@ -316,8 +305,7 @@ namespace xsd bits::error_handler_proxy<C> ehp (eh); -#if _XERCES_VERSION >= 30000 - xml::dom::auto_ptr<DOMLSSerializer> writer ( + XSD_DOM_AUTO_PTR<DOMLSSerializer> writer ( impl->createLSSerializer ()); DOMConfiguration* conf (writer->getDomConfig ()); @@ -332,46 +320,27 @@ namespace xsd if (!(flags & dont_pretty_print) && conf->canSetParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true)) + { conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); + // Don't add extra new lines between first-level elements. + // + if (conf->canSetParameter (XMLUni::fgDOMWRTXercesPrettyPrint, true)) + conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false); + } + // See if we need to write XML declaration. // if ((flags & no_xml_declaration) && conf->canSetParameter (XMLUni::fgDOMXMLDeclaration, false)) conf->setParameter (XMLUni::fgDOMXMLDeclaration, false); - xml::dom::auto_ptr<DOMLSOutput> out (impl->createLSOutput ()); + XSD_DOM_AUTO_PTR<DOMLSOutput> out (impl->createLSOutput ()); out->setEncoding (xml::string (encoding).c_str ()); out->setByteStream (&target); - bool r (writer->write (&doc, out.get ())); -#else - xml::dom::auto_ptr<DOMWriter> 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/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx b/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx index 11d7114..95de764 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx +++ b/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/wildcard-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_WILDCARD_SOURCE_HXX @@ -19,7 +18,7 @@ namespace xsd namespace dom { template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> create_document (); } } diff --git a/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.txx b/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.txx index 32043c0..cce6922 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/wildcard-source.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/dom/wildcard-source.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc @@ -17,7 +16,7 @@ namespace xsd namespace dom { template <typename C> - xml::dom::auto_ptr<xercesc::DOMDocument> + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> create_document () { const XMLCh ls[] = {xercesc::chLatin_L, @@ -29,7 +28,7 @@ namespace xsd xercesc::DOMImplementation* impl ( xercesc::DOMImplementationRegistry::getDOMImplementation (ls)); - return xml::dom::auto_ptr<xercesc::DOMDocument> ( + return XSD_DOM_AUTO_PTR<xercesc::DOMDocument> ( impl->createDocument ()); } } diff --git a/xsd/libxsd/xsd/cxx/xml/elements.hxx b/xsd/libxsd/xsd/cxx/xml/elements.hxx index d9f8a50..107b36d 100644 --- a/xsd/libxsd/xsd/cxx/xml/elements.hxx +++ b/xsd/libxsd/xsd/cxx/xml/elements.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/elements.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_ELEMENTS_HXX @@ -8,8 +7,13 @@ #include <string> +#include <xercesc/util/XercesVersion.hpp> #include <xercesc/util/PlatformUtils.hpp> +#if _XERCES_VERSION < 30000 +# error Xerces-C++ 2-series is not supported +#endif + namespace xsd { namespace cxx diff --git a/xsd/libxsd/xsd/cxx/xml/elements.txx b/xsd/libxsd/xsd/cxx/xml/elements.txx index 8ba07df..37adcf0 100644 --- a/xsd/libxsd/xsd/cxx/xml/elements.txx +++ b/xsd/libxsd/xsd/cxx/xml/elements.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/elements.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file namespace xsd diff --git a/xsd/libxsd/xsd/cxx/xml/error-handler.hxx b/xsd/libxsd/xsd/cxx/xml/error-handler.hxx index bf0b3d7..616d081 100644 --- a/xsd/libxsd/xsd/cxx/xml/error-handler.hxx +++ b/xsd/libxsd/xsd/cxx/xml/error-handler.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/error-handler.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_ERROR_HANDLER_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/exceptions.hxx b/xsd/libxsd/xsd/cxx/xml/exceptions.hxx index 1ed93d8..ef1ec7a 100644 --- a/xsd/libxsd/xsd/cxx/xml/exceptions.hxx +++ b/xsd/libxsd/xsd/cxx/xml/exceptions.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/exceptions.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_EXCEPTIONS_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/qualified-name.hxx b/xsd/libxsd/xsd/cxx/xml/qualified-name.hxx index 1a0e032..bfdf4f3 100644 --- a/xsd/libxsd/xsd/cxx/xml/qualified-name.hxx +++ b/xsd/libxsd/xsd/cxx/xml/qualified-name.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/qualified-name.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_QUALIFIED_NAME_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx b/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx index f92b6ab..0cfacc2 100644 --- a/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx +++ b/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/sax/bits/error-handler-proxy.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX diff --git a/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx b/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx index f8ca26d..24b8a3d 100644 --- a/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx +++ b/xsd/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/sax/bits/error-handler-proxy.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #include <xsd/cxx/xml/string.hxx> @@ -65,22 +64,11 @@ namespace xsd if (id == 0) id = e.getSystemId (); -#if _XERCES_VERSION >= 30000 eh_->handle (transcode<C> (id), static_cast<unsigned long> (e.getLineNumber ()), static_cast<unsigned long> (e.getColumnNumber ()), s, transcode<C> (e.getMessage ())); -#else - XMLSSize_t l (e.getLineNumber ()); - XMLSSize_t c (e.getColumnNumber ()); - - eh_->handle (transcode<C> (id), - (l == -1 ? 0 : static_cast<unsigned long> (l)), - (c == -1 ? 0 : static_cast<unsigned long> (c)), - s, - transcode<C> (e.getMessage ())); -#endif } } } diff --git a/xsd/libxsd/xsd/cxx/xml/sax/std-input-source.hxx b/xsd/libxsd/xsd/cxx/xml/sax/std-input-source.hxx index 71760a9..00b2397 100644 --- a/xsd/libxsd/xsd/cxx/xml/sax/std-input-source.hxx +++ b/xsd/libxsd/xsd/cxx/xml/sax/std-input-source.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/sax/std-input-source.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_SAX_STD_INPUT_SOURCE_HXX @@ -29,27 +28,14 @@ namespace xsd { } -#if _XERCES_VERSION >= 30000 virtual XMLFilePos curPos () const { return static_cast<XMLFilePos> (is_.tellg ()); } -#else - virtual unsigned int - curPos () const - { - return static_cast<unsigned int> (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 +64,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<XMLSize_t> (is_.gcount ()); -#else - return static_cast<unsigned int> (is_.gcount ()); -#endif - } - else - return 0; + return !is_.fail () + ? static_cast<XMLSize_t> (is_.gcount ()) + : 0; } -#if _XERCES_VERSION >= 30000 virtual const XMLCh* getContentType () const { return 0; } -#endif + private: std::istream& is_; }; diff --git a/xsd/libxsd/xsd/cxx/xml/std-memory-manager.hxx b/xsd/libxsd/xsd/cxx/xml/std-memory-manager.hxx index b5cfaf9..e4d6f5b 100644 --- a/xsd/libxsd/xsd/cxx/xml/std-memory-manager.hxx +++ b/xsd/libxsd/xsd/cxx/xml/std-memory-manager.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/std-memory-manager.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_STD_MEMORY_MANAGER_HXX @@ -18,12 +17,10 @@ namespace xsd class std_memory_manager: public xercesc::MemoryManager { public: + // Xerces-C++ MemoryManager interface. + // virtual void* -#if _XERCES_VERSION >= 30000 allocate(XMLSize_t size) -#else - allocate(size_t size) -#endif { return operator new (size); } @@ -35,13 +32,20 @@ namespace xsd operator delete (p); } -#if _XERCES_VERSION >= 30000 virtual xercesc::MemoryManager* getExceptionMemoryManager() { return xercesc::XMLPlatformUtils::fgMemoryManager; } -#endif + + // Standard deleter interface. + // + void + operator() (void* p) const + { + if (p) + operator delete (p); + } }; } } diff --git a/xsd/libxsd/xsd/cxx/xml/string.hxx b/xsd/libxsd/xsd/cxx/xml/string.hxx index f79e66e..9f4767b 100644 --- a/xsd/libxsd/xsd/cxx/xml/string.hxx +++ b/xsd/libxsd/xsd/cxx/xml/string.hxx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/string.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_STRING_HXX @@ -9,9 +8,16 @@ #include <string> #include <cstddef> // std::size_t -#include <xsd/cxx/auto-array.hxx> #include <xercesc/util/XercesDefs.hpp> // XMLCh +#include <xsd/cxx/config.hxx> // XSD_CXX11 + +#ifdef XSD_CXX11 +# include <memory> // std::unique_ptr +#else +# include <xsd/cxx/auto-array.hxx> +#endif + namespace xsd { namespace cxx @@ -31,9 +37,9 @@ namespace xsd transcode (const XMLCh* s, std::size_t length); - // For VC7.1 wchar_t and XMLCh are the same type so we cannot - // overload the transcode name. You should not use these functions - // anyway and instead use the xml::string class below. + // For VC wchar_t and XMLCh are the same type so we cannot overload + // the transcode name. You should not use these functions anyway and + // instead use the xml::string class below. // template <typename C> XMLCh* @@ -50,21 +56,16 @@ namespace xsd public : template <typename C> string (const std::basic_string<C>& s) - : s_ (transcode_to_xmlch<C> (s)) - { - } + : s_ (transcode_to_xmlch<C> (s)) {} template <typename C> - string (const C* s) - : s_ (transcode_to_xmlch<C> (s)) - { - } + string (const C* s): s_ (transcode_to_xmlch<C> (s)) {} const XMLCh* - c_str () const - { - return s_.get (); - } + c_str () const {return s_.get ();} + + XMLCh* + release () {return s_.release ();} private: string (const string&); @@ -73,7 +74,11 @@ namespace xsd operator= (const string&); private: +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> s_; +#else auto_array<XMLCh> s_; +#endif }; } } diff --git a/xsd/libxsd/xsd/cxx/xml/string.ixx b/xsd/libxsd/xsd/cxx/xml/string.ixx index 0f46f4d..ede125e 100644 --- a/xsd/libxsd/xsd/cxx/xml/string.ixx +++ b/xsd/libxsd/xsd/cxx/xml/string.ixx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/string.ixx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_STRING_IXX diff --git a/xsd/libxsd/xsd/cxx/xml/string.txx b/xsd/libxsd/xsd/cxx/xml/string.txx index df0fb74..e6adb98 100644 --- a/xsd/libxsd/xsd/cxx/xml/string.txx +++ b/xsd/libxsd/xsd/cxx/xml/string.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/xml/string.txx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_STRING_TXX @@ -47,7 +46,13 @@ namespace xsd XMLCh* wchar_transcoder<W, 2>:: from (const W* s, std::size_t length) { - auto_array<XMLCh> r (new XMLCh[length + 1]); +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> r ( +#else + auto_array<XMLCh> r ( +#endif + new XMLCh[length + 1]); + XMLCh* ir (r.get ()); for (std::size_t i (0); i < length; ++ir, ++i) @@ -120,7 +125,13 @@ namespace xsd rl += (*p & 0xFFFF0000) ? 2 : 1; } - auto_array<XMLCh> r (new XMLCh[rl + 1]); +#ifdef XSD_CXX11 + std::unique_ptr<XMLCh[]> r ( +#else + auto_array<XMLCh> r ( +#endif + new XMLCh[rl + 1]); + XMLCh* ir (r.get ()); for (const W* p (s); p < s + length; ++p) |