diff options
Diffstat (limited to 'xsd/libxsd/xsd/cxx/parser/expat')
-rw-r--r-- | xsd/libxsd/xsd/cxx/parser/expat/elements.hxx | 30 | ||||
-rw-r--r-- | xsd/libxsd/xsd/cxx/parser/expat/elements.txx | 11 |
2 files changed, 29 insertions, 12 deletions
diff --git a/xsd/libxsd/xsd/cxx/parser/expat/elements.hxx b/xsd/libxsd/xsd/cxx/parser/expat/elements.hxx index c9f3de0..86e7a73 100644 --- a/xsd/libxsd/xsd/cxx/parser/expat/elements.hxx +++ b/xsd/libxsd/xsd/cxx/parser/expat/elements.hxx @@ -1,16 +1,21 @@ // file : xsd/cxx/parser/expat/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_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 +40,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 +79,8 @@ namespace xsd return *this; } - public: - operator XML_Parser () + XML_Parser + get () const { return parser_; } @@ -76,12 +94,12 @@ namespace xsd private: XML_Parser parser_; }; - +#endif // XSD_CXX11 // // template <typename C> - struct document: cxx::parser::document<C> // VC 7.1 likes it qualified + struct document: cxx::parser::document<C> // VC likes it qualified { public: document (parser_base<C>&, diff --git a/xsd/libxsd/xsd/cxx/parser/expat/elements.txx b/xsd/libxsd/xsd/cxx/parser/expat/elements.txx index 08ecf21..d3fc0d9 100644 --- a/xsd/libxsd/xsd/cxx/parser/expat/elements.txx +++ b/xsd/libxsd/xsd/cxx/parser/expat/elements.txx @@ -1,6 +1,5 @@ // file : xsd/cxx/parser/expat/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 <new> // std::bad_alloc @@ -334,18 +333,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_, |