summaryrefslogtreecommitdiff
path: root/xsd/libxsd/xsd/cxx/tree/types.txx
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/libxsd/xsd/cxx/tree/types.txx')
-rw-r--r--xsd/libxsd/xsd/cxx/tree/types.txx114
1 files changed, 20 insertions, 94 deletions
diff --git a/xsd/libxsd/xsd/cxx/tree/types.txx b/xsd/libxsd/xsd/cxx/tree/types.txx
index 8d6d79f..8696171 100644
--- a/xsd/libxsd/xsd/cxx/tree/types.txx
+++ b/xsd/libxsd/xsd/cxx/tree/types.txx
@@ -1,13 +1,17 @@
// file : xsd/cxx/tree/types.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/Base64.hpp>
#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/XercesVersion.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>
@@ -168,11 +172,6 @@ namespace xsd
return *this;
}
- // It would have been cleaner to mention empty and _container
- // with the using-declaration but HP aCC3 can't handle it in
- // some non-trivial to track down cases. So we are going to use
- // the old-n-ugly this-> techniques.
- //
template <typename C, typename B>
void id<C, B>::
_container (container* c)
@@ -211,11 +210,6 @@ namespace xsd
return new idref (*this, f, c);
}
- // It would have been cleaner to mention empty, _root, etc. with
- // the using-declaration but HP aCC3 can't handle it in some
- // non-trivial to track down cases. So we are going to use the
- // old-n-ugly this-> techniques.
- //
template <typename C, typename B, typename T>
const _type* idref<C, B, T>::
get_ () const
@@ -321,52 +315,24 @@ namespace xsd
return new base64_binary (*this, f, c);
}
- // It would have been cleaner to mention size, and data with the
- // using-declaration but HP aCC3 can't handle it in some non-
- // trivial to track down cases. So we are going to use the
- // old-n- ugly this-> techniques.
- //
template <typename C, typename B>
std::basic_string<C> base64_binary<C, B>::
encode () const
{
- // HP aCC3 cannot handle using namespace xercesc;
- //
- using xercesc::Base64;
+ using namespace xercesc;
std::basic_string<C> str;
-#if _XERCES_VERSION >= 30000
XMLSize_t n;
-
xml::std_memory_manager mm;
- auto_array<XMLByte, xml::std_memory_manager> r (
- Base64::encode (
- reinterpret_cast<const XMLByte*> (this->data ()),
- static_cast<XMLSize_t> (this->size ()),
- &n,
- &mm),
- mm);
- if (r)
- {
- str.reserve (n + 1);
- str.resize (n);
-
- for (XMLSize_t i (0); i < n; ++i)
- str[i] = C (r[i]);
- }
- else
- {
- //@@ throw
- }
+#ifdef XSD_CXX11
+ std::unique_ptr<XMLByte[], xml::std_memory_manager&> r (
#else
- unsigned int n;
-
- xml::std_memory_manager mm;
auto_array<XMLByte, xml::std_memory_manager> r (
+#endif
Base64::encode (
reinterpret_cast<const XMLByte*> (this->data ()),
- static_cast<unsigned int> (this->size ()),
+ static_cast<XMLSize_t> (this->size ()),
&n,
&mm),
mm);
@@ -376,14 +342,13 @@ namespace xsd
str.reserve (n + 1);
str.resize (n);
- for (unsigned int i (0); i < n; ++i)
+ for (XMLSize_t i (0); i < n; ++i)
str[i] = C (r[i]);
}
else
{
//@@ throw
}
-#endif
return str;
}
@@ -392,28 +357,18 @@ namespace xsd
void base64_binary<C, B>::
decode (const XMLCh* src)
{
- // HP aCC3 cannot handle using namespace xercesc;
- //
- using xercesc::Base64;
+ using namespace xercesc;
xml::std_memory_manager mm;
-
- // Xerces 2.6.0 and earlier do not have decodeToXMLByte which
- // makes my life harder and your code slower.
- //
-#if _XERCES_VERSION >= 20700
-
-#if _XERCES_VERSION >= 30000
XMLSize_t size;
- auto_array<XMLByte, xml::std_memory_manager> data (
- Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045),
- mm);
+
+#ifdef XSD_CXX11
+ std::unique_ptr<XMLByte[], xml::std_memory_manager&> data (
#else
- unsigned int size;
auto_array<XMLByte, xml::std_memory_manager> data (
+#endif
Base64::decodeToXMLByte (src, &size, &mm, Base64::Conf_RFC2045),
- mm);
-#endif // _XERCES_VERSION >= 30000
+ mm);
if (data)
{
@@ -425,30 +380,6 @@ namespace xsd
{
//@@ throw
}
-#else
- unsigned int size;
-
-#if _XERCES_VERSION >= 20600 // Xerces 2.5.0 does not have Conf_RFC2045.
- auto_array<XMLCh, xml::std_memory_manager> data (
- Base64::decode (src, &size, &mm, Base64::Conf_RFC2045),
- mm);
-#else
- auto_array<XMLCh, xml::std_memory_manager> data (
- Base64::decode (src, &size, &mm), mm);
-#endif // _XERCES_VERSION >= 20600
-
- if (data)
- {
- buffer<C> tmp (size);
- for (unsigned int i (0); i < size; ++i)
- tmp.data ()[i] = static_cast<char> (data[i]);
- this->swap (tmp); // g++ 4.1 likes it qualified, not sure why.
- }
- else
- {
- //@@ throw
- }
-#endif //_XERCES_VERSION >= 20700
}
@@ -496,11 +427,6 @@ namespace xsd
return new hex_binary (*this, f, c);
}
- // It would have been cleaner to mention size, and data with the
- // using-declaration but HP aCC3 can't handle it in some non-
- // trivial to track down cases. So we are going to use the
- // old-n-ugly this-> techniques.
- //
template <typename C, typename B>
std::basic_string<C> hex_binary<C, B>::
encode () const