aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/parser
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-01-19 10:05:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-01-19 10:06:32 +0200
commit0fdf19714613a82a184f4f6e75fb9a4f9b62f18a (patch)
tree93bb2df0f9d9eab44d36dedf29d4df500ecefcbc /libxsd/xsd/cxx/parser
parent45db924dfc19b49b7930522dbddd123fb9575e32 (diff)
Use std::unique_ptr instead of std::auto_ptr in C++11 mode
Diffstat (limited to 'libxsd/xsd/cxx/parser')
-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
10 files changed, 76 insertions, 35 deletions
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);