aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd/xsd/cxx/xml')
-rw-r--r--libxsd/xsd/cxx/xml/char-iso8859-1.txx15
-rw-r--r--libxsd/xsd/cxx/xml/char-lcp.txx24
-rw-r--r--libxsd/xsd/cxx/xml/char-utf8.txx15
-rw-r--r--libxsd/xsd/cxx/xml/dom/auto-ptr.hxx80
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-source.hxx9
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-source.txx16
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.hxx4
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.txx8
-rw-r--r--libxsd/xsd/cxx/xml/dom/wildcard-source.hxx2
-rw-r--r--libxsd/xsd/cxx/xml/dom/wildcard-source.txx4
-rw-r--r--libxsd/xsd/cxx/xml/std-memory-manager.hxx11
-rw-r--r--libxsd/xsd/cxx/xml/string.hxx13
-rw-r--r--libxsd/xsd/cxx/xml/string.txx16
13 files changed, 184 insertions, 33 deletions
diff --git a/libxsd/xsd/cxx/xml/char-iso8859-1.txx b/libxsd/xsd/cxx/xml/char-iso8859-1.txx
index ff82963..3ce88ad 100644
--- a/libxsd/xsd/cxx/xml/char-iso8859-1.txx
+++ b/libxsd/xsd/cxx/xml/char-iso8859-1.txx
@@ -3,7 +3,13 @@
// copyright : Copyright (c) 2005-2011 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 +93,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/libxsd/xsd/cxx/xml/char-lcp.txx b/libxsd/xsd/cxx/xml/char-lcp.txx
index 7bd8862..21c85d0 100644
--- a/libxsd/xsd/cxx/xml/char-lcp.txx
+++ b/libxsd/xsd/cxx/xml/char-lcp.txx
@@ -7,7 +7,14 @@
#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 +28,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 +41,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/libxsd/xsd/cxx/xml/char-utf8.txx b/libxsd/xsd/cxx/xml/char-utf8.txx
index ff3f9e0..7dc0ac9 100644
--- a/libxsd/xsd/cxx/xml/char-utf8.txx
+++ b/libxsd/xsd/cxx/xml/char-utf8.txx
@@ -3,7 +3,13 @@
// copyright : Copyright (c) 2005-2011 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 +190,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/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
index d94ba13..b8c9aa3 100644
--- a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
+++ b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
@@ -6,6 +6,14 @@
#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 +22,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 +222,10 @@ namespace xsd
private:
T* x_;
};
+
+#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::auto_ptr
+
+#endif // XSD_CXX11
}
}
}
diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
index f35f99d..1daac34 100644
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
@@ -19,7 +19,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>
@@ -102,28 +101,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/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
index d2152ac..352114d 100644
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
@@ -68,7 +68,7 @@ namespace xsd
// 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,
@@ -79,7 +79,7 @@ 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,
@@ -98,7 +98,7 @@ namespace xsd
DOMImplementation* impl (
DOMImplementationRegistry::getDOMImplementation (ls_id));
- auto_ptr<DOMLSParser> parser (
+ XSD_DOM_AUTO_PTR<DOMLSParser> parser (
impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
DOMConfiguration* conf (parser->getDomConfig ());
@@ -196,7 +196,7 @@ namespace xsd
xercesc::Wrapper4InputSource wrap (&is, false);
- auto_ptr<DOMDocument> doc;
+ XSD_DOM_AUTO_PTR<DOMDocument> doc;
try
{
doc.reset (parser->parse (&wrap));
@@ -212,7 +212,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,
@@ -223,7 +223,7 @@ 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,
@@ -242,7 +242,7 @@ namespace xsd
DOMImplementation* impl (
DOMImplementationRegistry::getDOMImplementation (ls_id));
- auto_ptr<DOMLSParser> parser (
+ XSD_DOM_AUTO_PTR<DOMLSParser> parser (
impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
DOMConfiguration* conf (parser->getDomConfig ());
@@ -339,7 +339,7 @@ namespace xsd
bits::error_handler_proxy<C> ehp (eh);
conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
- auto_ptr<DOMDocument> doc;
+ XSD_DOM_AUTO_PTR<DOMDocument> doc;
try
{
doc.reset (parser->parseURI (string (uri).c_str ()));
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
index 9bfd27b..3b23220 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
@@ -53,7 +53,7 @@ namespace xsd
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 +62,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,
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
index 7de5ca0..efd4141 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
@@ -110,7 +110,7 @@ namespace xsd
//
//
template <typename C>
- auto_ptr<xercesc::DOMDocument>
+ XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
serialize (const std::basic_string<C>& el,
const std::basic_string<C>& ns,
const namespace_infomap<C>& map,
@@ -153,7 +153,7 @@ namespace xsd
DOMImplementation* impl (
DOMImplementationRegistry::getDOMImplementation (ls));
- auto_ptr<DOMDocument> doc (
+ XSD_DOM_AUTO_PTR<DOMDocument> doc (
impl->createDocument (
(ns.empty () ? 0 : xml::string (ns).c_str ()),
xml::string ((prefix.empty ()
@@ -295,7 +295,7 @@ namespace xsd
bits::error_handler_proxy<C> ehp (eh);
- xml::dom::auto_ptr<DOMLSSerializer> writer (
+ XSD_DOM_AUTO_PTR<DOMLSSerializer> writer (
impl->createLSSerializer ());
DOMConfiguration* conf (writer->getDomConfig ());
@@ -318,7 +318,7 @@ namespace xsd
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);
diff --git a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
index 55d083b..225f5df 100644
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
@@ -19,7 +19,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/libxsd/xsd/cxx/xml/dom/wildcard-source.txx b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
index 7feb937..bd2817f 100644
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
@@ -17,7 +17,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 +29,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/libxsd/xsd/cxx/xml/std-memory-manager.hxx b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
index bd8fbab..00012fd 100644
--- a/libxsd/xsd/cxx/xml/std-memory-manager.hxx
+++ b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
@@ -18,6 +18,8 @@ namespace xsd
class std_memory_manager: public xercesc::MemoryManager
{
public:
+ // Xerces-C++ MemoryManager interface.
+ //
virtual void*
allocate(XMLSize_t size)
{
@@ -36,6 +38,15 @@ namespace xsd
{
return xercesc::XMLPlatformUtils::fgMemoryManager;
}
+
+ // Standard deleter interface.
+ //
+ void
+ operator() (void* p) const
+ {
+ if (p)
+ operator delete (p);
+ }
};
}
}
diff --git a/libxsd/xsd/cxx/xml/string.hxx b/libxsd/xsd/cxx/xml/string.hxx
index f1a907c..832e7ec 100644
--- a/libxsd/xsd/cxx/xml/string.hxx
+++ b/libxsd/xsd/cxx/xml/string.hxx
@@ -9,9 +9,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
@@ -73,7 +80,11 @@ namespace xsd
operator= (const string&);
private:
+#ifdef XSD_CXX11
+ std::unique_ptr<XMLCh[]> s_;
+#else
auto_array<XMLCh> s_;
+#endif
};
}
}
diff --git a/libxsd/xsd/cxx/xml/string.txx b/libxsd/xsd/cxx/xml/string.txx
index 830ed92..c6f1d20 100644
--- a/libxsd/xsd/cxx/xml/string.txx
+++ b/libxsd/xsd/cxx/xml/string.txx
@@ -47,7 +47,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 +126,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)