summaryrefslogtreecommitdiff
path: root/libxsd-frontend/xsd-frontend/xml.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd-frontend/xsd-frontend/xml.hxx')
-rw-r--r--libxsd-frontend/xsd-frontend/xml.hxx86
1 files changed, 39 insertions, 47 deletions
diff --git a/libxsd-frontend/xsd-frontend/xml.hxx b/libxsd-frontend/xsd-frontend/xml.hxx
index 8c9b01c..d33f6bf 100644
--- a/libxsd-frontend/xsd-frontend/xml.hxx
+++ b/libxsd-frontend/xsd-frontend/xml.hxx
@@ -1,18 +1,17 @@
// file : xsd-frontend/xml.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_FRONTEND_XML_HXX
#define XSD_FRONTEND_XML_HXX
+#include <vector>
#include <ostream>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
-#include <cult/containers/vector.hxx>
-
+#include <xsd-frontend/version.hxx> // Check Xerces-C++ version.
#include <xsd-frontend/types.hxx>
#include <xsd-frontend/schema-dom-parser.hxx>
@@ -24,9 +23,9 @@ namespace XSDFrontend
inline
String
- transcode (XMLCh const* s, Size length)
+ transcode (XMLCh const* s, size_t length)
{
- if (sizeof (WideChar) == 4)
+ if (sizeof (wchar_t) == 4)
{
// UTF-32
//
@@ -34,8 +33,8 @@ namespace XSDFrontend
// Find what the resulting buffer size will be.
//
- Size rl (0);
- Boolean valid (true);
+ size_t rl (0);
+ bool valid (true);
for (XMLCh const* p (s); p < end; ++p)
{
@@ -60,27 +59,27 @@ namespace XSDFrontend
String r;
r.reserve (rl + 1);
r.resize (rl);
- WideChar* rs (const_cast<WideChar*> (r.c_str ()));
+ wchar_t* rs (const_cast<wchar_t*> (r.c_str ()));
- Size i (0);
+ size_t i (0);
for (XMLCh const* p (s); p < end; ++p)
{
XMLCh x (*p);
if (x < 0xD800 || x > 0xDBFF)
- rs[i++] = WideChar (x);
+ rs[i++] = wchar_t (x);
else
rs[i++] = ((x - 0xD800) << 10) + (*++p - 0xDC00) + 0x10000;
}
return r;
}
- else if (sizeof (WideChar) == 2)
+ else if (sizeof (wchar_t) == 2)
{
// UTF-16
//
- return String (reinterpret_cast<const WideChar*> (s), length);
+ return String (reinterpret_cast<const wchar_t*> (s), length);
}
else
return String ();
@@ -97,7 +96,7 @@ namespace XSDFrontend
NarrowString
transcode_to_narrow (XMLCh const* xs)
{
- Char* s (Xerces::XMLString::transcode (xs));
+ char* s (Xerces::XMLString::transcode (xs));
NarrowString r (s);
Xerces::XMLString::release (&s);
return r;
@@ -107,16 +106,16 @@ namespace XSDFrontend
XMLCh*
transcode (String const& str)
{
- Size l (str.size ());
- WideChar const* s (str.c_str ());
+ size_t l (str.size ());
+ wchar_t const* s (str.c_str ());
- if (sizeof (WideChar) == 4)
+ if (sizeof (wchar_t) == 4)
{
// Find what the resulting buffer size will be.
//
- Size rl (0);
+ size_t rl (0);
- for (WideChar const* p (s); p < s + l; ++p)
+ for (wchar_t const* p (s); p < s + l; ++p)
{
rl += (*p & 0xFFFF0000) ? 2 : 1;
}
@@ -124,9 +123,9 @@ namespace XSDFrontend
XMLCh* r (new XMLCh[rl + 1]);
XMLCh* ir (r);
- for (WideChar const* p (s); p < s + l; ++p)
+ for (wchar_t const* p (s); p < s + l; ++p)
{
- WideChar w (*p);
+ wchar_t w (*p);
if (w & 0xFFFF0000)
{
@@ -143,12 +142,12 @@ namespace XSDFrontend
return r;
}
- else if (sizeof (WideChar) == 2)
+ else if (sizeof (wchar_t) == 2)
{
XMLCh* r (new XMLCh[l + 1]);
XMLCh* ir (r);
- for (Size i (0); i < l; ++ir, ++i)
+ for (size_t i (0); i < l; ++ir, ++i)
*ir = static_cast<XMLCh> (s[i]);
*ir = XMLCh (0);
@@ -167,7 +166,7 @@ namespace XSDFrontend
{
}
- XMLChString (WideChar const* s)
+ XMLChString (wchar_t const* s)
: s_ (transcode (String (s)))
{
}
@@ -217,20 +216,20 @@ namespace XSDFrontend
}
public:
- UnsignedLong
+ unsigned long
line () const
{
//@@ cache
//
- return reinterpret_cast<UnsignedLong> (e_->getUserData (line_key));
+ return reinterpret_cast<unsigned long> (e_->getUserData (line_key));
}
- UnsignedLong
+ unsigned long
column () const
{
//@@ cache
//
- return reinterpret_cast<UnsignedLong> (e_->getUserData (column_key));
+ return reinterpret_cast<unsigned long> (e_->getUserData (column_key));
}
public:
@@ -243,7 +242,7 @@ namespace XSDFrontend
public:
// Attribute identified by a name.
//
- Boolean
+ bool
attribute_p (String const& name) const
{
return attribute_p ("", name);
@@ -264,7 +263,7 @@ namespace XSDFrontend
// Attribute identified by namespace and name.
//
- Boolean
+ bool
attribute_p (String const& namespace_, String const& name) const
{
Xerces::DOMAttr* a (
@@ -303,7 +302,7 @@ namespace XSDFrontend
inline String
prefix (String const& n)
{
- Size i (0);
+ size_t i (0);
while (i < n.length () && n[i] != L':') ++i;
//std::wcerr << "prefix " << n << " "
@@ -315,7 +314,7 @@ namespace XSDFrontend
inline String
uq_name (String const& n)
{
- Size i (0);
+ size_t i (0);
while (i < n.length () && n[i] != L':') ++i;
return String (n.c_str () + (i == n.length () ? 0 : i + 1));
@@ -367,18 +366,11 @@ namespace XSDFrontend
ns_prefix (Element const& e, String const& wns)
{
XMLChString ns (wns);
-
-#if _XERCES_VERSION >= 30000
- XMLCh const* p (
- e.dom_element ()->lookupPrefix (ns.c_str ()));
-#else
- XMLCh const* p (
- e.dom_element ()->lookupNamespacePrefix (ns.c_str (), false));
-#endif
+ XMLCh const* p (e.dom_element ()->lookupPrefix (ns.c_str ()));
if (p == 0)
{
- Boolean r (e.dom_element ()->isDefaultNamespace (ns.c_str ()));
+ bool r (e.dom_element ()->isDefaultNamespace (ns.c_str ()));
if (r)
return L"";
@@ -518,9 +510,9 @@ namespace XSDFrontend
// Conversion to bool.
//
- typedef X* (AutoPtr::*BooleanConvertible)() const;
+ typedef X* (AutoPtr::*boolConvertible)() const;
- operator BooleanConvertible () const throw ()
+ operator boolConvertible () const throw ()
{
return x_ ? &AutoPtr<X>::operator-> : 0;
}
@@ -530,13 +522,13 @@ namespace XSDFrontend
};
template <typename X>
- struct PtrVector: Cult::Containers::Vector<X*>
+ struct PtrVector: std::vector<X*>
{
- typedef Cult::Containers::Vector<X*> Base;
+ typedef std::vector<X*> Base;
~PtrVector ()
{
- for (typename Base::Iterator i (this->begin ()), e (this->end ());
+ for (typename Base::iterator i (this->begin ()), e (this->end ());
i != e; ++i)
{
if (*i)
@@ -544,7 +536,7 @@ namespace XSDFrontend
}
}
- Void
+ void
push_back (AutoPtr<X>& x)
{
Base::push_back (0);