diff --git a/DOM/Node.h b/DOM/Node.h index 13ceba42..d3304f16 100644 --- a/DOM/Node.h +++ b/DOM/Node.h @@ -45,15 +45,15 @@ class Node_base }; // class Node_base ///////////////////////////////////////////////// -template +template class Node : public Node_base { public: - typedef string_type stringT; - typedef string_type string_type; + typedef node_string_type string_type; + typedef node_string_type string_type; Node() : impl_() { } - Node(Node_impl* const impl) : impl_(impl) { } + Node(Node_impl* const impl) : impl_(impl) { } Node(const Node& rhs) : impl_(rhs.impl_) { } virtual ~Node() { } @@ -68,25 +68,25 @@ class Node : public Node_base return *this; } // operator= - stringT getNodeName() const { return impl_->getNodeName(); } + string_type getNodeName() const { return impl_->getNodeName(); } - stringT getNodeValue() const { return impl_->getNodeValue(); } - void setNodeValue(const stringT& nodeValue) { impl_->setNodeValue(nodeValue); } + string_type getNodeValue() const { return impl_->getNodeValue(); } + void setNodeValue(const string_type& nodeValue) { impl_->setNodeValue(nodeValue); } Type getNodeType() const { return impl_->getNodeType(); } Node getParentNode() const { return impl_->getParentNode(); } - const NodeList getChildNodes() const { return NodeList(impl_->getChildNodes()); } + const NodeList getChildNodes() const { return NodeList(impl_->getChildNodes()); } Node getFirstChild() const { return impl_->getFirstChild(); } Node getLastChild() const { return impl_->getLastChild(); } Node getPreviousSibling() const { return impl_->getPreviousSibling(); } Node getNextSibling() const { return impl_->getNextSibling(); } - const NamedNodeMap getAttributes() const { return NamedNodeMap(impl_->getAttributes()); } + const NamedNodeMap getAttributes() const { return NamedNodeMap(impl_->getAttributes()); } - Document getOwnerDocument() const { return impl_->getOwnerDocument(); } + Document getOwnerDocument() const { return impl_->getOwnerDocument(); } 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_); } @@ -99,15 +99,15 @@ class Node : public Node_base 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(); } - stringT getPrefix() const { return impl_->getPrefix(); } - void setPrefix(const stringT& prefix) const { impl_->setPrefix(prefix); } - stringT getLocalName() const { return impl_->getLocalName(); } + string_type getNamespaceURI() const { return impl_->getNamespaceURI(); } + string_type getPrefix() const { return impl_->getPrefix(); } + void setPrefix(const string_type& prefix) const { impl_->setPrefix(prefix); } + string_type getLocalName() const { return impl_->getLocalName(); } // 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 // to disambiguate. If they return false, the corresponding attribute should be // 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(); } // you almost certainly don't need to use this function - Node_impl* unlying_impl() const { return *impl_; } + Node_impl* unlying_impl() const { return *impl_; } protected: - Proxy > impl_; + Proxy > impl_; - typedef class Document DocumentT; - friend class Document; - typedef class Events::EventTarget EventTargetT; - friend class Events::EventTarget; + typedef class Document DocumentT; + friend class Document; + typedef class Events::EventTarget EventTargetT; + friend class Events::EventTarget; }; // class Node //////////////////////////////////////////////////////////////////// @@ -140,8 +140,6 @@ template class Node_impl { public: - typedef string_type stringT; - virtual ~Node_impl() { } /////////////////////////////////////////////////////// @@ -151,47 +149,47 @@ class Node_impl /////////////////////////////////////////////////////// // Node methods - virtual stringT getNodeName() const = 0; + virtual string_type getNodeName() const = 0; - virtual stringT getNodeValue() const = 0; - virtual void setNodeValue(const stringT& nodeValue) = 0; + virtual string_type getNodeValue() const = 0; + virtual void setNodeValue(const string_type& nodeValue) = 0; virtual Node_base::Type getNodeType() const = 0; - virtual Node_impl* getParentNode() const = 0; + virtual Node_impl* getParentNode() const = 0; - virtual NodeList_impl* getChildNodes() const = 0; + virtual NodeList_impl* getChildNodes() const = 0; - virtual Node_impl* getFirstChild() const = 0; - virtual Node_impl* getLastChild() const = 0; + virtual Node_impl* getFirstChild() const = 0; + virtual Node_impl* getLastChild() const = 0; - virtual Node_impl* getPreviousSibling() const = 0; - virtual Node_impl* getNextSibling() const = 0; + virtual Node_impl* getPreviousSibling() const = 0; + virtual Node_impl* getNextSibling() const = 0; - virtual NamedNodeMap_impl* getAttributes() const = 0; + virtual NamedNodeMap_impl* getAttributes() const = 0; - virtual Document_impl* getOwnerDocument() const = 0; + virtual Document_impl* getOwnerDocument() const = 0; - virtual Node_impl* insertBefore(Node_impl* newChild, Node_impl* refChild) = 0; - virtual Node_impl* replaceChild(Node_impl* newChild, Node_impl* oldChild) = 0; - virtual Node_impl* removeChild(Node_impl* oldChild) = 0; - virtual Node_impl* appendChild(Node_impl* newChild) = 0; + virtual Node_impl* insertBefore(Node_impl* newChild, Node_impl* refChild) = 0; + virtual Node_impl* replaceChild(Node_impl* newChild, Node_impl* oldChild) = 0; + virtual Node_impl* removeChild(Node_impl* oldChild) = 0; + virtual Node_impl* appendChild(Node_impl* newChild) = 0; virtual bool hasChildNodes() const = 0; - virtual Node_impl* cloneNode(bool deep) const = 0; + virtual Node_impl* cloneNode(bool deep) const = 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 stringT getPrefix() const = 0; - virtual void setPrefix(const stringT& prefix) = 0; - virtual stringT getLocalName() const = 0; + virtual string_type getNamespaceURI() const = 0; + virtual string_type getPrefix() const = 0; + virtual void setPrefix(const string_type& prefix) = 0; + virtual string_type getLocalName() const = 0; // 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 // to disambiguate. If they return false, the corresponding attribute should be // considered null. If they return true, the attribute has been set EVEN IF diff --git a/SAX/wrappers/saxlibxml2.h b/SAX/wrappers/saxlibxml2.h index 26753799..7ce562db 100644 --- a/SAX/wrappers/saxlibxml2.h +++ b/SAX/wrappers/saxlibxml2.h @@ -121,7 +121,14 @@ class libxml2_wrapper : public basic_XMLReader, typedef SAX::basic_InputSource inputSourceT; typedef SAX::basic_Locator locatorT; typedef SAX::basic_NamespaceSupport namespaceSupportT; - + typedef SAX::basic_ErrorHandler errorHandlerT; + typedef SAX::basic_SAXParseException SAXParseExceptionT; + typedef SAX::basic_XMLReader XMLReaderT; + typedef typename XMLReaderT::PropertyBase PropertyBaseT; + typedef typename XMLReaderT::template Property getLexicalHandlerT; + typedef typename XMLReaderT::template Property setLexicalHandlerT; + typedef typename XMLReaderT::template Property getDeclHandlerT; + typedef typename XMLReaderT::template Property setDeclHandlerT; libxml2_wrapper(); ~libxml2_wrapper(); @@ -148,8 +155,8 @@ class libxml2_wrapper : public basic_XMLReader, protected: //////////////////////////////////////////////// // properties - virtual std::auto_ptr::PropertyBase> doGetProperty(const stringT& name); - virtual void doSetProperty(const stringT& name, std::auto_ptr::PropertyBase> value); + virtual std::auto_ptr doGetProperty(const stringT& name); + virtual void doSetProperty(const stringT& name, std::auto_ptr value); public: virtual stringT getPublicId() const; @@ -310,53 +317,38 @@ void libxml2_wrapper::setFeature(const stringT& name, template #ifndef ARABICA_VS6_WORKAROUND -std::auto_ptr::PropertyBase> libxml2_wrapper::doGetProperty(const stringT& name) +std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const stringT& name) #else -std::auto_ptr::PropertyBase> libxml2_wrapper::doGetProperty(const stringT& name) +std::auto_ptr::PropertyBaseT> libxml2_wrapper::doGetProperty(const stringT& name) #endif { if(name == properties_.declHandler) { - typedef typename SAX::basic_XMLReader::Property dhp_type; - dhp_type *prop = new dhp_type(declHandler_); -#ifndef ARABICA_VS6_WORKAROUND - return std::auto_ptr::PropertyBase>(prop); -#else - return std::auto_ptr::PropertyBase>(prop); -#endif + getDeclHandlerT* prop = new getDeclHandlerT(declHandler_); + return std::auto_ptr(prop); } + if(name == properties_.lexicalHandler) + throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name)); - if(name == properties_.lexicalHandler) - 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 template -#ifndef ARABICA_VS6_WORKAROUND -void libxml2_wrapper::doSetProperty(const stringT& name, std::auto_ptr::PropertyBase> value) -#else -void libxml2_wrapper::doSetProperty(const stringT& name, std::auto_ptr::PropertyBase> value) -#endif +void libxml2_wrapper::doSetProperty(const stringT& name, std::auto_ptr value) { if(name == properties_.declHandler) { - typename SAX::basic_XMLReader::template Property* prop = - dynamic_cast::Property*>(value.get()); + setDeclHandlerT* prop = dynamic_cast(value.get()); if(!prop) - // no std::bad_cast( const char * ) or std::bad_cast( const string& ) - // see ISO-IEC-14882-1998 - throw std::bad_cast(); // ("Property DeclHandler is wrong type, should be SAX::DeclHandler&"); + throw std::bad_cast(); declHandler_ = &(prop->get()); - return; - } // if ... + } + if(name == properties_.lexicalHandler) + throw SAX::SAXNotSupportedException(std::string("Property not supported ") + SA_.asStdString(name)); - if(name == properties_.lexicalHandler) - 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 template