mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
gcc 3.4.3 compatibility fixes
This commit is contained in:
parent
4249ede14d
commit
05a97aab88
2 changed files with 68 additions and 78 deletions
90
DOM/Node.h
90
DOM/Node.h
|
@ -45,15 +45,15 @@ class Node_base
|
||||||
}; // class Node_base
|
}; // class Node_base
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
template<class string_type>
|
template<class node_string_type>
|
||||||
class Node : public Node_base
|
class Node : public Node_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef string_type stringT;
|
typedef node_string_type string_type;
|
||||||
typedef string_type string_type;
|
typedef node_string_type string_type;
|
||||||
|
|
||||||
Node() : impl_() { }
|
Node() : impl_() { }
|
||||||
Node(Node_impl<stringT>* const impl) : impl_(impl) { }
|
Node(Node_impl<string_type>* const impl) : impl_(impl) { }
|
||||||
Node(const Node& rhs) : impl_(rhs.impl_) { }
|
Node(const Node& rhs) : impl_(rhs.impl_) { }
|
||||||
virtual ~Node() { }
|
virtual ~Node() { }
|
||||||
|
|
||||||
|
@ -68,25 +68,25 @@ class Node : public Node_base
|
||||||
return *this;
|
return *this;
|
||||||
} // operator=
|
} // operator=
|
||||||
|
|
||||||
stringT getNodeName() const { return impl_->getNodeName(); }
|
string_type getNodeName() const { return impl_->getNodeName(); }
|
||||||
|
|
||||||
stringT getNodeValue() const { return impl_->getNodeValue(); }
|
string_type getNodeValue() const { return impl_->getNodeValue(); }
|
||||||
void setNodeValue(const stringT& nodeValue) { impl_->setNodeValue(nodeValue); }
|
void setNodeValue(const string_type& nodeValue) { impl_->setNodeValue(nodeValue); }
|
||||||
|
|
||||||
Type getNodeType() const { return impl_->getNodeType(); }
|
Type getNodeType() const { return impl_->getNodeType(); }
|
||||||
|
|
||||||
Node getParentNode() const { return impl_->getParentNode(); }
|
Node getParentNode() const { return impl_->getParentNode(); }
|
||||||
|
|
||||||
const NodeList<stringT> getChildNodes() const { return NodeList<stringT>(impl_->getChildNodes()); }
|
const NodeList<string_type> getChildNodes() const { return NodeList<string_type>(impl_->getChildNodes()); }
|
||||||
|
|
||||||
Node getFirstChild() const { return impl_->getFirstChild(); }
|
Node getFirstChild() const { return impl_->getFirstChild(); }
|
||||||
Node getLastChild() const { return impl_->getLastChild(); }
|
Node getLastChild() const { return impl_->getLastChild(); }
|
||||||
Node getPreviousSibling() const { return impl_->getPreviousSibling(); }
|
Node getPreviousSibling() const { return impl_->getPreviousSibling(); }
|
||||||
Node getNextSibling() const { return impl_->getNextSibling(); }
|
Node getNextSibling() const { return impl_->getNextSibling(); }
|
||||||
|
|
||||||
const NamedNodeMap<stringT> getAttributes() const { return NamedNodeMap<stringT>(impl_->getAttributes()); }
|
const NamedNodeMap<string_type> getAttributes() const { return NamedNodeMap<string_type>(impl_->getAttributes()); }
|
||||||
|
|
||||||
Document<stringT> getOwnerDocument() const { return impl_->getOwnerDocument(); }
|
Document<string_type> getOwnerDocument() const { return impl_->getOwnerDocument(); }
|
||||||
|
|
||||||
Node insertBefore(const Node& newChild, const Node& refChild) { return impl_->insertBefore(*newChild.impl_, *refChild.impl_); }
|
Node insertBefore(const Node& newChild, const Node& refChild) { return impl_->insertBefore(*newChild.impl_, *refChild.impl_); }
|
||||||
Node replaceChild(const Node& newChild, const Node& oldChild) { return impl_->replaceChild(*newChild.impl_, *oldChild.impl_); }
|
Node replaceChild(const Node& newChild, const Node& oldChild) { return impl_->replaceChild(*newChild.impl_, *oldChild.impl_); }
|
||||||
|
@ -99,15 +99,15 @@ class Node : public Node_base
|
||||||
|
|
||||||
void normalize() { impl_->normalize(); }
|
void normalize() { impl_->normalize(); }
|
||||||
|
|
||||||
bool isSupported(const stringT& feature, const stringT& version) const { return impl_->isSupported(feature, version); }
|
bool isSupported(const string_type& feature, const string_type& version) const { return impl_->isSupported(feature, version); }
|
||||||
|
|
||||||
stringT getNamespaceURI() const { return impl_->getNamespaceURI(); }
|
string_type getNamespaceURI() const { return impl_->getNamespaceURI(); }
|
||||||
stringT getPrefix() const { return impl_->getPrefix(); }
|
string_type getPrefix() const { return impl_->getPrefix(); }
|
||||||
void setPrefix(const stringT& prefix) const { impl_->setPrefix(prefix); }
|
void setPrefix(const string_type& prefix) const { impl_->setPrefix(prefix); }
|
||||||
stringT getLocalName() const { return impl_->getLocalName(); }
|
string_type getLocalName() const { return impl_->getLocalName(); }
|
||||||
|
|
||||||
// additional three methods - since C++ std::string (and by implication
|
// additional three methods - since C++ std::string (and by implication
|
||||||
// stringT) don't differenciate between a null string and an empty string,
|
// string_type) don't differenciate between a null string and an empty string,
|
||||||
// but the DOM recommendation does, I have to introduce these three methods
|
// but the DOM recommendation does, I have to introduce these three methods
|
||||||
// to disambiguate. If they return false, the corresponding attribute should be
|
// to disambiguate. If they return false, the corresponding attribute should be
|
||||||
// considered null. If they return true, the attribute has been set EVEN IF
|
// considered null. If they return true, the attribute has been set EVEN IF
|
||||||
|
@ -118,15 +118,15 @@ class Node : public Node_base
|
||||||
bool hasAttributes() const { return impl_->hasAttributes(); }
|
bool hasAttributes() const { return impl_->hasAttributes(); }
|
||||||
|
|
||||||
// you almost certainly don't need to use this function
|
// you almost certainly don't need to use this function
|
||||||
Node_impl<stringT>* unlying_impl() const { return *impl_; }
|
Node_impl<string_type>* unlying_impl() const { return *impl_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Proxy<Node_impl<stringT> > impl_;
|
Proxy<Node_impl<string_type> > impl_;
|
||||||
|
|
||||||
typedef class Document<stringT> DocumentT;
|
typedef class Document<string_type> DocumentT;
|
||||||
friend class Document<stringT>;
|
friend class Document<string_type>;
|
||||||
typedef class Events::EventTarget<stringT> EventTargetT;
|
typedef class Events::EventTarget<string_type> EventTargetT;
|
||||||
friend class Events::EventTarget<stringT>;
|
friend class Events::EventTarget<string_type>;
|
||||||
}; // class Node
|
}; // class Node
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -140,8 +140,6 @@ template<class string_type>
|
||||||
class Node_impl
|
class Node_impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef string_type stringT;
|
|
||||||
|
|
||||||
virtual ~Node_impl() { }
|
virtual ~Node_impl() { }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
|
@ -151,47 +149,47 @@ class Node_impl
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// Node methods
|
// Node methods
|
||||||
virtual stringT getNodeName() const = 0;
|
virtual string_type getNodeName() const = 0;
|
||||||
|
|
||||||
virtual stringT getNodeValue() const = 0;
|
virtual string_type getNodeValue() const = 0;
|
||||||
virtual void setNodeValue(const stringT& nodeValue) = 0;
|
virtual void setNodeValue(const string_type& nodeValue) = 0;
|
||||||
|
|
||||||
virtual Node_base::Type getNodeType() const = 0;
|
virtual Node_base::Type getNodeType() const = 0;
|
||||||
|
|
||||||
virtual Node_impl<stringT>* getParentNode() const = 0;
|
virtual Node_impl<string_type>* getParentNode() const = 0;
|
||||||
|
|
||||||
virtual NodeList_impl<stringT>* getChildNodes() const = 0;
|
virtual NodeList_impl<string_type>* getChildNodes() const = 0;
|
||||||
|
|
||||||
virtual Node_impl<stringT>* getFirstChild() const = 0;
|
virtual Node_impl<string_type>* getFirstChild() const = 0;
|
||||||
virtual Node_impl<stringT>* getLastChild() const = 0;
|
virtual Node_impl<string_type>* getLastChild() const = 0;
|
||||||
|
|
||||||
virtual Node_impl<stringT>* getPreviousSibling() const = 0;
|
virtual Node_impl<string_type>* getPreviousSibling() const = 0;
|
||||||
virtual Node_impl<stringT>* getNextSibling() const = 0;
|
virtual Node_impl<string_type>* getNextSibling() const = 0;
|
||||||
|
|
||||||
virtual NamedNodeMap_impl<stringT>* getAttributes() const = 0;
|
virtual NamedNodeMap_impl<string_type>* getAttributes() const = 0;
|
||||||
|
|
||||||
virtual Document_impl<stringT>* getOwnerDocument() const = 0;
|
virtual Document_impl<string_type>* getOwnerDocument() const = 0;
|
||||||
|
|
||||||
virtual Node_impl<stringT>* insertBefore(Node_impl<stringT>* newChild, Node_impl<stringT>* refChild) = 0;
|
virtual Node_impl<string_type>* insertBefore(Node_impl<string_type>* newChild, Node_impl<string_type>* refChild) = 0;
|
||||||
virtual Node_impl<stringT>* replaceChild(Node_impl<stringT>* newChild, Node_impl<stringT>* oldChild) = 0;
|
virtual Node_impl<string_type>* replaceChild(Node_impl<string_type>* newChild, Node_impl<string_type>* oldChild) = 0;
|
||||||
virtual Node_impl<stringT>* removeChild(Node_impl<stringT>* oldChild) = 0;
|
virtual Node_impl<string_type>* removeChild(Node_impl<string_type>* oldChild) = 0;
|
||||||
virtual Node_impl<stringT>* appendChild(Node_impl<stringT>* newChild) = 0;
|
virtual Node_impl<string_type>* appendChild(Node_impl<string_type>* newChild) = 0;
|
||||||
|
|
||||||
virtual bool hasChildNodes() const = 0;
|
virtual bool hasChildNodes() const = 0;
|
||||||
|
|
||||||
virtual Node_impl<stringT>* cloneNode(bool deep) const = 0;
|
virtual Node_impl<string_type>* cloneNode(bool deep) const = 0;
|
||||||
|
|
||||||
virtual void normalize() = 0;
|
virtual void normalize() = 0;
|
||||||
|
|
||||||
virtual bool isSupported(const stringT& feature, const stringT& version) const = 0;
|
virtual bool isSupported(const string_type& feature, const string_type& version) const = 0;
|
||||||
|
|
||||||
virtual stringT getNamespaceURI() const = 0;
|
virtual string_type getNamespaceURI() const = 0;
|
||||||
virtual stringT getPrefix() const = 0;
|
virtual string_type getPrefix() const = 0;
|
||||||
virtual void setPrefix(const stringT& prefix) = 0;
|
virtual void setPrefix(const string_type& prefix) = 0;
|
||||||
virtual stringT getLocalName() const = 0;
|
virtual string_type getLocalName() const = 0;
|
||||||
|
|
||||||
// additional methods - since C++ std::string (and by implication
|
// additional methods - since C++ std::string (and by implication
|
||||||
// stringT) don't differenciate between a null string and an empty string,
|
// string_type) don't differenciate between a null string and an empty string,
|
||||||
// but the DOM recommendation does, I have to introduce these three methods
|
// but the DOM recommendation does, I have to introduce these three methods
|
||||||
// to disambiguate. If they return false, the corresponding attribute should be
|
// to disambiguate. If they return false, the corresponding attribute should be
|
||||||
// considered null. If they return true, the attribute has been set EVEN IF
|
// considered null. If they return true, the attribute has been set EVEN IF
|
||||||
|
|
|
@ -121,7 +121,14 @@ class libxml2_wrapper : public basic_XMLReader<string_type>,
|
||||||
typedef SAX::basic_InputSource<stringT> inputSourceT;
|
typedef SAX::basic_InputSource<stringT> inputSourceT;
|
||||||
typedef SAX::basic_Locator<stringT> locatorT;
|
typedef SAX::basic_Locator<stringT> locatorT;
|
||||||
typedef SAX::basic_NamespaceSupport<stringT, string_adaptorT> namespaceSupportT;
|
typedef SAX::basic_NamespaceSupport<stringT, string_adaptorT> namespaceSupportT;
|
||||||
|
typedef SAX::basic_ErrorHandler<stringT> errorHandlerT;
|
||||||
|
typedef SAX::basic_SAXParseException<stringT> SAXParseExceptionT;
|
||||||
|
typedef SAX::basic_XMLReader<stringT> XMLReaderT;
|
||||||
|
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
|
||||||
|
typedef typename XMLReaderT::template Property<lexicalHandlerT*> getLexicalHandlerT;
|
||||||
|
typedef typename XMLReaderT::template Property<lexicalHandlerT&> setLexicalHandlerT;
|
||||||
|
typedef typename XMLReaderT::template Property<declHandlerT*> getDeclHandlerT;
|
||||||
|
typedef typename XMLReaderT::template Property<declHandlerT&> setDeclHandlerT;
|
||||||
libxml2_wrapper();
|
libxml2_wrapper();
|
||||||
~libxml2_wrapper();
|
~libxml2_wrapper();
|
||||||
|
|
||||||
|
@ -148,8 +155,8 @@ class libxml2_wrapper : public basic_XMLReader<string_type>,
|
||||||
protected:
|
protected:
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// properties
|
// properties
|
||||||
virtual std::auto_ptr<typename basic_XMLReader<stringT>::PropertyBase> doGetProperty(const stringT& name);
|
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const stringT& name);
|
||||||
virtual void doSetProperty(const stringT& name, std::auto_ptr<typename basic_XMLReader<stringT>::PropertyBase> value);
|
virtual void doSetProperty(const stringT& name, std::auto_ptr<PropertyBaseT> value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual stringT getPublicId() const;
|
virtual stringT getPublicId() const;
|
||||||
|
@ -310,52 +317,37 @@ void libxml2_wrapper<stringT, string_adaptorT>::setFeature(const stringT& name,
|
||||||
|
|
||||||
template<class stringT, class string_adaptorT>
|
template<class stringT, class string_adaptorT>
|
||||||
#ifndef ARABICA_VS6_WORKAROUND
|
#ifndef ARABICA_VS6_WORKAROUND
|
||||||
std::auto_ptr<typename basic_XMLReader<stringT>::PropertyBase> libxml2_wrapper<stringT, string_adaptorT>::doGetProperty(const stringT& name)
|
std::auto_ptr<typename libxml2_wrapper<stringT, string_adaptorT>::PropertyBaseT> libxml2_wrapper<stringT, string_adaptorT>::doGetProperty(const stringT& name)
|
||||||
#else
|
#else
|
||||||
std::auto_ptr<basic_XMLReader<stringT>::PropertyBase> libxml2_wrapper<stringT, string_adaptorT>::doGetProperty(const stringT& name)
|
std::auto_ptr<libxml2_wrapper<stringT, string_adaptorT>::PropertyBaseT> libxml2_wrapper<stringT, string_adaptorT>::doGetProperty(const stringT& name)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(name == properties_.declHandler)
|
if(name == properties_.declHandler)
|
||||||
{
|
{
|
||||||
typedef typename SAX::basic_XMLReader<stringT>::Property<declHandlerT *> dhp_type;
|
getDeclHandlerT* prop = new getDeclHandlerT(declHandler_);
|
||||||
dhp_type *prop = new dhp_type(declHandler_);
|
return std::auto_ptr<PropertyBaseT>(prop);
|
||||||
#ifndef ARABICA_VS6_WORKAROUND
|
|
||||||
return std::auto_ptr<typename SAX::basic_XMLReader<stringT>::PropertyBase>(prop);
|
|
||||||
#else
|
|
||||||
return std::auto_ptr<SAX::basic_XMLReader<stringT>::PropertyBase>(prop);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name == properties_.lexicalHandler)
|
if(name == properties_.lexicalHandler)
|
||||||
throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name));
|
throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name));
|
||||||
else
|
|
||||||
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA_.asStdString(name));
|
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA_.asStdString(name));
|
||||||
} // doGetProperty
|
} // doGetProperty
|
||||||
|
|
||||||
template<class stringT, class string_adaptorT>
|
template<class stringT, class string_adaptorT>
|
||||||
#ifndef ARABICA_VS6_WORKAROUND
|
void libxml2_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name, std::auto_ptr<PropertyBaseT> value)
|
||||||
void libxml2_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name, std::auto_ptr<typename basic_XMLReader<stringT>::PropertyBase> value)
|
|
||||||
#else
|
|
||||||
void libxml2_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name, std::auto_ptr<basic_XMLReader<stringT>::PropertyBase> value)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if(name == properties_.declHandler)
|
if(name == properties_.declHandler)
|
||||||
{
|
{
|
||||||
typename SAX::basic_XMLReader<stringT>::template Property<declHandlerT&>* prop =
|
setDeclHandlerT* prop = dynamic_cast<setDeclHandlerT*>(value.get());
|
||||||
dynamic_cast<SAX::basic_XMLReader<stringT>::Property<declHandlerT&>*>(value.get());
|
|
||||||
|
|
||||||
if(!prop)
|
if(!prop)
|
||||||
// no std::bad_cast( const char * ) or std::bad_cast( const string& )
|
throw std::bad_cast();
|
||||||
// see ISO-IEC-14882-1998
|
|
||||||
throw std::bad_cast(); // ("Property DeclHandler is wrong type, should be SAX::DeclHandler&");
|
|
||||||
|
|
||||||
declHandler_ = &(prop->get());
|
declHandler_ = &(prop->get());
|
||||||
return;
|
}
|
||||||
} // if ...
|
|
||||||
|
|
||||||
if(name == properties_.lexicalHandler)
|
if(name == properties_.lexicalHandler)
|
||||||
throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name));
|
throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name));
|
||||||
else
|
|
||||||
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA_.asStdString(name));
|
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA_.asStdString(name));
|
||||||
} // doSetProperty
|
} // doSetProperty
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue