2005-08-04 22:42:30 +02:00
|
|
|
#ifndef ARABICA_XPATHIC_XPATH_NAMESPACE_NODE_HPP
|
|
|
|
#define ARABICA_XPATHIC_XPATH_NAMESPACE_NODE_HPP
|
|
|
|
|
2005-08-05 23:02:24 +02:00
|
|
|
#ifdef _MSC_VER
|
2005-08-04 22:42:30 +02:00
|
|
|
#pragma warning(disable: 4250)
|
2005-08-05 23:02:24 +02:00
|
|
|
#endif
|
2005-08-04 22:42:30 +02:00
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <DOM/Simple/DocumentImpl.hpp>
|
|
|
|
#include <DOM/Simple/NodeImpl.hpp>
|
2007-09-10 19:52:04 +02:00
|
|
|
#include <Arabica/StringAdaptor.hpp>
|
2005-08-04 22:42:30 +02:00
|
|
|
|
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace XPath
|
|
|
|
{
|
|
|
|
|
|
|
|
const DOM::Node_base::Type NAMESPACE_NODE_TYPE = static_cast<DOM::Node_base::Type>(DOM::Node_base::MAX_TYPE + 27); // 27 is a random choice
|
|
|
|
|
2005-08-22 17:35:20 +02:00
|
|
|
namespace impl
|
|
|
|
{
|
|
|
|
|
2005-08-15 23:09:13 +02:00
|
|
|
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
|
2008-05-28 10:53:21 +02:00
|
|
|
class NamespaceNodeImpl : public DOM::Node_impl<stringT, string_adaptorT>
|
2005-08-04 22:42:30 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-05-28 10:53:21 +02:00
|
|
|
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
|
|
|
typedef DOM::Node_impl<stringT, string_adaptorT> NodeImplT;
|
|
|
|
typedef DOM::NodeList_impl<stringT, string_adaptorT> NodeListT;
|
|
|
|
typedef DOM::NamedNodeMap_impl<stringT, string_adaptorT> NamedNodeMapT;
|
|
|
|
typedef DOM::Document_impl<stringT, string_adaptorT> DocumentImplT;
|
|
|
|
|
|
|
|
NamespaceNodeImpl(const NodeT& parentNode,
|
|
|
|
const stringT& localname,
|
|
|
|
const stringT& value) :
|
|
|
|
NodeImplT(),
|
|
|
|
parentNode_(parentNode.underlying_impl()),
|
2005-08-04 22:42:30 +02:00
|
|
|
localname_(localname),
|
|
|
|
value_(value),
|
|
|
|
ref_(0)
|
|
|
|
{
|
|
|
|
} // NamespaceNodeImpl
|
|
|
|
|
2009-05-19 10:24:19 +02:00
|
|
|
NamespaceNodeImpl(NodeImplT* parentNode,
|
|
|
|
const stringT& localname,
|
|
|
|
const stringT& value) :
|
|
|
|
NodeImplT(),
|
|
|
|
parentNode_(parentNode),
|
|
|
|
localname_(localname),
|
|
|
|
value_(value),
|
|
|
|
ref_(0)
|
|
|
|
{
|
|
|
|
} // NamespaceNodeImpl
|
|
|
|
|
2005-08-04 22:42:30 +02:00
|
|
|
virtual ~NamespaceNodeImpl() { }
|
|
|
|
|
2008-05-28 10:53:21 +02:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// not fully part of the document, so need to manage our own lifetime
|
2005-08-04 22:42:30 +02:00
|
|
|
virtual void addRef()
|
|
|
|
{
|
2008-05-28 10:53:21 +02:00
|
|
|
parentNode_->addRef();
|
2005-08-04 22:42:30 +02:00
|
|
|
++ref_;
|
|
|
|
} // addRef
|
|
|
|
|
|
|
|
virtual void releaseRef()
|
|
|
|
{
|
2008-05-28 10:53:21 +02:00
|
|
|
parentNode_->releaseRef();
|
2005-08-04 22:42:30 +02:00
|
|
|
if(!(--ref_))
|
|
|
|
delete this;
|
|
|
|
} // releaseRef
|
|
|
|
|
2008-05-28 10:53:21 +02:00
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
// DOM::Node methods
|
|
|
|
virtual const stringT& getNodeName() const { return localname_; }
|
|
|
|
|
|
|
|
virtual const stringT& getNodeValue() const { return value_; }
|
|
|
|
virtual void setNodeValue(const stringT&) { oopsReadOnly(); }
|
|
|
|
|
|
|
|
virtual DOM::Node_base::Type getNodeType() const { return NAMESPACE_NODE_TYPE; }
|
|
|
|
|
|
|
|
virtual NodeImplT* getParentNode() const { return parentNode_; }
|
|
|
|
|
|
|
|
virtual NodeListT* getChildNodes() const { return 0; }
|
|
|
|
|
|
|
|
virtual NodeImplT* getFirstChild() const { return 0; }
|
|
|
|
virtual NodeImplT* getLastChild() const { return 0; }
|
|
|
|
|
|
|
|
virtual NodeImplT* getPreviousSibling() const { return 0; }
|
|
|
|
virtual NodeImplT* getNextSibling() const { return 0; }
|
|
|
|
|
|
|
|
virtual NamedNodeMapT* getAttributes() const { return 0; }
|
|
|
|
|
|
|
|
virtual DocumentImplT* getOwnerDocument() const { return parentNode_->getOwnerDocument(); }
|
|
|
|
|
2010-01-10 21:23:53 +01:00
|
|
|
virtual NodeImplT* insertBefore(NodeImplT* /* newChild */, NodeImplT* /* refChild */) { throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); }
|
|
|
|
virtual NodeImplT* replaceChild(NodeImplT* /* newChild */, NodeImplT* /* oldChild */) { throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); }
|
|
|
|
virtual NodeImplT* removeChild(NodeImplT* /* oldChild */) { throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); }
|
|
|
|
virtual NodeImplT* appendChild(NodeImplT* /* newChild */) { throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); }
|
|
|
|
virtual void purgeChild(NodeImplT* /* oldChild */) { throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR); }
|
2008-05-28 10:53:21 +02:00
|
|
|
|
|
|
|
virtual bool hasChildNodes() const { return false; }
|
|
|
|
|
2010-01-10 21:23:53 +01:00
|
|
|
virtual NodeImplT* cloneNode(bool /* deep */) const { return new NamespaceNodeImpl<stringT, string_adaptorT>(parentNode_, localname_, value_); }
|
2008-05-28 10:53:21 +02:00
|
|
|
|
|
|
|
virtual void normalize() { }
|
|
|
|
|
2010-01-10 21:23:53 +01:00
|
|
|
virtual bool isSupported(const stringT& /* feature */, const stringT& /* version */) const { return false; }
|
2008-05-28 10:53:21 +02:00
|
|
|
|
|
|
|
virtual const stringT& getNamespaceURI() const { return empty_; }
|
|
|
|
virtual const stringT& getPrefix() const { return empty_; }
|
|
|
|
virtual void setPrefix(const stringT&) { oopsReadOnly(); }
|
|
|
|
virtual const stringT& getLocalName() const { return localname_; }
|
|
|
|
|
|
|
|
virtual bool hasNamespaceURI() const { return false; }
|
|
|
|
virtual bool hasPrefix() const { return false; }
|
|
|
|
|
|
|
|
virtual bool hasAttributes() const { return false; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void oopsReadOnly() const { throw DOM::DOMException(DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR); }
|
|
|
|
|
|
|
|
NodeImplT* parentNode_;
|
2005-08-04 22:42:30 +02:00
|
|
|
stringT localname_;
|
|
|
|
stringT value_;
|
2005-12-09 16:49:52 +01:00
|
|
|
const stringT empty_;
|
2005-08-04 22:42:30 +02:00
|
|
|
unsigned int ref_;
|
|
|
|
}; // class NamespaceNodeImpl
|
|
|
|
|
2005-08-22 17:35:20 +02:00
|
|
|
} // namespace impl
|
2005-08-04 22:42:30 +02:00
|
|
|
} // namespace XPath
|
|
|
|
} // namespace Arabica
|
|
|
|
|
|
|
|
#endif
|