summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd/xsd/cxx')
-rw-r--r--libxsd/xsd/cxx/auto-array.hxx22
-rw-r--r--libxsd/xsd/cxx/config.hxx35
-rw-r--r--libxsd/xsd/cxx/parser/expat/elements.hxx25
-rw-r--r--libxsd/xsd/cxx/parser/expat/elements.txx8
-rw-r--r--libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx6
-rw-r--r--libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx8
-rw-r--r--libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx8
-rw-r--r--libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx10
-rw-r--r--libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx16
-rw-r--r--libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx8
-rw-r--r--libxsd/xsd/cxx/parser/xerces/elements.hxx6
-rw-r--r--libxsd/xsd/cxx/parser/xerces/elements.txx16
-rw-r--r--libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx38
-rw-r--r--libxsd/xsd/cxx/tree/containers.hxx33
-rw-r--r--libxsd/xsd/cxx/tree/containers.txx21
-rw-r--r--libxsd/xsd/cxx/tree/element-map.hxx10
-rw-r--r--libxsd/xsd/cxx/tree/elements.hxx131
-rw-r--r--libxsd/xsd/cxx/tree/istream.hxx6
-rw-r--r--libxsd/xsd/cxx/tree/ostream.hxx6
-rw-r--r--libxsd/xsd/cxx/tree/parsing.txx18
-rw-r--r--libxsd/xsd/cxx/tree/parsing/element-map.txx6
-rw-r--r--libxsd/xsd/cxx/tree/stream-extraction-map.hxx10
-rw-r--r--libxsd/xsd/cxx/tree/stream-extraction-map.txx6
-rw-r--r--libxsd/xsd/cxx/tree/stream-extraction.hxx3
-rw-r--r--libxsd/xsd/cxx/tree/type-factory-map.hxx16
-rw-r--r--libxsd/xsd/cxx/tree/type-factory-map.txx13
-rw-r--r--libxsd/xsd/cxx/tree/type-serializer-map.hxx3
-rw-r--r--libxsd/xsd/cxx/tree/type-serializer-map.txx2
-rw-r--r--libxsd/xsd/cxx/tree/types.txx20
-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
42 files changed, 497 insertions, 230 deletions
diff --git a/libxsd/xsd/cxx/auto-array.hxx b/libxsd/xsd/cxx/auto-array.hxx
index e309603..64c454a 100644
--- a/libxsd/xsd/cxx/auto-array.hxx
+++ b/libxsd/xsd/cxx/auto-array.hxx
@@ -6,6 +6,12 @@
#ifndef XSD_CXX_AUTO_ARRAY_HXX
#define XSD_CXX_AUTO_ARRAY_HXX
+#include <xsd/cxx/config.hxx> // XSD_CXX11
+
+#ifdef XSD_CXX11
+# error use std::unique_ptr instead of non-standard auto_array
+#endif
+
#include <cstddef> // std::size_t
namespace xsd
@@ -13,20 +19,20 @@ namespace xsd
namespace cxx
{
template <typename T>
- struct std_deallocator
+ struct std_array_deleter
{
void
- deallocate (T* p)
+ operator() (T* p) const
{
delete[] p;
}
};
// Simple automatic array. The second template parameter is
- // an optional deallocator type. If not specified, delete[]
+ // an optional deleter type. If not specified, delete[]
// is used.
//
- template <typename T, typename D = std_deallocator<T> >
+ template <typename T, typename D = std_array_deleter<T> >
struct auto_array
{
auto_array (T a[])
@@ -34,7 +40,7 @@ namespace xsd
{
}
- auto_array (T a[], D& d)
+ auto_array (T a[], const D& d)
: a_ (a), d_ (&d)
{
}
@@ -42,7 +48,7 @@ namespace xsd
~auto_array ()
{
if (d_ != 0)
- d_->deallocate (a_);
+ (*d_) (a_);
else
delete[] a_;
}
@@ -73,7 +79,7 @@ namespace xsd
if (a_ != a)
{
if (d_ != 0)
- d_->deallocate (a_);
+ (*d_) (a_);
else
delete[] a_;
@@ -100,7 +106,7 @@ namespace xsd
private:
T* a_;
- D* d_;
+ const D* d_;
};
template <typename T, typename D>
diff --git a/libxsd/xsd/cxx/config.hxx b/libxsd/xsd/cxx/config.hxx
index 1c214fc..e4d6a48 100644
--- a/libxsd/xsd/cxx/config.hxx
+++ b/libxsd/xsd/cxx/config.hxx
@@ -8,7 +8,40 @@
#include <xsd/cxx/version.hxx>
-// Macro to suppress unused variable warning.
+// Available C++11 features.
+//
+#ifdef XSD_CXX11
+#ifdef _MSC_VER
+# if _MSC_VER >= 1600
+# define XSD_CXX11_NULLPTR
+# if _MSC_VER >= 1800
+# define XSD_CXX11_TEMPLATE_ALIAS
+# endif
+# endif
+#else
+# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
+# ifdef __GNUC__
+# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4
+# define XSD_CXX11_NULLPTR
+# endif
+# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
+# define XSD_CXX11_TEMPLATE_ALIAS
+# endif
+# else
+# define XSD_CXX11_NULLPTR
+# define XSD_CXX11_TEMPLATE_ALIAS
+# endif
+# endif
+#endif
+#endif // XSD_CXX11
+
+#ifdef XSD_CXX11
+# define XSD_AUTO_PTR std::unique_ptr
+#else
+# define XSD_AUTO_PTR std::auto_ptr
+#endif
+
+// Macro to suppress the unused variable warning.
//
#define XSD_UNUSED(x) (void)x
diff --git a/libxsd/xsd/cxx/parser/expat/elements.hxx b/libxsd/xsd/cxx/parser/expat/elements.hxx
index 706b6a3..d47106b 100644
--- a/libxsd/xsd/cxx/parser/expat/elements.hxx
+++ b/libxsd/xsd/cxx/parser/expat/elements.hxx
@@ -6,11 +6,17 @@
#ifndef XSD_CXX_PARSER_EXPAT_ELEMENTS_HXX
#define XSD_CXX_PARSER_EXPAT_ELEMENTS_HXX
+#include <xsd/cxx/config.hxx> // XSD_CXX11
+
#include <string>
#include <iosfwd>
#include <cstddef> // std::size_t
#include <vector>
+#ifdef XSD_CXX11
+# include <memory> // std::unique_ptr
+#endif
+
#include <expat.h>
// We only support UTF-8 expat for now.
@@ -35,6 +41,19 @@ namespace xsd
{
namespace expat
{
+#ifdef XSD_CXX11
+ struct parser_deleter
+ {
+ void
+ operator() (XML_Parser p) const
+ {
+ if (p != 0)
+ XML_ParserFree (p);
+ }
+ };
+
+ typedef std::unique_ptr<XML_ParserStruct> parser_auto_ptr;
+#else
// Simple auto pointer for Expat's XML_Parser object.
//
struct parser_auto_ptr
@@ -61,8 +80,8 @@ namespace xsd
return *this;
}
- public:
- operator XML_Parser ()
+ XML_Parser
+ get () const
{
return parser_;
}
@@ -76,7 +95,7 @@ namespace xsd
private:
XML_Parser parser_;
};
-
+#endif // XSD_CXX11
//
//
diff --git a/libxsd/xsd/cxx/parser/expat/elements.txx b/libxsd/xsd/cxx/parser/expat/elements.txx
index 21dff58..f3df667 100644
--- a/libxsd/xsd/cxx/parser/expat/elements.txx
+++ b/libxsd/xsd/cxx/parser/expat/elements.txx
@@ -334,18 +334,18 @@ namespace xsd
{
// First call.
//
- if (auto_xml_parser_ == 0)
+ if (auto_xml_parser_.get () == 0)
{
auto_xml_parser_ = XML_ParserCreateNS (0, XML_Char (' '));
- if (auto_xml_parser_ == 0)
+ if (auto_xml_parser_.get () == 0)
throw std::bad_alloc ();
if (system_id || public_id)
- parse_begin (auto_xml_parser_,
+ parse_begin (auto_xml_parser_.get (),
system_id ? *system_id : *public_id, eh);
else
- parse_begin (auto_xml_parser_, eh);
+ parse_begin (auto_xml_parser_.get (), eh);
}
bool r (XML_Parse (xml_parser_,
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
index 26c77a6..0e05e42 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx
@@ -8,6 +8,8 @@
#include <string>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/parser/non-validating/xml-schema-pskel.hxx>
namespace xsd
@@ -564,7 +566,7 @@ namespace xsd
virtual void
_characters (const ro_string<C>&);
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_base64_binary ();
protected:
@@ -582,7 +584,7 @@ namespace xsd
virtual void
_characters (const ro_string<C>&);
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_hex_binary ();
protected:
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
index 2c46874..77b1423 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pimpl.txx
@@ -1157,7 +1157,7 @@ namespace xsd
}
template <typename C>
- std::auto_ptr<buffer> base64_binary_pimpl<C>::
+ XSD_AUTO_PTR<buffer> base64_binary_pimpl<C>::
post_base64_binary ()
{
typedef typename std::basic_string<C>::size_type size_type;
@@ -1199,7 +1199,7 @@ namespace xsd
size_type quad_count (size / 4);
size_type capacity (quad_count * 3 + 1);
- std::auto_ptr<buffer> buf (new buffer (capacity, capacity));
+ XSD_AUTO_PTR<buffer> buf (new buffer (capacity, capacity));
char* dst (buf->data ());
size_type si (0), di (0); // Source and destination indexes.
@@ -1309,7 +1309,7 @@ namespace xsd
}
template <typename C>
- std::auto_ptr<buffer> hex_binary_pimpl<C>::
+ XSD_AUTO_PTR<buffer> hex_binary_pimpl<C>::
post_hex_binary ()
{
typedef typename ro_string<C>::size_type size_type;
@@ -1318,7 +1318,7 @@ namespace xsd
size_type size (trim_right (tmp));
buffer::size_t n (size / 2);
- std::auto_ptr<buffer> buf (new buffer (n));
+ XSD_AUTO_PTR<buffer> buf (new buffer (n));
const C* src (tmp.data ());
char* dst (buf->data ());
diff --git a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
index 7d0dd00..aae157e 100644
--- a/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
+++ b/libxsd/xsd/cxx/parser/non-validating/xml-schema-pskel.hxx
@@ -7,7 +7,9 @@
#define XSD_CXX_PARSER_NON_VALIDATING_XML_SCHEMA_PSKEL_HXX
#include <string>
-#include <memory> // auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
+
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
#include <xsd/cxx/parser/xml-schema.hxx>
#include <xsd/cxx/parser/non-validating/parser.hxx>
@@ -494,7 +496,7 @@ namespace xsd
template <typename C>
struct base64_binary_pskel: simple_content<C>
{
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_base64_binary () = 0;
static const C*
@@ -507,7 +509,7 @@ namespace xsd
template <typename C>
struct hex_binary_pskel: simple_content<C>
{
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_hex_binary () = 0;
static const C*
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
index 0df1c4f..09194e4 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.hxx
@@ -8,6 +8,8 @@
#include <string>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/parser/validating/xml-schema-pskel.hxx>
namespace xsd
@@ -664,12 +666,12 @@ namespace xsd
virtual void
_post ();
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_base64_binary ();
protected:
std::basic_string<C> str_;
- std::auto_ptr<buffer> buf_;
+ XSD_AUTO_PTR<buffer> buf_;
};
// hexBinary
@@ -686,12 +688,12 @@ namespace xsd
virtual void
_post ();
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_hex_binary ();
protected:
std::basic_string<C> str_;
- std::auto_ptr<buffer> buf_;
+ XSD_AUTO_PTR<buffer> buf_;
};
// gday
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
index 021cca8..6631dd2 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pimpl.txx
@@ -6,6 +6,10 @@
#include <limits>
#include <locale>
+#ifdef XSD_CXX11
+# include <utility> // std::move
+#endif
+
#include <xsd/cxx/zc-istream.hxx>
#include <xsd/cxx/parser/validating/exceptions.hxx>
@@ -1634,10 +1638,14 @@ namespace xsd
}
template <typename C>
- std::auto_ptr<buffer> base64_binary_pimpl<C>::
+ XSD_AUTO_PTR<buffer> base64_binary_pimpl<C>::
post_base64_binary ()
{
+#ifdef XSD_CXX11
+ return std::move (buf_);
+#else
return buf_;
+#endif
}
// hex_binary
@@ -1721,10 +1729,14 @@ namespace xsd
}
template <typename C>
- std::auto_ptr<buffer> hex_binary_pimpl<C>::
+ XSD_AUTO_PTR<buffer> hex_binary_pimpl<C>::
post_hex_binary ()
{
+#ifdef XSD_CXX11
+ return std::move (buf_);
+#else
return buf_;
+#endif
}
// time_zone
diff --git a/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx b/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
index 4641fe9..88cc3ab 100644
--- a/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
+++ b/libxsd/xsd/cxx/parser/validating/xml-schema-pskel.hxx
@@ -7,7 +7,9 @@
#define XSD_CXX_PARSER_VALIDATING_XML_SCHEMA_PSKEL_HXX
#include <string>
-#include <memory> // auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
+
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
#include <xsd/cxx/parser/xml-schema.hxx>
#include <xsd/cxx/parser/validating/parser.hxx>
@@ -494,7 +496,7 @@ namespace xsd
template <typename C>
struct base64_binary_pskel: simple_content<C>
{
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_base64_binary () = 0;
static const C*
@@ -507,7 +509,7 @@ namespace xsd
template <typename C>
struct hex_binary_pskel: simple_content<C>
{
- virtual std::auto_ptr<buffer>
+ virtual XSD_AUTO_PTR<buffer>
post_hex_binary () = 0;
static const C*
diff --git a/libxsd/xsd/cxx/parser/xerces/elements.hxx b/libxsd/xsd/cxx/parser/xerces/elements.hxx
index 5fe3688..35920a4 100644
--- a/libxsd/xsd/cxx/parser/xerces/elements.hxx
+++ b/libxsd/xsd/cxx/parser/xerces/elements.hxx
@@ -6,7 +6,7 @@
#ifndef XSD_CXX_PARSER_XERCES_ELEMENTS_HXX
#define XSD_CXX_PARSER_XERCES_ELEMENTS_HXX
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <string>
#include <iosfwd>
#include <vector>
@@ -18,6 +18,8 @@
#include <xercesc/util/XercesVersion.hpp>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/xml/elements.hxx>
#include <xsd/cxx/xml/error-handler.hxx>
@@ -377,7 +379,7 @@ namespace xsd
const properties<C>&);
private:
- std::auto_ptr<xercesc::SAX2XMLReader>
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader>
create_sax_ (flags, const properties<C>&);
private:
diff --git a/libxsd/xsd/cxx/parser/xerces/elements.txx b/libxsd/xsd/cxx/parser/xerces/elements.txx
index 60b6c6d..2324b0c 100644
--- a/libxsd/xsd/cxx/parser/xerces/elements.txx
+++ b/libxsd/xsd/cxx/parser/xerces/elements.txx
@@ -95,7 +95,7 @@ namespace xsd
error_handler<C> eh;
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (uri, eh_proxy, *sax, f, p);
@@ -124,7 +124,7 @@ namespace xsd
xml::auto_initializer init ((f & flags::dont_initialize) == 0);
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (uri, eh_proxy, *sax, f, p);
@@ -153,7 +153,7 @@ namespace xsd
const properties<C>& p)
{
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (uri, eh_proxy, *sax, f, p);
@@ -390,7 +390,7 @@ namespace xsd
{
error_handler<C> eh;
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (is, eh_proxy, *sax, f, p);
@@ -405,7 +405,7 @@ namespace xsd
const properties<C>& p)
{
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (is, eh_proxy, *sax, f, p);
@@ -421,7 +421,7 @@ namespace xsd
const properties<C>& p)
{
xml::sax::bits::error_handler_proxy<C> eh_proxy (eh);
- std::auto_ptr<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> sax (create_sax_ (f, p));
parse (is, eh_proxy, *sax, f, p);
@@ -569,12 +569,12 @@ namespace xsd
template <typename C>
- std::auto_ptr<xercesc::SAX2XMLReader> document<C>::
+ XSD_AUTO_PTR<xercesc::SAX2XMLReader> document<C>::
create_sax_ (flags f, const properties<C>& p)
{
using namespace xercesc;
- std::auto_ptr<SAX2XMLReader> sax (
+ XSD_AUTO_PTR<SAX2XMLReader> sax (
XMLReaderFactory::createXMLReader ());
sax->setFeature (XMLUni::fgSAX2CoreNameSpaces, true);
diff --git a/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx b/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
index 50c19d6..03e2409 100644
--- a/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
+++ b/libxsd/xsd/cxx/tree/ace-cdr-stream-extraction.hxx
@@ -12,7 +12,13 @@
#include <ace/ACE.h> // ACE::strdelete
#include <ace/CDR_Stream.h>
-#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/tree/buffer.hxx>
#include <xsd/cxx/tree/istream.hxx>
@@ -258,11 +264,11 @@ namespace xsd
namespace bits
{
- template<typename C>
- struct ace_str_deallocator
+ template <typename C>
+ struct ace_str_deleter
{
void
- deallocate (C* s)
+ operator() (C* s) const
{
ACE::strdelete (s);
}
@@ -272,18 +278,22 @@ namespace xsd
inline istream<ACE_InputCDR>&
operator>> (istream<ACE_InputCDR>& s, std::basic_string<char>& x)
{
- typedef bits::ace_str_deallocator<char> deallocator;
+ typedef bits::ace_str_deleter<char> deleter;
- deallocator d;
+ deleter d;
char* r;
if (!s.impl ().read_string (r))
throw ace_cdr_stream_extraction ();
- auto_array<char, deallocator> ar (r, d);
+#ifdef XSD_CXX11
+ std::unique_ptr<char[], deleter&> ar (
+#else
+ auto_array<char, deleter> ar (
+#endif
+ r, d);
x = r;
-
return s;
}
@@ -291,18 +301,22 @@ namespace xsd
inline istream<ACE_InputCDR>&
operator>> (istream<ACE_InputCDR>& s, std::basic_string<wchar_t>& x)
{
- typedef bits::ace_str_deallocator<wchar_t> deallocator;
+ typedef bits::ace_str_deleter<wchar_t> deleter;
- deallocator d;
+ deleter d;
wchar_t* r;
if (!s.impl ().read_wstring (r))
throw ace_cdr_stream_extraction ();
- auto_array<wchar_t, deallocator> ar (r, d);
+#ifdef XSD_CXX11
+ std::unique_ptr<wchar_t[], deleter&> ar (
+#else
+ auto_array<wchar_t, deleter> ar (
+#endif
+ r, d);
x = r;
-
return s;
}
#endif
diff --git a/libxsd/xsd/cxx/tree/containers.hxx b/libxsd/xsd/cxx/tree/containers.hxx
index e6b9f88..1b959cb 100644
--- a/libxsd/xsd/cxx/tree/containers.hxx
+++ b/libxsd/xsd/cxx/tree/containers.hxx
@@ -9,11 +9,13 @@
#include <cstddef> // std::ptrdiff_t
#include <string>
#include <vector>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <iterator> // std::iterator_traits
#include <algorithm> // std::equal, std::lexicographical_compare
#include <iosfwd>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/tree/elements.hxx>
namespace xsd
@@ -136,7 +138,7 @@ namespace xsd
one (const T&, container*);
- one (std::auto_ptr<T>, container*);
+ one (XSD_AUTO_PTR<T>, container*);
one (const one&, flags, container*);
@@ -163,7 +165,7 @@ namespace xsd
}
void
- set (std::auto_ptr<T>);
+ set (XSD_AUTO_PTR<T>);
bool
present () const
@@ -171,13 +173,13 @@ namespace xsd
return x_ != 0;
}
- std::auto_ptr<T>
+ XSD_AUTO_PTR<T>
detach ()
{
T* x (x_);
x->_container (0);
x_ = 0;
- return std::auto_ptr<T> (x);
+ return XSD_AUTO_PTR<T> (x);
}
protected:
@@ -268,7 +270,7 @@ namespace xsd
optional (const T&, container* = 0);
explicit
- optional (std::auto_ptr<T>, container* = 0);
+ optional (XSD_AUTO_PTR<T>, container* = 0);
optional (const optional&, flags = 0, container* = 0);
@@ -341,18 +343,18 @@ namespace xsd
}
void
- set (std::auto_ptr<T>);
+ set (XSD_AUTO_PTR<T>);
void
reset ();
- std::auto_ptr<T>
+ XSD_AUTO_PTR<T>
detach ()
{
T* x (x_);
x->_container (0);
x_ = 0;
- return std::auto_ptr<T> (x);
+ return XSD_AUTO_PTR<T> (x);
}
protected:
@@ -1266,7 +1268,7 @@ namespace xsd
}
void
- push_back (std::auto_ptr<T> x)
+ push_back (XSD_AUTO_PTR<T> x)
{
if (x->_container () != container_)
x->_container (container_);
@@ -1280,7 +1282,7 @@ namespace xsd
v_.pop_back ();
}
- std::auto_ptr<T>
+ XSD_AUTO_PTR<T>
detach_back (bool pop = true)
{
ptr& p (v_.back ());
@@ -1290,7 +1292,7 @@ namespace xsd
if (pop)
v_.pop_back ();
- return std::auto_ptr<T> (x);
+ return XSD_AUTO_PTR<T> (x);
}
iterator
@@ -1302,7 +1304,7 @@ namespace xsd
}
iterator
- insert (iterator position, std::auto_ptr<T> x)
+ insert (iterator position, XSD_AUTO_PTR<T> x)
{
if (x->_container () != container_)
x->_container (container_);
@@ -1336,12 +1338,11 @@ namespace xsd
}
iterator
- detach (iterator position, std::auto_ptr<T>& r, bool erase = true)
+ detach (iterator position, XSD_AUTO_PTR<T>& r, bool erase = true)
{
ptr& p (*position.base ());
p->_container (0);
- std::auto_ptr<T> tmp (static_cast<T*> (p.release ()));
- r = tmp;
+ r.reset (static_cast<T*> (p.release ()));
if (erase)
return iterator (v_.erase (position.base ()));
diff --git a/libxsd/xsd/cxx/tree/containers.txx b/libxsd/xsd/cxx/tree/containers.txx
index a27af48..7e45a02 100644
--- a/libxsd/xsd/cxx/tree/containers.txx
+++ b/libxsd/xsd/cxx/tree/containers.txx
@@ -4,6 +4,11 @@
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <ostream>
+
+#ifdef XSD_CXX11
+# include <utility> // std::move
+#endif
+
#include <xsd/cxx/tree/bits/literals.hxx>
namespace xsd
@@ -38,10 +43,14 @@ namespace xsd
template<typename T>
one<T, false>::
- one (std::auto_ptr<T> x, container* c)
+ one (XSD_AUTO_PTR<T> x, container* c)
: x_ (0), container_ (c)
{
+#ifdef XSD_CXX11
+ set (std::move (x));
+#else
set (x);
+#endif
}
template<typename T>
@@ -86,7 +95,7 @@ namespace xsd
template<typename T>
void one<T, false>::
- set (std::auto_ptr<T> x)
+ set (XSD_AUTO_PTR<T> x)
{
T* r (0);
@@ -128,10 +137,14 @@ namespace xsd
template <typename T>
optional<T, false>::
- optional (std::auto_ptr<T> x, container* c)
+ optional (XSD_AUTO_PTR<T> x, container* c)
: x_ (0), container_ (c)
{
+#ifdef XSD_CXX11
+ set (std::move (x));
+#else
set (x);
+#endif
}
template <typename T>
@@ -185,7 +198,7 @@ namespace xsd
template <typename T>
void optional<T, false>::
- set (std::auto_ptr<T> x)
+ set (XSD_AUTO_PTR<T> x)
{
T* r (0);
diff --git a/libxsd/xsd/cxx/tree/element-map.hxx b/libxsd/xsd/cxx/tree/element-map.hxx
index debfaed..b00bdbd 100644
--- a/libxsd/xsd/cxx/tree/element-map.hxx
+++ b/libxsd/xsd/cxx/tree/element-map.hxx
@@ -7,10 +7,12 @@
#define XSD_CXX_TREE_ELEMENT_MAP_HXX
#include <map>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <cstddef> // std::size_t
#include <string>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/xml/qualified-name.hxx>
#include <xsd/cxx/tree/elements.hxx>
@@ -44,7 +46,7 @@ namespace xsd
* @param f Flags to create the new element object with.
* @return An automatic pointer to the new element object.
*/
- static std::auto_ptr<element_type>
+ static XSD_AUTO_PTR<element_type>
parse (const xercesc::DOMElement& e, flags f = 0);
/**
@@ -61,7 +63,7 @@ namespace xsd
typedef xml::qualified_name<C> qualified_name;
- typedef std::auto_ptr<element_type>
+ typedef XSD_AUTO_PTR<element_type>
(*parser) (const xercesc::DOMElement&, flags f);
typedef void
@@ -113,7 +115,7 @@ namespace xsd
//
//
template<typename T, typename C, typename B>
- std::auto_ptr<element_type<C, B> >
+ XSD_AUTO_PTR<element_type<C, B> >
parser_impl (const xercesc::DOMElement&, flags);
template<typename T, typename C, typename B>
diff --git a/libxsd/xsd/cxx/tree/elements.hxx b/libxsd/xsd/cxx/tree/elements.hxx
index 17ad70c..396e880 100644
--- a/libxsd/xsd/cxx/tree/elements.hxx
+++ b/libxsd/xsd/cxx/tree/elements.hxx
@@ -17,13 +17,19 @@
#ifndef XSD_CXX_TREE_ELEMENTS_HXX
#define XSD_CXX_TREE_ELEMENTS_HXX
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR, XSD_CXX11
+
#include <map>
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <istream>
#include <sstream>
#include <cassert>
+#ifdef XSD_CXX11
+# include <utility> // std::move
+#endif
+
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/dom/DOMElement.hpp>
@@ -33,7 +39,7 @@
#include <xercesc/util/XercesVersion.hpp>
#include <xsd/cxx/xml/elements.hxx> // xml::properties
-#include <xsd/cxx/xml/dom/auto-ptr.hxx> // dom::auto_ptr
+#include <xsd/cxx/xml/dom/auto-ptr.hxx> // dom::auto_ptr/unique_ptr
#include <xsd/cxx/tree/facet.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
@@ -83,7 +89,7 @@ namespace xsd
*
* This flag only makes sense together with the @c keep_dom
* flag in the call to the %parsing function with the
- * @c dom::auto_ptr<DOMDocument> argument.
+ * @c dom::auto_ptr/unique_ptr<DOMDocument> argument.
*
*/
static const unsigned long own_dom = 0x00000200UL;
@@ -386,11 +392,7 @@ namespace xsd
{
// Drop DOM association.
//
- if (dom_info_.get ())
- {
- std::auto_ptr<dom_info> r (0);
- dom_info_ = r;
- }
+ dom_info_.reset ();
}
return *this;
@@ -444,7 +446,7 @@ namespace xsd
dr = c;
}
- std::auto_ptr<map>& m (dr ? dr->map_ : map_);
+ XSD_AUTO_PTR<map>& m (dr ? dr->map_ : map_);
if (container_ == 0)
{
@@ -455,11 +457,16 @@ namespace xsd
if (m.get () != 0)
{
m->insert (map_->begin (), map_->end ());
- std::auto_ptr<map> tmp (0);
- map_ = tmp;
+ map_.reset ();
}
else
+ {
+#ifdef XSD_CXX11
+ m = std::move (map_);
+#else
m = map_;
+#endif
+ }
}
}
else
@@ -481,10 +488,7 @@ namespace xsd
// Part of our subtree.
//
if (m.get () == 0)
- {
- std::auto_ptr<map> tmp (new map);
- m = tmp;
- }
+ m.reset (new map);
m->insert (*i);
sr->map_->erase (i++);
@@ -599,37 +603,31 @@ namespace xsd
{
if (container_ != 0)
{
- // @@ Should be a throw.
- //
assert (_root ()->_node () != 0);
assert (_root ()->_node ()->getOwnerDocument () ==
n->getOwnerDocument ());
}
- std::auto_ptr<dom_info> r (
+ dom_info_ =
dom_info_factory::create (
*static_cast<xercesc::DOMElement*> (n),
*this,
- container_ == 0));
+ container_ == 0);
- dom_info_ = r;
break;
}
case xercesc::DOMNode::ATTRIBUTE_NODE:
{
- //@@ Should be a throw.
- //
assert (container_ != 0);
assert (_root ()->_node () != 0);
assert (_root ()->_node ()->getOwnerDocument () ==
n->getOwnerDocument ());
- std::auto_ptr<dom_info> r (
+ dom_info_ =
dom_info_factory::create (
*static_cast<xercesc::DOMAttr*> (n),
- *this));
+ *this);
- dom_info_ = r;
break;
}
default:
@@ -650,10 +648,7 @@ namespace xsd
assert (container_ == 0);
if (map_.get () == 0)
- {
- std::auto_ptr<map> tmp (new map);
- map_ = tmp;
- }
+ map_.reset (new map);
if (!map_->insert (
std::pair<const identity*, type*> (&i, t)).second)
@@ -714,7 +709,7 @@ namespace xsd
{
}
- virtual std::auto_ptr<dom_info>
+ virtual XSD_AUTO_PTR<dom_info>
clone (type& tree_node, container*) const = 0;
virtual xercesc::DOMNode*
@@ -731,32 +726,35 @@ namespace xsd
struct dom_element_info: public dom_info
{
dom_element_info (xercesc::DOMElement& e, type& n, bool root)
- : doc_ (0), e_ (e)
+ : e_ (e)
{
e_.setUserData (user_data_keys::node, &n, 0);
if (root)
{
- // The caller should have associated a dom::auto_ptr object
- // that owns this document with the document node using the
- // xml_schema::dom::tree_node_key key.
+ // The caller should have associated a dom::auto/unique_ptr
+ // object that owns this document with the document node
+ // using the xml_schema::dom::tree_node_key key.
//
- xml::dom::auto_ptr<xercesc::DOMDocument>* pd (
- reinterpret_cast<xml::dom::auto_ptr<xercesc::DOMDocument>*> (
+ XSD_DOM_AUTO_PTR<xercesc::DOMDocument>* pd (
+ reinterpret_cast<XSD_DOM_AUTO_PTR<xercesc::DOMDocument>*> (
e.getOwnerDocument ()->getUserData (user_data_keys::node)));
assert (pd != 0);
assert (pd->get () == e.getOwnerDocument ());
- doc_ = *pd; // Transfer ownership.
+ // Transfer ownership.
+#ifdef XSD_CXX11
+ doc_ = std::move (*pd);
+#else
+ doc_ = *pd;
+#endif
}
}
- virtual std::auto_ptr<dom_info>
+ virtual XSD_AUTO_PTR<dom_info>
clone (type& tree_node, container* c) const
{
- using std::auto_ptr;
-
// Check if we are a document root.
//
if (c == 0)
@@ -764,11 +762,10 @@ namespace xsd
// We preserver DOM associations only in complete
// copies from root.
//
- if (doc_.get () == 0)
- return auto_ptr<dom_info> (0);
-
- return auto_ptr<dom_info> (
- new dom_element_info (*doc_, tree_node));
+ return XSD_AUTO_PTR<dom_info> (
+ doc_.get () == 0
+ ? 0
+ : new dom_element_info (*doc_, tree_node));
}
// Check if our container does not have DOM association (e.g.,
@@ -779,8 +776,7 @@ namespace xsd
DOMNode* cn (c->_node ());
if (cn == 0)
- return auto_ptr<dom_info> (0);
-
+ return XSD_AUTO_PTR<dom_info> ();
// Now we are going to find the corresponding element in
// the new tree.
@@ -812,7 +808,7 @@ namespace xsd
assert (dn->getNodeType () == DOMNode::ELEMENT_NODE);
- return auto_ptr<dom_info> (
+ return XSD_AUTO_PTR<dom_info> (
new dom_element_info (static_cast<DOMElement&> (*dn),
tree_node,
false));
@@ -835,7 +831,7 @@ namespace xsd
}
private:
- xml::dom::auto_ptr<xercesc::DOMDocument> doc_;
+ XSD_DOM_AUTO_PTR<xercesc::DOMDocument> doc_;
xercesc::DOMElement& e_;
};
@@ -848,11 +844,9 @@ namespace xsd
a_.setUserData (user_data_keys::node, &n, 0);
}
- virtual std::auto_ptr<dom_info>
+ virtual XSD_AUTO_PTR<dom_info>
clone (type& tree_node, container* c) const
{
- using std::auto_ptr;
-
// Check if we are a document root.
//
if (c == 0)
@@ -860,7 +854,7 @@ namespace xsd
// We preserver DOM associations only in complete
// copies from root.
//
- return auto_ptr<dom_info> (0);
+ return XSD_AUTO_PTR<dom_info> ();
}
// Check if our container does not have DOM association (e.g.,
@@ -871,7 +865,7 @@ namespace xsd
DOMNode* cn (c->_node ());
if (cn == 0)
- return auto_ptr<dom_info> (0);
+ return XSD_AUTO_PTR<dom_info> ();
// We are going to find the corresponding attribute in
// the new tree.
@@ -898,7 +892,7 @@ namespace xsd
DOMNode& n (*cn->getAttributes ()->item (i));
assert (n.getNodeType () == DOMNode::ATTRIBUTE_NODE);
- return auto_ptr<dom_info> (
+ return XSD_AUTO_PTR<dom_info> (
new dom_attribute_info (static_cast<DOMAttr&> (n), tree_node));
}
@@ -919,18 +913,18 @@ namespace xsd
struct dom_info_factory
{
- static std::auto_ptr<dom_info>
+ static XSD_AUTO_PTR<dom_info>
create (const xercesc::DOMElement& e, type& n, bool root)
{
- return std::auto_ptr<dom_info> (
+ return XSD_AUTO_PTR<dom_info> (
new dom_element_info (
const_cast<xercesc::DOMElement&> (e), n, root));
}
- static std::auto_ptr<dom_info>
+ static XSD_AUTO_PTR<dom_info>
create (const xercesc::DOMAttr& a, type& n)
{
- return std::auto_ptr<dom_info> (
+ return XSD_AUTO_PTR<dom_info> (
new dom_attribute_info (
const_cast<xercesc::DOMAttr&> (a), n));
}
@@ -938,7 +932,7 @@ namespace xsd
//@endcond
- std::auto_ptr<dom_info> dom_info_;
+ XSD_AUTO_PTR<dom_info> dom_info_;
// ID/IDREF map.
@@ -961,7 +955,7 @@ namespace xsd
std::map<const identity*, type*, identity_comparator>
map;
- std::auto_ptr<map> map_;
+ XSD_AUTO_PTR<map> map_;
private:
container* container_;
@@ -973,8 +967,7 @@ namespace xsd
{
if (x.dom_info_.get () != 0 && (f & flags::keep_dom))
{
- std::auto_ptr<dom_info> r (x.dom_info_->clone (*this, c));
- dom_info_ = r;
+ dom_info_ = x.dom_info_->clone (*this, c);
}
}
@@ -1183,25 +1176,25 @@ namespace xsd
{
typedef T type;
- static std::auto_ptr<T>
+ static XSD_AUTO_PTR<T>
create (const xercesc::DOMElement& e, flags f, container* c)
{
- return std::auto_ptr<T> (new T (e, f, c));
+ return XSD_AUTO_PTR<T> (new T (e, f, c));
}
- static std::auto_ptr<T>
+ static XSD_AUTO_PTR<T>
create (const xercesc::DOMAttr& a, flags f, container* c)
{
- return std::auto_ptr<T> (new T (a, f, c));
+ return XSD_AUTO_PTR<T> (new T (a, f, c));
}
- static std::auto_ptr<T>
+ static XSD_AUTO_PTR<T>
create (const std::basic_string<C>& s,
const xercesc::DOMElement* e,
flags f,
container* c)
{
- return std::auto_ptr<T> (new T (s, e, f, c));
+ return XSD_AUTO_PTR<T> (new T (s, e, f, c));
}
};
diff --git a/libxsd/xsd/cxx/tree/istream.hxx b/libxsd/xsd/cxx/tree/istream.hxx
index b76fdcb..1ff2bd8 100644
--- a/libxsd/xsd/cxx/tree/istream.hxx
+++ b/libxsd/xsd/cxx/tree/istream.hxx
@@ -8,9 +8,11 @@
#include <map>
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <cstddef> // std::size_t
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/tree/istream-fwd.hxx>
namespace xsd
@@ -236,7 +238,7 @@ namespace xsd
S& s_;
std::size_t seq_;
- std::auto_ptr<pool> pool_;
+ XSD_AUTO_PTR<pool> pool_;
};
diff --git a/libxsd/xsd/cxx/tree/ostream.hxx b/libxsd/xsd/cxx/tree/ostream.hxx
index 7d8711e..fde681e 100644
--- a/libxsd/xsd/cxx/tree/ostream.hxx
+++ b/libxsd/xsd/cxx/tree/ostream.hxx
@@ -8,9 +8,11 @@
#include <map>
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <cstddef> // std::size_t
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
namespace xsd
{
namespace cxx
@@ -187,7 +189,7 @@ namespace xsd
S& s_;
std::size_t seq_;
- std::auto_ptr<pool> pool_;
+ XSD_AUTO_PTR<pool> pool_;
};
diff --git a/libxsd/xsd/cxx/tree/parsing.txx b/libxsd/xsd/cxx/tree/parsing.txx
index e8bca99..14af025 100644
--- a/libxsd/xsd/cxx/tree/parsing.txx
+++ b/libxsd/xsd/cxx/tree/parsing.txx
@@ -35,25 +35,18 @@ namespace xsd
//
inline _type::
_type (const xercesc::DOMElement& e, flags f, container* c)
- : dom_info_ (0), container_ (c)
+ : container_ (c)
{
if (f & flags::keep_dom)
- {
- std::auto_ptr<dom_info> r (
- dom_info_factory::create (e, *this, c == 0));
- dom_info_ = r;
- }
+ dom_info_ = dom_info_factory::create (e, *this, c == 0);
}
inline _type::
_type (const xercesc::DOMAttr& a, flags f, container* c)
- : dom_info_ (0), container_ (c)
+ : container_ (c)
{
if (f & flags::keep_dom)
- {
- std::auto_ptr<dom_info> r (dom_info_factory::create (a, *this));
- dom_info_ = r;
- }
+ dom_info_ = dom_info_factory::create (a, *this);
}
template <typename C>
@@ -62,8 +55,7 @@ namespace xsd
const xercesc::DOMElement*,
flags,
container* c)
- : dom_info_ (0), // List elements don't have associated DOM nodes.
- container_ (c)
+ : container_ (c) // List elements don't have associated DOM nodes.
{
}
diff --git a/libxsd/xsd/cxx/tree/parsing/element-map.txx b/libxsd/xsd/cxx/tree/parsing/element-map.txx
index 71f23a8..a284c39 100644
--- a/libxsd/xsd/cxx/tree/parsing/element-map.txx
+++ b/libxsd/xsd/cxx/tree/parsing/element-map.txx
@@ -17,7 +17,7 @@ namespace xsd
namespace tree
{
template <typename C, typename T>
- std::auto_ptr<element_type<C, T> > element_map<C, T>::
+ XSD_AUTO_PTR<element_type<C, T> > element_map<C, T>::
parse (const xercesc::DOMElement& e, flags f)
{
const qualified_name n (xml::dom::name<C> (e));
@@ -30,10 +30,10 @@ namespace xsd
}
template<typename T, typename C, typename B>
- std::auto_ptr<element_type<C, B> >
+ XSD_AUTO_PTR<element_type<C, B> >
parser_impl (const xercesc::DOMElement& e, flags f)
{
- return std::auto_ptr<element_type<C, B> > (new T (e, f));
+ return XSD_AUTO_PTR<element_type<C, B> > (new T (e, f));
}
}
}
diff --git a/libxsd/xsd/cxx/tree/stream-extraction-map.hxx b/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
index 1c18d51..245d786 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
+++ b/libxsd/xsd/cxx/tree/stream-extraction-map.hxx
@@ -7,9 +7,11 @@
#define XSD_CXX_TREE_STREAM_EXTRACTION_MAP_HXX
#include <map>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <cstddef> // std::size_t
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/tree/istream.hxx>
#include <xsd/cxx/xml/qualified-name.hxx>
@@ -24,7 +26,7 @@ namespace xsd
struct stream_extraction_map
{
typedef xml::qualified_name<C> qualified_name;
- typedef std::auto_ptr<type> (*extractor) (
+ typedef XSD_AUTO_PTR<type> (*extractor) (
istream<S>&, flags, container*);
public:
@@ -38,7 +40,7 @@ namespace xsd
void
unregister_type (const qualified_name& name);
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
extract (istream<S>&, flags, container*);
public:
@@ -82,7 +84,7 @@ namespace xsd
//
//
template<typename S, typename T>
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
extractor_impl (istream<S>&, flags, container*);
diff --git a/libxsd/xsd/cxx/tree/stream-extraction-map.txx b/libxsd/xsd/cxx/tree/stream-extraction-map.txx
index 17b3fc5..156f9c0 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction-map.txx
+++ b/libxsd/xsd/cxx/tree/stream-extraction-map.txx
@@ -233,7 +233,7 @@ namespace xsd
}
template <typename S, typename C>
- std::auto_ptr<type> stream_extraction_map<S, C>::
+ XSD_AUTO_PTR<type> stream_extraction_map<S, C>::
extract (istream<S>& s, flags f, container* c)
{
std::basic_string<C> ns, name;
@@ -303,10 +303,10 @@ namespace xsd
//
//
template<typename S, typename T>
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
extractor_impl (istream<S>& s, flags f, container* c)
{
- return std::auto_ptr<type> (new T (s, f, c));
+ return XSD_AUTO_PTR<type> (new T (s, f, c));
}
diff --git a/libxsd/xsd/cxx/tree/stream-extraction.hxx b/libxsd/xsd/cxx/tree/stream-extraction.hxx
index eef60ca..e4a1740 100644
--- a/libxsd/xsd/cxx/tree/stream-extraction.hxx
+++ b/libxsd/xsd/cxx/tree/stream-extraction.hxx
@@ -67,8 +67,7 @@ namespace xsd
while (size--)
{
- std::auto_ptr<T> p (new T (s, f, c));
- this->push_back (p);
+ this->push_back (XSD_AUTO_PTR<T> (new T (s, f, c)));
}
}
}
diff --git a/libxsd/xsd/cxx/tree/type-factory-map.hxx b/libxsd/xsd/cxx/tree/type-factory-map.hxx
index a42ef96..ea173cc 100644
--- a/libxsd/xsd/cxx/tree/type-factory-map.hxx
+++ b/libxsd/xsd/cxx/tree/type-factory-map.hxx
@@ -8,11 +8,13 @@
#include <map>
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::auto_ptr/unique_ptr
#include <cstddef> // std::size_t
#include <xercesc/dom/DOMElement.hpp>
+#include <xsd/cxx/config.hxx> // XSD_AUTO_PTR
+
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/xml/qualified-name.hxx>
@@ -26,9 +28,9 @@ namespace xsd
struct type_factory_map
{
typedef xml::qualified_name<C> qualified_name;
- typedef std::auto_ptr<type> (*factory) (const xercesc::DOMElement&,
- flags,
- container*);
+ typedef XSD_AUTO_PTR<type> (*factory) (const xercesc::DOMElement&,
+ flags,
+ container*);
public:
type_factory_map ();
@@ -49,7 +51,7 @@ namespace xsd
unregister_element (const qualified_name& root,
const qualified_name& subst);
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
create (const C* name, // element name
const C* ns, // element namespace
factory static_type,
@@ -66,7 +68,7 @@ namespace xsd
private:
template <typename T>
- static std::auto_ptr<type>
+ static XSD_AUTO_PTR<type>
traits_adapter (const xercesc::DOMElement&, flags, container*);
private:
@@ -132,7 +134,7 @@ namespace xsd
//
//
template<typename T>
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
factory_impl (const xercesc::DOMElement&, flags, container*);
//
diff --git a/libxsd/xsd/cxx/tree/type-factory-map.txx b/libxsd/xsd/cxx/tree/type-factory-map.txx
index 998fb7b..174147c 100644
--- a/libxsd/xsd/cxx/tree/type-factory-map.txx
+++ b/libxsd/xsd/cxx/tree/type-factory-map.txx
@@ -273,7 +273,7 @@ namespace xsd
}
template <typename C>
- std::auto_ptr<type> type_factory_map<C>::
+ XSD_AUTO_PTR<type> type_factory_map<C>::
create (const C* name,
const C* ns,
factory static_type,
@@ -307,7 +307,7 @@ namespace xsd
}
if (f == 0)
- return std::auto_ptr<type> (0); // No match.
+ return XSD_AUTO_PTR<type> (); // No match.
// Check for xsi:type
//
@@ -326,11 +326,10 @@ namespace xsd
template <typename C>
template <typename T>
- std::auto_ptr<type> type_factory_map<C>::
+ XSD_AUTO_PTR<type> type_factory_map<C>::
traits_adapter (const xercesc::DOMElement& e, flags f, container* c)
{
- std::auto_ptr<T> r (traits<T, C>::create (e, f, c));
- return std::auto_ptr<type> (r.release ());
+ return XSD_AUTO_PTR<type> (traits<T, C>::create (e, f, c));
}
template <typename C>
@@ -428,10 +427,10 @@ namespace xsd
//
//
template<typename T>
- std::auto_ptr<type>
+ XSD_AUTO_PTR<type>
factory_impl (const xercesc::DOMElement& e, flags f, container* c)
{
- return std::auto_ptr<type> (new T (e, f, c));
+ return XSD_AUTO_PTR<type> (new T (e, f, c));
}
//
diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.hxx b/libxsd/xsd/cxx/tree/type-serializer-map.hxx
index 0ac9299..ca52129 100644
--- a/libxsd/xsd/cxx/tree/type-serializer-map.hxx
+++ b/libxsd/xsd/cxx/tree/type-serializer-map.hxx
@@ -16,6 +16,7 @@
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/xml/qualified-name.hxx>
+#include <xsd/cxx/xml/dom/auto-ptr.hxx>
#include <xsd/cxx/xml/dom/serialization-header.hxx> // namespace_infomap
namespace xsd
@@ -70,7 +71,7 @@ namespace xsd
// Create DOMDocument with root element suitable for serializing
// x into it.
//
- xml::dom::auto_ptr<xercesc::DOMDocument>
+ XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
serialize (const C* name, // element name
const C* ns, // element namespace
const xml::dom::namespace_infomap<C>&,
diff --git a/libxsd/xsd/cxx/tree/type-serializer-map.txx b/libxsd/xsd/cxx/tree/type-serializer-map.txx
index 1dd1e52..454282e 100644
--- a/libxsd/xsd/cxx/tree/type-serializer-map.txx
+++ b/libxsd/xsd/cxx/tree/type-serializer-map.txx
@@ -399,7 +399,7 @@ namespace xsd
}
template <typename C>
- xml::dom::auto_ptr<xercesc::DOMDocument> type_serializer_map<C>::
+ XSD_DOM_AUTO_PTR<xercesc::DOMDocument> type_serializer_map<C>::
serialize (const C* name,
const C* ns,
const xml::dom::namespace_infomap<C>& m,
diff --git a/libxsd/xsd/cxx/tree/types.txx b/libxsd/xsd/cxx/tree/types.txx
index 98fcf81..61cb419 100644
--- a/libxsd/xsd/cxx/tree/types.txx
+++ b/libxsd/xsd/cxx/tree/types.txx
@@ -6,7 +6,13 @@
#include <xercesc/util/Base64.hpp>
#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>
@@ -318,9 +324,13 @@ namespace xsd
std::basic_string<C> str;
XMLSize_t n;
-
xml::std_memory_manager mm;
+
+#ifdef XSD_CXX11
+ std::unique_ptr<XMLByte[], xml::std_memory_manager&> r (
+#else
auto_array<XMLByte, xml::std_memory_manager> r (
+#endif
Base64::encode (
reinterpret_cast<const XMLByte*> (this->data ()),
static_cast<XMLSize_t> (this->size ()),
@@ -353,9 +363,13 @@ namespace xsd
xml::std_memory_manager mm;
XMLSize_t size;
+#ifdef XSD_CXX11
+ std::unique_ptr<XMLByte[], xml::std_memory_manager&> data (
+#else
auto_array<XMLByte, xml::std_memory_manager> data (
+#endif
Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045),
- mm);
+ mm);
if (data)
{
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)