mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-17 18:12:04 +01:00
working on DOM template params - build is currently broken
This commit is contained in:
parent
bbcf3e1001
commit
90685582ea
30 changed files with 694 additions and 602 deletions
|
@ -14,20 +14,24 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Element;
|
||||
template<class stringT> class Attr_impl;
|
||||
template<class stringT, class string_adaptorT> class Element;
|
||||
template<class stringT, class string_adaptorT> class Attr_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Attr : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Attr : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
public:
|
||||
Attr() : Node<stringT>() { }
|
||||
explicit Attr(Attr_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
Attr(const Attr& rhs) : Node<stringT>(rhs) { }
|
||||
explicit Attr(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
typedef Element<stringT, string_adaptorT> ElementT;
|
||||
typedef Attr_impl<stringT, string_adaptorT> Attr_implT;
|
||||
|
||||
Attr() : NodeT() { }
|
||||
|
||||
explicit Attr(Attr_implT* impl) : NodeT(impl) { }
|
||||
Attr(const Attr& rhs) : NodeT(rhs) { }
|
||||
explicit Attr(const NodeT& rhs) : NodeT(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::ATTRIBUTE_NODE)
|
||||
if(rhs.getNodeType() != NodeT::ATTRIBUTE_NODE)
|
||||
throw std::bad_cast();
|
||||
} // Attr
|
||||
|
||||
|
@ -38,21 +42,20 @@ class Attr : public Node<stringT>
|
|||
const stringT& getValue() const { return attrImpl()->getValue(); }
|
||||
void setValue(const stringT& value) { attrImpl()->setValue(value); }
|
||||
|
||||
Element<stringT> getOwnerElement() const { return Element<stringT>(attrImpl()->getOwnerElement()); }
|
||||
ElementT getOwnerElement() const { return ElementT(attrImpl()->getOwnerElement()); }
|
||||
|
||||
private:
|
||||
Attr_impl<stringT>* attrImpl() const { return dynamic_cast<Attr_impl<stringT>*>(*NodeT::impl_); }
|
||||
Attr_implT* attrImpl() const { return dynamic_cast<Attr_implT*>(*NodeT::impl_); }
|
||||
|
||||
typedef Element<stringT> ElementT;
|
||||
friend class Element<stringT>;
|
||||
friend class Element<stringT, string_adaptorT>;
|
||||
}; // class Attr
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT> class Element_impl;
|
||||
template<class stringT, class string_adaptorT> class Element_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Attr_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Attr_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Attr_impl() { }
|
||||
|
@ -66,7 +69,7 @@ class Attr_impl : virtual public Node_impl<stringT>
|
|||
virtual const stringT& getValue() const = 0;
|
||||
virtual void setValue(const stringT& value) = 0;
|
||||
|
||||
virtual Element_impl<stringT>* getOwnerElement() const = 0;
|
||||
virtual Element_impl<stringT, string_adaptorT>* getOwnerElement() const = 0;
|
||||
}; // class Attr_impl
|
||||
|
||||
} // namespace DOM
|
||||
|
|
|
@ -13,33 +13,33 @@ namespace Arabica
|
|||
{
|
||||
namespace DOM
|
||||
{
|
||||
template<class stringT> class CDATASection_impl;
|
||||
template<class stringT, class string_adaptorT> class CDATASection_impl;
|
||||
|
||||
template<class stringT>
|
||||
class CDATASection : public Text<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class CDATASection : public Text<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Text<stringT> TextT;
|
||||
typedef Text<stringT, string_adaptorT> TextT;
|
||||
public:
|
||||
CDATASection() : Text<stringT>() { }
|
||||
explicit CDATASection(CDATASection_impl<stringT>* impl) : Text<stringT>(impl) { }
|
||||
CDATASection(const CDATASection& rhs) : Text<stringT>(rhs) { }
|
||||
explicit CDATASection(const Node<stringT>& rhs) : Text<stringT>(rhs, 0)
|
||||
CDATASection() : Text<stringT, string_adaptorT>() { }
|
||||
explicit CDATASection(CDATASection_impl<stringT, string_adaptorT>* impl) : Text<stringT, string_adaptorT>(impl) { }
|
||||
CDATASection(const CDATASection& rhs) : Text<stringT, string_adaptorT>(rhs) { }
|
||||
explicit CDATASection(const Node<stringT, string_adaptorT>& rhs) : Text<stringT, string_adaptorT>(rhs, 0)
|
||||
{
|
||||
if(rhs.getNodeType() != Node_base::CDATA_SECTION_NODE)
|
||||
//throw std::runtime_error("bad_cast: Cannot convert Node to CDATA section");
|
||||
throw std::bad_cast();
|
||||
} // CDATASection
|
||||
|
||||
CDATASection<stringT> splitText(int offset)
|
||||
CDATASection<stringT, string_adaptorT> splitText(int offset)
|
||||
{
|
||||
TextT::tImpl()->throwIfReadOnly();
|
||||
return static_cast<CDATASection<stringT> >(TextT::tImpl()->splitText(offset));
|
||||
return static_cast<CDATASection<stringT, string_adaptorT> >(TextT::tImpl()->splitText(offset));
|
||||
} // splitText
|
||||
}; // class CDATASection
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class CDATASection_impl : public virtual Text_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class CDATASection_impl : public virtual Text_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~CDATASection_impl() { }
|
||||
|
|
|
@ -13,17 +13,19 @@ namespace Arabica
|
|||
{
|
||||
namespace DOM
|
||||
{
|
||||
template<class stringT> class CharacterData_impl;
|
||||
template<class stringT, class string_adaptorT> class CharacterData_impl;
|
||||
|
||||
template<class stringT>
|
||||
class CharacterData : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class CharacterData : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef CharacterData_impl<stringT, string_adaptorT> CharacterData_implT;
|
||||
public:
|
||||
CharacterData() : Node<stringT>() { }
|
||||
explicit CharacterData(CharacterData_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
CharacterData(const CharacterData& rhs) : Node<stringT>(rhs) { }
|
||||
explicit CharacterData(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
CharacterData() : NodeT() { }
|
||||
explicit CharacterData(CharacterData_implT* impl) : NodeT(impl) { }
|
||||
CharacterData(const CharacterData& rhs) : NodeT(rhs) { }
|
||||
explicit CharacterData(const NodeT& rhs) : NodeT(rhs)
|
||||
{
|
||||
typename NodeT::Type type = rhs.getNodeType();
|
||||
if((type != NodeT::TEXT_NODE) && (type != NodeT::CDATA_SECTION_NODE))
|
||||
|
@ -31,7 +33,7 @@ class CharacterData : public Node<stringT>
|
|||
} // CharacterData
|
||||
|
||||
protected:
|
||||
CharacterData(const Node<stringT>& rhs, int dummy) : Node<stringT>(rhs) { }
|
||||
CharacterData(const NodeT& rhs, int dummy) : NodeT(rhs) { }
|
||||
|
||||
public:
|
||||
const stringT& getData() const { return cdImpl()->getData(); }
|
||||
|
@ -62,13 +64,13 @@ class CharacterData : public Node<stringT>
|
|||
} // replaceData
|
||||
|
||||
private:
|
||||
CharacterData_impl<stringT>* cdImpl() { return dynamic_cast<CharacterData_impl<stringT>*>(*NodeT::impl_); }
|
||||
const CharacterData_impl<stringT>* cdImpl() const { return dynamic_cast<const CharacterData_impl<stringT>*>(*NodeT::impl_); }
|
||||
CharacterData_implT* cdImpl() { return dynamic_cast<CharacterData_implT*>(*NodeT::impl_); }
|
||||
const CharacterData_implT* cdImpl() const { return dynamic_cast<const CharacterData_implT*>(*NodeT::impl_); }
|
||||
}; // class CharacterData
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class CharacterData_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class CharacterData_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~CharacterData_impl () { }
|
||||
|
|
|
@ -13,25 +13,25 @@ namespace Arabica
|
|||
{
|
||||
namespace DOM
|
||||
{
|
||||
template<class stringT> class Comment_impl;
|
||||
template<class stringT, class string_adaptor> class Comment_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Comment : public CharacterData<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Comment : public CharacterData<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
Comment() : CharacterData<stringT>() { }
|
||||
explicit Comment(Comment_impl<stringT>* impl) : CharacterData<stringT>(dynamic_cast<Comment_impl<stringT>*>(impl)) { }
|
||||
Comment(const Comment& rhs) : CharacterData<stringT>(rhs) { }
|
||||
explicit Comment(const Node<stringT>& rhs) : CharacterData<stringT>(rhs)
|
||||
Comment() : CharacterData<stringT, string_adaptorT>() { }
|
||||
explicit Comment(Comment_impl<stringT, string_adaptorT>* impl) : CharacterData<stringT, string_adaptorT>(dynamic_cast<Comment_impl<stringT, string_adaptorT>*>(impl)) { }
|
||||
Comment(const Comment& rhs) : CharacterData<stringT, string_adaptorT>(rhs) { }
|
||||
explicit Comment(const Node<stringT, string_adaptorT>& rhs) : CharacterData<stringT, string_adaptorT>(rhs)
|
||||
{
|
||||
if(dynamic_cast<Comment_impl<stringT>*>(rhs.impl()) == 0)
|
||||
if(dynamic_cast<Comment_impl<stringT, string_adaptorT>*>(rhs.impl()) == 0)
|
||||
throw std::bad_cast();
|
||||
} // Comment
|
||||
}; // class Comment
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class Comment_impl : virtual public CharacterData_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Comment_impl : virtual public CharacterData_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Comment_impl() { }
|
||||
|
|
|
@ -14,16 +14,16 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Document;
|
||||
template<class stringT> class DocumentType;
|
||||
template<class stringT> class DOMImplementation_impl;
|
||||
template<class stringT, class string_adaptorT> class Document;
|
||||
template<class stringT, class string_adaptorT> class DocumentType;
|
||||
template<class stringT, class string_adaptorT> class DOMImplementation_impl;
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DOMImplementation
|
||||
{
|
||||
public:
|
||||
DOMImplementation() : impl_(0) { }
|
||||
DOMImplementation(DOMImplementation_impl<stringT>* impl) : impl_(impl) { }
|
||||
DOMImplementation(DOMImplementation_impl<stringT, string_adaptorT>* impl) : impl_(impl) { }
|
||||
DOMImplementation(const DOMImplementation& rhs) : impl_(rhs.impl_) { }
|
||||
|
||||
operator bool() const { return impl_; }
|
||||
|
@ -43,31 +43,31 @@ class DOMImplementation
|
|||
return impl_->hasFeature(feature, version);
|
||||
} // hasFeature
|
||||
|
||||
DocumentType<stringT> createDocumentType(const stringT& qualifiedName,
|
||||
DocumentType<stringT, string_adaptorT> createDocumentType(const stringT& qualifiedName,
|
||||
const stringT& publicId,
|
||||
const stringT& systemId)
|
||||
{
|
||||
return impl_->createDocumentType(qualifiedName, publicId, systemId);
|
||||
} // createDocumentType
|
||||
|
||||
Document<stringT> createDocument(const stringT& namespaceURI,
|
||||
Document<stringT, string_adaptorT> createDocument(const stringT& namespaceURI,
|
||||
const stringT& qualifiedName,
|
||||
DocumentType<stringT> docType)
|
||||
DocumentType<stringT, string_adaptorT> docType)
|
||||
{
|
||||
return impl_->createDocument(namespaceURI, qualifiedName, docType.dtImpl());
|
||||
} // createDocument
|
||||
|
||||
private:
|
||||
Proxy<DOMImplementation_impl<stringT> > impl_;
|
||||
Proxy<DOMImplementation_impl<stringT, string_adaptorT> > impl_;
|
||||
}; // class DOMImplementation
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
template<class stringT> class Document_impl;
|
||||
template<class stringT> class DocumentType_impl;
|
||||
template<class stringT, class string_adaptorT> class Document_impl;
|
||||
template<class stringT, class string_adaptorT> class DocumentType_impl;
|
||||
|
||||
// derive from this class to implement your own
|
||||
// DOM provider
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DOMImplementation_impl
|
||||
{
|
||||
public:
|
||||
|
@ -80,13 +80,13 @@ class DOMImplementation_impl
|
|||
// DOM implementation methods
|
||||
virtual bool hasFeature(const stringT& feature, const stringT& version) const = 0;
|
||||
|
||||
virtual DocumentType_impl<stringT>* createDocumentType(const stringT& qualifiedName,
|
||||
virtual DocumentType_impl<stringT, string_adaptorT>* createDocumentType(const stringT& qualifiedName,
|
||||
const stringT& publicId,
|
||||
const stringT& systemId) = 0;
|
||||
|
||||
virtual Document_impl<stringT>* createDocument(const stringT& namespaceURI,
|
||||
virtual Document_impl<stringT, string_adaptorT>* createDocument(const stringT& namespaceURI,
|
||||
const stringT& qualifiedName,
|
||||
DocumentType_impl<stringT>* docType) = 0;
|
||||
DocumentType_impl<stringT, string_adaptorT>* docType) = 0;
|
||||
|
||||
protected:
|
||||
DOMImplementation_impl() { }
|
||||
|
|
|
@ -30,146 +30,146 @@ namespace DOM
|
|||
{
|
||||
|
||||
namespace Events {
|
||||
template<class stringT> class DocumentEvent;
|
||||
template<class stringT, class string_adaptorT> class DocumentEvent;
|
||||
} // namespace Events
|
||||
|
||||
template<class stringT> class Document_impl;
|
||||
template<class stringT, class string_adaptorT> class Document_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Document : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Document : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
public:
|
||||
Document() : Node<stringT>() { }
|
||||
Document(Document_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
Document(const Document& rhs) : Node<stringT>(rhs) { }
|
||||
explicit Document(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
Document() : Node<stringT, string_adaptorT>() { }
|
||||
Document(Document_impl<stringT, string_adaptorT>* impl) : Node<stringT, string_adaptorT>(impl) { }
|
||||
Document(const Document& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
||||
explicit Document(const Node<stringT, string_adaptorT>& rhs) : Node<stringT, string_adaptorT>(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::DOCUMENT_NODE)
|
||||
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::DOCUMENT_NODE)
|
||||
throw std::bad_cast();
|
||||
} // Document
|
||||
~Document() { }
|
||||
|
||||
Document& operator=(const Document& rhs)
|
||||
{
|
||||
Node<stringT>::operator=(rhs);
|
||||
Node<stringT, string_adaptorT>::operator=(rhs);
|
||||
return *this;
|
||||
} // operator
|
||||
|
||||
DocumentType<stringT> getDoctype() const { return dImpl()->getDoctype(); }
|
||||
DocumentType<stringT, string_adaptorT> getDoctype() const { return dImpl()->getDoctype(); }
|
||||
|
||||
DOMImplementation<stringT> getImplementation() const { return DOMImplementation<stringT>(dImpl()->getImplementation()); }
|
||||
DOMImplementation<stringT, string_adaptorT> getImplementation() const { return DOMImplementation<stringT, string_adaptorT>(dImpl()->getImplementation()); }
|
||||
|
||||
Element<stringT> getDocumentElement() const { return Element<stringT>(dImpl()->getDocumentElement()); }
|
||||
Element<stringT, string_adaptorT> getDocumentElement() const { return Element<stringT, string_adaptorT>(dImpl()->getDocumentElement()); }
|
||||
|
||||
Element<stringT> createElement(const stringT& tagName) const { return Element<stringT>(dImpl()->createElement(tagName)); }
|
||||
Element<stringT, string_adaptorT> createElement(const stringT& tagName) const { return Element<stringT, string_adaptorT>(dImpl()->createElement(tagName)); }
|
||||
|
||||
DocumentFragment<stringT> createDocumentFragment() const { return DocumentFragment<stringT>(dImpl()->createDocumentFragment()); }
|
||||
DocumentFragment<stringT, string_adaptorT> createDocumentFragment() const { return DocumentFragment<stringT, string_adaptorT>(dImpl()->createDocumentFragment()); }
|
||||
|
||||
Text<stringT> createTextNode(const stringT& data) const { return Text<stringT>(dImpl()->createTextNode(data)); }
|
||||
Text<stringT, string_adaptorT> createTextNode(const stringT& data) const { return Text<stringT, string_adaptorT>(dImpl()->createTextNode(data)); }
|
||||
|
||||
Comment<stringT> createComment(const stringT& data) const { return Comment<stringT>(dImpl()->createComment(data)); }
|
||||
Comment<stringT, string_adaptorT> createComment(const stringT& data) const { return Comment<stringT, string_adaptorT>(dImpl()->createComment(data)); }
|
||||
|
||||
CDATASection<stringT> createCDATASection(const stringT& data) const { return CDATASection<stringT>(dImpl()->createCDATASection(data)); }
|
||||
CDATASection<stringT, string_adaptorT> createCDATASection(const stringT& data) const { return CDATASection<stringT, string_adaptorT>(dImpl()->createCDATASection(data)); }
|
||||
|
||||
ProcessingInstruction<stringT> createProcessingInstruction(const stringT& target, const stringT& data) const
|
||||
ProcessingInstruction<stringT, string_adaptorT> createProcessingInstruction(const stringT& target, const stringT& data) const
|
||||
{
|
||||
return ProcessingInstruction<stringT>(dImpl()->createProcessingInstruction(target, data));
|
||||
return ProcessingInstruction<stringT, string_adaptorT>(dImpl()->createProcessingInstruction(target, data));
|
||||
} // createProcessingInstruction
|
||||
|
||||
Attr<stringT> createAttribute(const stringT& name) const { return Attr<stringT>(dImpl()->createAttribute(name)); }
|
||||
Attr<stringT, string_adaptorT> createAttribute(const stringT& name) const { return Attr<stringT, string_adaptorT>(dImpl()->createAttribute(name)); }
|
||||
|
||||
EntityReference<stringT> createEntityReference(const stringT& name) const { return EntityReference<stringT>(dImpl()->createEntityReference(name)); }
|
||||
EntityReference<stringT, string_adaptorT> createEntityReference(const stringT& name) const { return EntityReference<stringT, string_adaptorT>(dImpl()->createEntityReference(name)); }
|
||||
|
||||
NodeList<stringT> getElementsByTagName(const stringT& tagname) const { return NodeList<stringT>(dImpl()->getElementsByTagName(tagname)); }
|
||||
NodeList<stringT, string_adaptorT> getElementsByTagName(const stringT& tagname) const { return NodeList<stringT, string_adaptorT>(dImpl()->getElementsByTagName(tagname)); }
|
||||
|
||||
Node<stringT> importNode(const Node<stringT>& importedNode, bool deep) const { return Node<stringT>(dImpl()->importNode(*importedNode.impl_, deep)); }
|
||||
Node<stringT, string_adaptorT> importNode(const Node<stringT, string_adaptorT>& importedNode, bool deep) const { return Node<stringT, string_adaptorT>(dImpl()->importNode(*importedNode.impl_, deep)); }
|
||||
|
||||
Element<stringT> createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
||||
Element<stringT, string_adaptorT> createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
||||
{
|
||||
return Element<stringT>(dImpl()->createElementNS(namespaceURI, qualifiedName));
|
||||
return Element<stringT, string_adaptorT>(dImpl()->createElementNS(namespaceURI, qualifiedName));
|
||||
} // createElementNS
|
||||
|
||||
Attr<stringT> createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
||||
Attr<stringT, string_adaptorT> createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const
|
||||
{
|
||||
return Attr<stringT>(dImpl()->createAttributeNS(namespaceURI, qualifiedName));
|
||||
return Attr<stringT, string_adaptorT>(dImpl()->createAttributeNS(namespaceURI, qualifiedName));
|
||||
} // createAttributeNS
|
||||
|
||||
NodeList<stringT> getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
NodeList<stringT, string_adaptorT> getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return NodeList<stringT>(dImpl()->getElementsByTagNameNS(namespaceURI, localName));
|
||||
return NodeList<stringT, string_adaptorT>(dImpl()->getElementsByTagNameNS(namespaceURI, localName));
|
||||
} // getElementsByTagNameNS
|
||||
|
||||
Element<stringT> getElementById(const stringT& elementId) const { return Element<stringT>(dImpl()->getElementById(elementId)); }
|
||||
Element<stringT, string_adaptorT> getElementById(const stringT& elementId) const { return Element<stringT, string_adaptorT>(dImpl()->getElementById(elementId)); }
|
||||
|
||||
|
||||
Traversal::DocumentTraversal<stringT> createDocumentTraversal()
|
||||
Traversal::DocumentTraversal<stringT, string_adaptorT> createDocumentTraversal()
|
||||
{
|
||||
Traversal::DocumentTraversal<stringT> docTraversal(new Traversal::DocumentTraversalImpl<stringT>());
|
||||
Traversal::DocumentTraversal<stringT, string_adaptorT> docTraversal(new Traversal::DocumentTraversalImpl<stringT, string_adaptorT>());
|
||||
return docTraversal;
|
||||
}
|
||||
|
||||
private:
|
||||
Document_impl<stringT>* dImpl() const { return dynamic_cast<Document_impl<stringT>*>(*NodeT::impl_); }
|
||||
Document_impl<stringT, string_adaptorT>* dImpl() const { return dynamic_cast<Document_impl<stringT, string_adaptorT>*>(*NodeT::impl_); }
|
||||
|
||||
typedef class Traversal::DocumentTraversal<stringT> DocumentTraversalT;
|
||||
friend class Traversal::DocumentTraversal<stringT>;
|
||||
typedef class Events::DocumentEvent<stringT> DocumentEventT;
|
||||
friend class Events::DocumentEvent<stringT>;
|
||||
typedef class Traversal::DocumentTraversal<stringT, string_adaptorT> DocumentTraversalT;
|
||||
friend class Traversal::DocumentTraversal<stringT, string_adaptorT>;
|
||||
typedef class Events::DocumentEvent<stringT, string_adaptorT> DocumentEventT;
|
||||
friend class Events::DocumentEvent<stringT, string_adaptorT>;
|
||||
}; // class DocumentFragment
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT> class DocumentType_impl;
|
||||
template<class stringT> class DOMImplementation_impl;
|
||||
template<class stringT> class Element_impl;
|
||||
template<class stringT> class DocumentFragment_impl;
|
||||
template<class stringT> class Text_impl;
|
||||
template<class stringT> class Comment_impl;
|
||||
template<class stringT> class CDATASection_impl;
|
||||
template<class stringT> class ProcessingInstruction_impl;
|
||||
template<class stringT> class Attr_impl;
|
||||
template<class stringT> class EntityReference_impl;
|
||||
template<class stringT> class NodeList_impl;
|
||||
template<class stringT, class string_adaptorT> class DocumentType_impl;
|
||||
template<class stringT, class string_adaptorT> class DOMImplementation_impl;
|
||||
template<class stringT, class string_adaptorT> class Element_impl;
|
||||
template<class stringT, class string_adaptorT> class DocumentFragment_impl;
|
||||
template<class stringT, class string_adaptorT> class Text_impl;
|
||||
template<class stringT, class string_adaptorT> class Comment_impl;
|
||||
template<class stringT, class string_adaptorT> class CDATASection_impl;
|
||||
template<class stringT, class string_adaptorT> class ProcessingInstruction_impl;
|
||||
template<class stringT, class string_adaptorT> class Attr_impl;
|
||||
template<class stringT, class string_adaptorT> class EntityReference_impl;
|
||||
template<class stringT, class string_adaptorT> class NodeList_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Document_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Document_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Document_impl() { }
|
||||
|
||||
virtual DocumentType_impl<stringT>* getDoctype() const = 0;
|
||||
virtual DocumentType_impl<stringT, string_adaptorT>* getDoctype() const = 0;
|
||||
|
||||
virtual DOMImplementation<stringT> getImplementation() const = 0;
|
||||
virtual DOMImplementation<stringT, string_adaptorT> getImplementation() const = 0;
|
||||
|
||||
virtual Element_impl<stringT>* getDocumentElement() const = 0;
|
||||
virtual Element_impl<stringT, string_adaptorT>* getDocumentElement() const = 0;
|
||||
|
||||
virtual Element_impl<stringT>* createElement(const stringT& tagName) const = 0;
|
||||
virtual Element_impl<stringT, string_adaptorT>* createElement(const stringT& tagName) const = 0;
|
||||
|
||||
virtual DocumentFragment_impl<stringT>* createDocumentFragment() const = 0;
|
||||
virtual DocumentFragment_impl<stringT, string_adaptorT>* createDocumentFragment() const = 0;
|
||||
|
||||
virtual Text_impl<stringT>* createTextNode(const stringT& data) const = 0;
|
||||
virtual Text_impl<stringT, string_adaptorT>* createTextNode(const stringT& data) const = 0;
|
||||
|
||||
virtual Comment_impl<stringT>* createComment(const stringT& data) const = 0;
|
||||
virtual Comment_impl<stringT, string_adaptorT>* createComment(const stringT& data) const = 0;
|
||||
|
||||
virtual CDATASection_impl<stringT>* createCDATASection(const stringT& data) const = 0;
|
||||
virtual CDATASection_impl<stringT, string_adaptorT>* createCDATASection(const stringT& data) const = 0;
|
||||
|
||||
virtual ProcessingInstruction_impl<stringT>* createProcessingInstruction(const stringT& target, const stringT& data) const = 0;
|
||||
virtual ProcessingInstruction_impl<stringT, string_adaptorT>* createProcessingInstruction(const stringT& target, const stringT& data) const = 0;
|
||||
|
||||
virtual Attr_impl<stringT>* createAttribute(const stringT& name) const = 0;
|
||||
virtual Attr_impl<stringT, string_adaptorT>* createAttribute(const stringT& name) const = 0;
|
||||
|
||||
virtual EntityReference_impl<stringT>* createEntityReference(const stringT& name) const = 0;
|
||||
virtual EntityReference_impl<stringT, string_adaptorT>* createEntityReference(const stringT& name) const = 0;
|
||||
|
||||
virtual NodeList_impl<stringT>* getElementsByTagName(const stringT& tagname) const = 0;
|
||||
virtual NodeList_impl<stringT, string_adaptorT>* getElementsByTagName(const stringT& tagname) const = 0;
|
||||
|
||||
virtual Node_impl<stringT>* importNode(Node_impl<stringT>* importedNode, bool deep) const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* importNode(Node_impl<stringT, string_adaptorT>* importedNode, bool deep) const = 0;
|
||||
|
||||
virtual Element_impl<stringT>* createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
||||
virtual Element_impl<stringT, string_adaptorT>* createElementNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
||||
|
||||
virtual Attr_impl<stringT>* createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
||||
virtual Attr_impl<stringT, string_adaptorT>* createAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName) const = 0;
|
||||
|
||||
virtual NodeList_impl<stringT>* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual NodeList_impl<stringT, string_adaptorT>* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
|
||||
virtual Element_impl<stringT>* getElementById(const stringT& elementId) const = 0;
|
||||
virtual Element_impl<stringT, string_adaptorT>* getElementById(const stringT& elementId) const = 0;
|
||||
}; // class Document_impl
|
||||
|
||||
} // namespace DOM
|
||||
|
|
|
@ -15,25 +15,25 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class DocumentFragment_impl;
|
||||
template<class stringT, class string_adaptorT> class DocumentFragment_impl;
|
||||
|
||||
template<class stringT>
|
||||
class DocumentFragment : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentFragment : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
DocumentFragment() : Node<stringT>() { }
|
||||
explicit DocumentFragment(DocumentFragment_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
DocumentFragment(const DocumentFragment& rhs) : Node<stringT>(rhs) { }
|
||||
explicit DocumentFragment(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
DocumentFragment() : Node<stringT, string_adaptorT>() { }
|
||||
explicit DocumentFragment(DocumentFragment_impl<stringT, string_adaptorT>* impl) : Node<stringT, string_adaptorT>(impl) { }
|
||||
DocumentFragment(const DocumentFragment& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
||||
explicit DocumentFragment(const Node<stringT, string_adaptorT>& rhs) : Node<stringT, string_adaptorT>(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::DOCUMENT_FRAGMENT_NODE)
|
||||
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::DOCUMENT_FRAGMENT_NODE)
|
||||
throw std::bad_cast();
|
||||
}
|
||||
}; // class DocumentFragment
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class DocumentFragment_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentFragment_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~DocumentFragment_impl() { }
|
||||
|
|
|
@ -16,28 +16,32 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Document_impl;
|
||||
template<class stringT> class DocumentType_impl;
|
||||
template<class stringT, class string_adaptorT> class Document_impl;
|
||||
template<class stringT, class string_adaptorT> class DocumentType_impl;
|
||||
|
||||
template<class stringT>
|
||||
class DocumentType : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentType : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef DocumentType_impl<stringT, string_adaptorT> DocumentType_implT;
|
||||
public:
|
||||
DocumentType() : Node<stringT>(0) { }
|
||||
DocumentType(DocumentType_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
DocumentType(const DocumentType& rhs) : Node<stringT>(rhs) { }
|
||||
explicit DocumentType(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
typedef NamedNodeMap<stringT, string_adaptorT> NamedNodeMapT;
|
||||
typedef DOMImplementation<stringT, string_adaptorT> DOMImplementationT;
|
||||
|
||||
DocumentType() : NodeT(0) { }
|
||||
DocumentType(DocumentType_implT* impl) : NodeT(impl) { }
|
||||
DocumentType(const DocumentType& rhs) : NodeT(rhs) { }
|
||||
explicit DocumentType(const NodeT& rhs) : NodeT(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::DOCUMENT_TYPE_NODE)
|
||||
if(rhs.getNodeType() != NodeT::DOCUMENT_TYPE_NODE)
|
||||
throw std::bad_cast();
|
||||
} // DocumentType
|
||||
|
||||
const stringT& getName() const { return dtImpl()->getName(); }
|
||||
|
||||
const NamedNodeMap<stringT> getEntities() const { return NamedNodeMap<stringT>(dtImpl()->getEntities()); }
|
||||
const NamedNodeMapT getEntities() const { return NamedNodeMapT(dtImpl()->getEntities()); }
|
||||
|
||||
const NamedNodeMap<stringT> getNotations() const { return NamedNodeMap<stringT>(dtImpl()->getNotations()); }
|
||||
const NamedNodeMapT getNotations() const { return NamedNodeMapT(dtImpl()->getNotations()); }
|
||||
|
||||
stringT getPublicId() const { return dtImpl()->getPublicId(); }
|
||||
|
||||
|
@ -46,26 +50,27 @@ class DocumentType : public Node<stringT>
|
|||
stringT getInternalSubset() const { return dtImpl()->getInternalSubset(); }
|
||||
|
||||
protected:
|
||||
DocumentType_impl<stringT>* dtImpl() const { return dynamic_cast<DocumentType_impl<stringT>*>(*NodeT::impl_); }
|
||||
DocumentType_implT* dtImpl() const { return dynamic_cast<DocumentType_implT*>(*NodeT::impl_); }
|
||||
|
||||
typedef DOMImplementation<stringT> DOMImplementationT;
|
||||
friend class DOMImplementation<stringT>;
|
||||
friend class DOMImplementation<stringT, string_adaptorT>;
|
||||
}; // class DocumentType
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class DocumentType_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentType_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
typedef NamedNodeMap_impl<stringT, string_adaptorT> NamedNodeMap_implT;
|
||||
|
||||
virtual ~DocumentType_impl() { }
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// DOM::DocumentType methods
|
||||
virtual const stringT& getName() const = 0;
|
||||
|
||||
virtual NamedNodeMap_impl<stringT>* getEntities() = 0;
|
||||
virtual NamedNodeMap_implT* getEntities() = 0;
|
||||
|
||||
virtual NamedNodeMap_impl<stringT>* getNotations() = 0;
|
||||
virtual NamedNodeMap_implT* getNotations() = 0;
|
||||
|
||||
virtual stringT getPublicId() const = 0;
|
||||
|
||||
|
|
|
@ -16,21 +16,25 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Attr;
|
||||
template<class stringT> class NodeList;
|
||||
template<class stringT> class Element_impl;
|
||||
template<class stringT, class string_adaptorT> class Attr;
|
||||
template<class stringT, class string_adaptorT> class NodeList;
|
||||
template<class stringT, class string_adaptorT> class Element_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Element : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Element : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef Element_impl<stringT, string_adaptorT> Element_implT;
|
||||
public:
|
||||
Element() : Node<stringT>() { }
|
||||
explicit Element(Element_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
Element(const Element& rhs) : Node<stringT>(rhs) { }
|
||||
explicit Element(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
typedef NodeList<stringT, string_adaptorT> NodeListT;
|
||||
typedef Attr<stringT, string_adaptorT> AttrT;
|
||||
|
||||
Element() : NodeT() { }
|
||||
explicit Element(Element_implT* impl) : NodeT(impl) { }
|
||||
Element(const Element& rhs) : NodeT(rhs) { }
|
||||
explicit Element(const NodeT& rhs) : NodeT(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::ELEMENT_NODE)
|
||||
if(rhs.getNodeType() != NodeT::ELEMENT_NODE)
|
||||
throw std::bad_cast();
|
||||
} // Element
|
||||
|
||||
|
@ -40,34 +44,37 @@ class Element : public Node<stringT>
|
|||
void setAttribute(const stringT& name, const stringT& value) { eImpl()->setAttribute(name, value); }
|
||||
void removeAttribute(const stringT& name) { eImpl()->removeAttribute(name); }
|
||||
|
||||
Attr<stringT> getAttributeNode(const stringT& name) const { return Attr<stringT>(eImpl()->getAttributeNode(name)); }
|
||||
Attr<stringT> setAttributeNode(const Attr<stringT>& newAttr) { return Attr<stringT>(eImpl()->setAttributeNode(newAttr.attrImpl())); }
|
||||
Attr<stringT> removeAttributeNode(const Attr<stringT>& oldAttr) { return Attr<stringT>(eImpl()->removeAttributeNode(oldAttr.attrImpl())); }
|
||||
AttrT getAttributeNode(const stringT& name) const { return AttrT(eImpl()->getAttributeNode(name)); }
|
||||
AttrT setAttributeNode(const AttrT& newAttr) { return AttrT(eImpl()->setAttributeNode(newAttr.attrImpl())); }
|
||||
AttrT removeAttributeNode(const AttrT& oldAttr) { return AttrT(eImpl()->removeAttributeNode(oldAttr.attrImpl())); }
|
||||
|
||||
NodeList<stringT> getElementsByTagName(const stringT& tagName) const { return NodeList<stringT>(eImpl()->getElementsByTagName(tagName)); }
|
||||
NodeListT getElementsByTagName(const stringT& tagName) const { return NodeListT(eImpl()->getElementsByTagName(tagName)); }
|
||||
|
||||
stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const { return eImpl()->getAttributeNS(namespaceURI, localName); }
|
||||
void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value) { eImpl()->setAttributeNS(namespaceURI, qualifiedName, value); }
|
||||
void removeAttributeNS(const stringT& namespaceURI, const stringT& localName) { return eImpl()->removeAttributeNS(namespaceURI, localName); }
|
||||
|
||||
Attr<stringT> getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const { return Attr<stringT>(eImpl()->getAttributeNodeNS(namespaceURI, localName)); }
|
||||
Attr<stringT> setAttributeNodeNS(const Attr<stringT>& newAttr) { return Attr<stringT>(eImpl()->getAttributeNodeNS(newAttr)); }
|
||||
AttrT getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const { return AttrT(eImpl()->getAttributeNodeNS(namespaceURI, localName)); }
|
||||
AttrT setAttributeNodeNS(const AttrT& newAttr) { return AttrT(eImpl()->getAttributeNodeNS(newAttr)); }
|
||||
|
||||
NodeList<stringT> getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const { return NodeList<stringT>(eImpl()->getElementsByTagNameNS(namespaceURI, localName)); }
|
||||
NodeListT getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const { return NodeListT(eImpl()->getElementsByTagNameNS(namespaceURI, localName)); }
|
||||
|
||||
bool hasAttribute(const stringT& name) const { return eImpl()->hasAttribute(name); }
|
||||
|
||||
bool hasAttributeNS(const stringT& namespaceURI, const stringT& localName) const { return eImpl()->hasAttributeNS(namespaceURI, localName); }
|
||||
|
||||
private:
|
||||
Element_impl<stringT>* eImpl() const { return dynamic_cast<Element_impl<stringT>*>(*NodeT::impl_); }
|
||||
Element_implT* eImpl() const { return dynamic_cast<Element_implT*>(*NodeT::impl_); }
|
||||
}; // class Element
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class Element_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Element_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
typedef NodeList_impl<stringT, string_adaptorT> NodeList_implT;
|
||||
typedef Attr_impl<stringT, string_adaptorT> Attr_implT;
|
||||
|
||||
virtual ~Element_impl () { }
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
@ -78,20 +85,20 @@ class Element_impl : virtual public Node_impl<stringT>
|
|||
virtual void setAttribute(const stringT& name, const stringT& value) = 0;
|
||||
virtual void removeAttribute(const stringT& name) = 0;
|
||||
|
||||
virtual Attr_impl<stringT>* getAttributeNode(const stringT& name) const = 0;
|
||||
virtual Attr_impl<stringT>* setAttributeNode(Attr_impl<stringT>* newAttr) = 0;
|
||||
virtual Attr_impl<stringT>* removeAttributeNode(Attr_impl<stringT>* oldAttr) = 0;
|
||||
virtual Attr_implT* getAttributeNode(const stringT& name) const = 0;
|
||||
virtual Attr_implT* setAttributeNode(Attr_implT* newAttr) = 0;
|
||||
virtual Attr_implT* removeAttributeNode(Attr_implT* oldAttr) = 0;
|
||||
|
||||
virtual NodeList_impl<stringT>* getElementsByTagName(const stringT& tagName) const = 0;
|
||||
virtual NodeList_implT* getElementsByTagName(const stringT& tagName) const = 0;
|
||||
|
||||
virtual stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value) = 0;
|
||||
virtual void removeAttributeNS(const stringT& namespaceURI, const stringT& localName) = 0;
|
||||
|
||||
virtual Attr_impl<stringT>* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual Attr_impl<stringT>* setAttributeNodeNS(Attr_impl<stringT>* newAttr) = 0;
|
||||
virtual Attr_implT* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual Attr_implT* setAttributeNodeNS(Attr_implT* newAttr) = 0;
|
||||
|
||||
virtual NodeList_impl<stringT>* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual NodeList_implT* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
|
||||
virtual bool hasAttribute(const stringT& name) const = 0;
|
||||
|
||||
|
|
|
@ -14,19 +14,19 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Entity_impl;
|
||||
template<class stringT, class string_adaptorT> class Entity_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Entity : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Entity : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
public:
|
||||
Entity() : Node<stringT>() { }
|
||||
explicit Entity(Entity_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
Entity(const Entity& rhs) : Node<stringT>(rhs) { }
|
||||
explicit Entity(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
Entity() : Node<stringT, string_adaptorT>() { }
|
||||
explicit Entity(Entity_impl<stringT, string_adaptorT>* impl) : Node<stringT>(impl) { }
|
||||
Entity(const Entity& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
||||
explicit Entity(const Node<stringT, string_adaptorT>& rhs) : Node<stringT>(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::Entity_NODE)
|
||||
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::Entity_NODE)
|
||||
throw std::bad_cast();
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,14 @@ class Entity : public Node<stringT>
|
|||
stringT getNotationName() const { nImpl()->getNotationName(); }
|
||||
|
||||
private:
|
||||
Entity_impl<stringT>* nImpl() { return dynamic_cast<Entity_impl<stringT>*>(NodeT::impl()); }
|
||||
Entity_impl<stringT, string_adaptorT>* nImpl() { return dynamic_cast<Entity_impl<stringT>*>(NodeT::impl()); }
|
||||
}; // class Entity
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT> class NamedNodeMap_impl;
|
||||
template<class stringT, class string_adaptorT> class NamedNodeMap_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Entity_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Entity_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Entity_impl () { }
|
||||
|
|
|
@ -13,25 +13,29 @@ namespace Arabica
|
|||
{
|
||||
namespace DOM
|
||||
{
|
||||
template<class stringT> class EntityReference_impl;
|
||||
template<class stringT, class string_adaptorT> class EntityReference_impl;
|
||||
|
||||
template<class stringT>
|
||||
class EntityReference : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class EntityReference : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef EntityReference_impl<stringT, string_adaptorT> EntityReference_implT;
|
||||
|
||||
public:
|
||||
EntityReference() : Node<stringT>() { }
|
||||
explicit EntityReference(EntityReference_impl<stringT>* impl) : Node<stringT>(impl) { }
|
||||
EntityReference(const EntityReference& rhs) : Node<stringT>(rhs) { }
|
||||
explicit EntityReference(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
EntityReference() : NodeT() { }
|
||||
explicit EntityReference(EntityReference_implT* impl) : NodeT(impl) { }
|
||||
EntityReference(const EntityReference& rhs) : NodeT(rhs) { }
|
||||
explicit EntityReference(const NodeT& rhs) : NodeT(rhs)
|
||||
{
|
||||
if(dynamic_cast<EntityReference_impl<stringT>*>(rhs.impl()) == 0)
|
||||
if(dynamic_cast<EntityReference_implT*>(rhs.impl()) == 0)
|
||||
throw std::bad_cast();
|
||||
} // EntityReference
|
||||
}; // class EntityReference
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class EntityReference_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class EntityReference_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~EntityReference_impl () { }
|
||||
|
|
|
@ -14,15 +14,17 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Node;
|
||||
template<class stringT> class NamedNodeMap_impl;
|
||||
template<class stringT, class string_adaptorT> class Node;
|
||||
template<class stringT, class string_adaptorT> class NamedNodeMap_impl;
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NamedNodeMap
|
||||
{
|
||||
public:
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
NamedNodeMap() : impl_(0) { }
|
||||
explicit NamedNodeMap(NamedNodeMap_impl<stringT>* impl) : impl_(impl) { }
|
||||
explicit NamedNodeMap(NamedNodeMap_impl<stringT, string_adaptorT>* impl) : impl_(impl) { }
|
||||
NamedNodeMap(const NamedNodeMap& rhs) : impl_(rhs.impl_) { }
|
||||
virtual ~NamedNodeMap() { }
|
||||
|
||||
|
@ -37,40 +39,42 @@ class NamedNodeMap
|
|||
return *this;
|
||||
} // operator=
|
||||
|
||||
Node<stringT> getNamedItem(const stringT& name) const { return Node<stringT>(impl_->getNamedItem(name)); }
|
||||
NodeT getNamedItem(const stringT& name) const { return NodeT(impl_->getNamedItem(name)); }
|
||||
|
||||
Node<stringT> setNamedItem(const Node<stringT>& arg) { return Node<stringT>(impl_->setNamedItem(arg)); }
|
||||
NodeT setNamedItem(const NodeT& arg) { return NodeT(impl_->setNamedItem(arg)); }
|
||||
|
||||
Node<stringT> removeNamedItem(const stringT& name) const { return Node<stringT>(impl_->removeNamedItem(name)); }
|
||||
NodeT removeNamedItem(const stringT& name) const { return NodeT(impl_->removeNamedItem(name)); }
|
||||
|
||||
Node<stringT> item(unsigned int index) const { return Node<stringT>(impl_->item(index)); }
|
||||
NodeT item(unsigned int index) const { return NodeT(impl_->item(index)); }
|
||||
|
||||
unsigned int getLength() const { return impl_->getLength(); }
|
||||
|
||||
Node<stringT> getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
NodeT getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return Node<stringT>(impl_->getNamedItemNS(namespaceURI, localName));
|
||||
return NodeT(impl_->getNamedItemNS(namespaceURI, localName));
|
||||
} // getNamedItemNS
|
||||
|
||||
Node<stringT> setNamedItemNS(const Node<stringT>& arg) { return Node<stringT>(impl_->setNamedItemNS(arg)); }
|
||||
NodeT setNamedItemNS(const NodeT& arg) { return NodeT(impl_->setNamedItemNS(arg)); }
|
||||
|
||||
Node<stringT> removeNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
NodeT removeNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return Node<stringT>(impl_->removeNamedItem(namespaceURI, localName));
|
||||
return NodeT(impl_->removeNamedItem(namespaceURI, localName));
|
||||
} // removeNamedItemNS
|
||||
|
||||
private:
|
||||
Proxy<NamedNodeMap_impl<stringT> > impl_;
|
||||
Proxy<NamedNodeMap_impl<stringT, string_adaptorT> > impl_;
|
||||
}; // class NamedNodeMap
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// NamedNodeMap_impl
|
||||
template<class stringT> class Node_impl;
|
||||
template<class stringT, class string_adaptorT> class Node_impl;
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NamedNodeMap_impl
|
||||
{
|
||||
public:
|
||||
typedef Node_impl<stringT, string_adaptorT> Node_implT;
|
||||
|
||||
virtual ~NamedNodeMap_impl() { }
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
@ -80,17 +84,17 @@ class NamedNodeMap_impl
|
|||
|
||||
///////////////////////////////////////////////////////
|
||||
// NamedNodeMap methods
|
||||
virtual Node_impl<stringT>* getNamedItem(const stringT& name) const = 0;
|
||||
virtual Node_impl<stringT>* setNamedItem(Node_impl<stringT>* arg) = 0;
|
||||
virtual Node_impl<stringT>* removeNamedItem(const stringT& name) = 0;
|
||||
virtual Node_implT* getNamedItem(const stringT& name) const = 0;
|
||||
virtual Node_implT* setNamedItem(Node_implT* arg) = 0;
|
||||
virtual Node_implT* removeNamedItem(const stringT& name) = 0;
|
||||
|
||||
virtual Node_impl<stringT>* item(unsigned int index) const = 0;
|
||||
virtual Node_implT* item(unsigned int index) const = 0;
|
||||
|
||||
virtual unsigned int getLength() const = 0;
|
||||
|
||||
virtual Node_impl<stringT>* getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual Node_impl<stringT>* setNamedItemNS(Node_impl<stringT>* arg) = 0;
|
||||
virtual Node_impl<stringT>* removeNamedItemNS(const stringT& namespaceURI, const stringT& localName) = 0;
|
||||
virtual Node_implT* getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const = 0;
|
||||
virtual Node_implT* setNamedItemNS(Node_implT* arg) = 0;
|
||||
virtual Node_implT* removeNamedItemNS(const stringT& namespaceURI, const stringT& localName) = 0;
|
||||
}; // class NamedNodeMap_impl
|
||||
|
||||
} // namespace DOM
|
||||
|
|
|
@ -17,13 +17,13 @@ namespace DOM
|
|||
{
|
||||
|
||||
namespace Events {
|
||||
template<class stringT> class EventTarget;
|
||||
template<class stringT, class string_adaptorT> class EventTarget;
|
||||
} // namespace Events
|
||||
|
||||
template<class stringT> class Document;
|
||||
template<class stringT> class NodeList;
|
||||
template<class stringT> class NamedNodeMap;
|
||||
template<class stringT> class Node_impl;
|
||||
template<class stringT, class string_adaptorT> class Document;
|
||||
template<class stringT, class string_adaptorT> class NodeList;
|
||||
template<class stringT, class string_adaptorT> class NamedNodeMap;
|
||||
template<class stringT, class string_adaptorT> class Node_impl;
|
||||
|
||||
class Node_base
|
||||
{
|
||||
|
@ -47,14 +47,12 @@ class Node_base
|
|||
}; // class Node_base
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
template<class node_string_type>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Node : public Node_base
|
||||
{
|
||||
public:
|
||||
typedef node_string_type string_type;
|
||||
|
||||
Node() : impl_() { }
|
||||
Node(Node_impl<string_type>* const impl) : impl_(impl) { }
|
||||
Node(Node_impl<stringT, string_adaptorT>* const impl) : impl_(impl) { }
|
||||
Node(const Node& rhs) : impl_(rhs.impl_) { }
|
||||
virtual ~Node() { }
|
||||
|
||||
|
@ -70,25 +68,25 @@ class Node : public Node_base
|
|||
return *this;
|
||||
} // operator=
|
||||
|
||||
const string_type& getNodeName() const { return impl_->getNodeName(); }
|
||||
const stringT& getNodeName() const { return impl_->getNodeName(); }
|
||||
|
||||
const string_type& getNodeValue() const { return impl_->getNodeValue(); }
|
||||
void setNodeValue(const string_type& nodeValue) { impl_->setNodeValue(nodeValue); }
|
||||
const stringT& getNodeValue() const { return impl_->getNodeValue(); }
|
||||
void setNodeValue(const stringT& nodeValue) { impl_->setNodeValue(nodeValue); }
|
||||
|
||||
Type getNodeType() const { return impl_->getNodeType(); }
|
||||
|
||||
Node getParentNode() const { return impl_->getParentNode(); }
|
||||
|
||||
const NodeList<string_type> getChildNodes() const { return NodeList<string_type>(impl_->getChildNodes()); }
|
||||
const NodeList<stringT, string_adaptorT> getChildNodes() const { return NodeList<stringT, string_adaptorT>(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<string_type> getAttributes() const { return NamedNodeMap<string_type>(impl_->getAttributes()); }
|
||||
const NamedNodeMap<stringT, string_adaptorT> getAttributes() const { return NamedNodeMap<stringT, string_adaptorT>(impl_->getAttributes()); }
|
||||
|
||||
Document<string_type> getOwnerDocument() const { return impl_->getOwnerDocument(); }
|
||||
Document<stringT, string_adaptorT> 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_); }
|
||||
|
@ -96,7 +94,7 @@ class Node : public Node_base
|
|||
Node appendChild(const Node& newChild) { return impl_->appendChild(*newChild.impl_); }
|
||||
void purgeChild(Node& oldChild)
|
||||
{
|
||||
Node_impl<string_type>* child = *oldChild.impl_;
|
||||
Node_impl<stringT, string_adaptorT>* child = *oldChild.impl_;
|
||||
oldChild = 0;
|
||||
|
||||
try {
|
||||
|
@ -115,15 +113,15 @@ class Node : public Node_base
|
|||
|
||||
void normalize() { impl_->normalize(); }
|
||||
|
||||
bool isSupported(const string_type& feature, const string_type& version) const { return impl_->isSupported(feature, version); }
|
||||
bool isSupported(const stringT& feature, const stringT& version) const { return impl_->isSupported(feature, version); }
|
||||
|
||||
const string_type& getNamespaceURI() const { return impl_->getNamespaceURI(); }
|
||||
const string_type& getPrefix() const { return impl_->getPrefix(); }
|
||||
void setPrefix(const string_type& prefix) const { impl_->setPrefix(prefix); }
|
||||
const string_type& getLocalName() const { return impl_->getLocalName(); }
|
||||
const stringT& getNamespaceURI() const { return impl_->getNamespaceURI(); }
|
||||
const stringT& getPrefix() const { return impl_->getPrefix(); }
|
||||
void setPrefix(const stringT& prefix) const { impl_->setPrefix(prefix); }
|
||||
const stringT& getLocalName() const { return impl_->getLocalName(); }
|
||||
|
||||
// additional three methods - since C++ std::string (and by implication
|
||||
// string_type) don't differenciate between a null string and an empty string,
|
||||
// stringT) 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
|
||||
|
@ -134,25 +132,25 @@ class Node : public Node_base
|
|||
bool hasAttributes() const { return impl_->hasAttributes(); }
|
||||
|
||||
// you almost certainly don't need to use this function
|
||||
Node_impl<string_type>* unlying_impl() const { return *impl_; }
|
||||
Node_impl<stringT, string_adaptorT>* unlying_impl() const { return *impl_; }
|
||||
|
||||
protected:
|
||||
Proxy<Node_impl<string_type> > impl_;
|
||||
Proxy<Node_impl<stringT, string_adaptorT> > impl_;
|
||||
|
||||
typedef class Document<string_type> DocumentT;
|
||||
friend class Document<string_type>;
|
||||
typedef class Events::EventTarget<string_type> EventTargetT;
|
||||
friend class Events::EventTarget<string_type>;
|
||||
typedef class Document<stringT, string_adaptorT> DocumentT;
|
||||
friend class Document<stringT, string_adaptorT>;
|
||||
typedef class Events::EventTarget<stringT, string_adaptorT> EventTargetT;
|
||||
friend class Events::EventTarget<stringT, string_adaptorT>;
|
||||
}; // class Node
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// derive from this class to implement your own
|
||||
// DOM provider
|
||||
template<class string_type> class Document_impl;
|
||||
template<class string_type> class NodeList_impl;
|
||||
template<class string_type> class NamedNodeMap_impl;
|
||||
template<class stringT, class string_adaptorT> class Document_impl;
|
||||
template<class stringT, class string_adaptorT> class NodeList_impl;
|
||||
template<class stringT, class string_adaptorT> class NamedNodeMap_impl;
|
||||
|
||||
template<class string_type>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Node_impl
|
||||
{
|
||||
public:
|
||||
|
@ -165,48 +163,48 @@ class Node_impl
|
|||
|
||||
///////////////////////////////////////////////////////
|
||||
// Node methods
|
||||
virtual const string_type& getNodeName() const = 0;
|
||||
virtual const stringT& getNodeName() const = 0;
|
||||
|
||||
virtual const string_type& getNodeValue() const = 0;
|
||||
virtual void setNodeValue(const string_type& nodeValue) = 0;
|
||||
virtual const stringT& getNodeValue() const = 0;
|
||||
virtual void setNodeValue(const stringT& nodeValue) = 0;
|
||||
|
||||
virtual Node_base::Type getNodeType() const = 0;
|
||||
|
||||
virtual Node_impl<string_type>* getParentNode() const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* getParentNode() const = 0;
|
||||
|
||||
virtual NodeList_impl<string_type>* getChildNodes() const = 0;
|
||||
virtual NodeList_impl<stringT, string_adaptorT>* getChildNodes() const = 0;
|
||||
|
||||
virtual Node_impl<string_type>* getFirstChild() const = 0;
|
||||
virtual Node_impl<string_type>* getLastChild() const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* getFirstChild() const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* getLastChild() const = 0;
|
||||
|
||||
virtual Node_impl<string_type>* getPreviousSibling() const = 0;
|
||||
virtual Node_impl<string_type>* getNextSibling() const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* getPreviousSibling() const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* getNextSibling() const = 0;
|
||||
|
||||
virtual NamedNodeMap_impl<string_type>* getAttributes() const = 0;
|
||||
virtual NamedNodeMap_impl<stringT, string_adaptorT>* getAttributes() const = 0;
|
||||
|
||||
virtual Document_impl<string_type>* getOwnerDocument() const = 0;
|
||||
virtual Document_impl<stringT, string_adaptorT>* getOwnerDocument() const = 0;
|
||||
|
||||
virtual Node_impl<string_type>* insertBefore(Node_impl<string_type>* newChild, Node_impl<string_type>* refChild) = 0;
|
||||
virtual Node_impl<string_type>* replaceChild(Node_impl<string_type>* newChild, Node_impl<string_type>* oldChild) = 0;
|
||||
virtual Node_impl<string_type>* removeChild(Node_impl<string_type>* oldChild) = 0;
|
||||
virtual Node_impl<string_type>* appendChild(Node_impl<string_type>* newChild) = 0;
|
||||
virtual void purgeChild(Node_impl<string_type>* oldChild) = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* insertBefore(Node_impl<stringT, string_adaptorT>* newChild, Node_impl<stringT, string_adaptorT>* refChild) = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* replaceChild(Node_impl<stringT, string_adaptorT>* newChild, Node_impl<stringT, string_adaptorT>* oldChild) = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* removeChild(Node_impl<stringT, string_adaptorT>* oldChild) = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* appendChild(Node_impl<stringT, string_adaptorT>* newChild) = 0;
|
||||
virtual void purgeChild(Node_impl<stringT, string_adaptorT>* oldChild) = 0;
|
||||
|
||||
virtual bool hasChildNodes() const = 0;
|
||||
|
||||
virtual Node_impl<string_type>* cloneNode(bool deep) const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* cloneNode(bool deep) const = 0;
|
||||
|
||||
virtual void normalize() = 0;
|
||||
|
||||
virtual bool isSupported(const string_type& feature, const string_type& version) const = 0;
|
||||
virtual bool isSupported(const stringT& feature, const stringT& version) const = 0;
|
||||
|
||||
virtual const string_type& getNamespaceURI() const = 0;
|
||||
virtual const string_type& getPrefix() const = 0;
|
||||
virtual void setPrefix(const string_type& prefix) = 0;
|
||||
virtual const string_type& getLocalName() const = 0;
|
||||
virtual const stringT& getNamespaceURI() const = 0;
|
||||
virtual const stringT& getPrefix() const = 0;
|
||||
virtual void setPrefix(const stringT& prefix) = 0;
|
||||
virtual const stringT& getLocalName() const = 0;
|
||||
|
||||
// additional methods - since C++ std::string (and by implication
|
||||
// string_type) don't differenciate between a null string and an empty string,
|
||||
// stringT) 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
|
||||
|
|
|
@ -14,15 +14,15 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Node;
|
||||
template<class stringT> class NodeList_impl;
|
||||
template<class stringT, class string_adaptorT> class Node;
|
||||
template<class stringT, class string_adaptorT> class NodeList_impl;
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NodeList
|
||||
{
|
||||
public:
|
||||
NodeList() : impl_(0) { }
|
||||
explicit NodeList(NodeList_impl<stringT>* const impl) : impl_(impl) { }
|
||||
explicit NodeList(NodeList_impl<stringT, string_adaptorT>* const impl) : impl_(impl) { }
|
||||
NodeList(const NodeList& rhs) : impl_(rhs.impl_) { }
|
||||
virtual ~NodeList() { }
|
||||
|
||||
|
@ -37,16 +37,16 @@ class NodeList
|
|||
return *this;
|
||||
} // operator=
|
||||
|
||||
Node<stringT> item(unsigned int index) const { return impl_->item(index); }
|
||||
Node<stringT, string_adaptorT> item(unsigned int index) const { return impl_->item(index); }
|
||||
|
||||
unsigned int getLength() const { return impl_->getLength(); }
|
||||
|
||||
private:
|
||||
Proxy<NodeList_impl<stringT> > impl_;
|
||||
Proxy<NodeList_impl<stringT, string_adaptorT> > impl_;
|
||||
}; // class NodeList
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NodeList_impl
|
||||
{
|
||||
public:
|
||||
|
@ -59,7 +59,7 @@ class NodeList_impl
|
|||
|
||||
///////////////////////////////////////////////////////
|
||||
// NodeList methods
|
||||
virtual Node_impl<stringT>* item(unsigned int index) const = 0;
|
||||
virtual Node_impl<stringT, string_adaptorT>* item(unsigned int index) const = 0;
|
||||
|
||||
virtual unsigned int getLength() const = 0;
|
||||
}; // class NodeList_impl
|
||||
|
|
|
@ -15,19 +15,19 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class Notation_impl;
|
||||
template<class stringT, class string_adaptorT> class Notation_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Notation : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Notation : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
public:
|
||||
Notation() : Node<stringT>() { }
|
||||
explicit Notation(Notation_impl<stringT>* impl) : Node<stringT>(dynamic_cast<Node_impl<stringT>*>(impl)) { }
|
||||
Notation(const Notation& rhs) : Node<stringT>(rhs) { }
|
||||
explicit Notation(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
Notation() : Node<stringT, string_adaptorT>() { }
|
||||
explicit Notation(Notation_impl<stringT, string_adaptorT>* impl) : Node<stringT>(dynamic_cast<Node_impl<stringT>*>(impl)) { }
|
||||
Notation(const Notation& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
||||
explicit Notation(const Node<stringT, string_adaptorT>& rhs) : Node<stringT>(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::NOTATION_NODE)
|
||||
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::NOTATION_NODE)
|
||||
throw std::bad_cast();
|
||||
}
|
||||
|
||||
|
@ -36,14 +36,14 @@ class Notation : public Node<stringT>
|
|||
stringT getSystemId() const { nImpl()->getSystemId(); }
|
||||
|
||||
private:
|
||||
Notation_impl<stringT>* nImpl() { return dynamic_cast<Notation_impl<stringT>*>(NodeT::impl()); }
|
||||
Notation_impl<stringT, string_adaptorT>* nImpl() { return dynamic_cast<Notation_impl<stringT>*>(NodeT::impl()); }
|
||||
}; // class Notation
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT> class NamedNodeMap_impl;
|
||||
template<class stringT, class string_adaptorT> class NamedNodeMap_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Notation_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Notation_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Notation_impl () { }
|
||||
|
|
|
@ -14,19 +14,19 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT> class ProcessingInstruction_impl;
|
||||
template<class stringT, class string_adaptorT> class ProcessingInstruction_impl;
|
||||
|
||||
template<class stringT>
|
||||
class ProcessingInstruction : public Node<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class ProcessingInstruction : public Node<stringT, string_adaptorT>
|
||||
{
|
||||
typedef Node<stringT> NodeT;
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
public:
|
||||
ProcessingInstruction() : Node<stringT>(0) { }
|
||||
explicit ProcessingInstruction(ProcessingInstruction_impl<stringT>* impl) : Node<stringT>(dynamic_cast<Node_impl<stringT>*>(impl)) { }
|
||||
ProcessingInstruction(const ProcessingInstruction& rhs) : Node<stringT>(rhs) { }
|
||||
explicit ProcessingInstruction(const Node<stringT>& rhs) : Node<stringT>(rhs)
|
||||
ProcessingInstruction() : Node<stringT, string_adaptorT>(0) { }
|
||||
explicit ProcessingInstruction(ProcessingInstruction_impl<stringT, string_adaptorT>* impl) : Node<stringT, string_adaptorT>(dynamic_cast<Node_impl<stringT, string_adaptorT>*>(impl)) { }
|
||||
ProcessingInstruction(const ProcessingInstruction& rhs) : Node<stringT, string_adaptorT>(rhs) { }
|
||||
explicit ProcessingInstruction(const Node<stringT, string_adaptorT>& rhs) : Node<stringT, string_adaptorT>(rhs)
|
||||
{
|
||||
if(rhs.getNodeType() != Node<stringT>::PROCESSING_INSTRUCTION_NODE)
|
||||
if(rhs.getNodeType() != Node<stringT, string_adaptorT>::PROCESSING_INSTRUCTION_NODE)
|
||||
throw std::bad_cast();
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ class ProcessingInstruction : public Node<stringT>
|
|||
void setData(const stringT& data) { piImpl()->setData(data); }
|
||||
|
||||
private:
|
||||
ProcessingInstruction_impl<stringT>* piImpl() const { return dynamic_cast<ProcessingInstruction_impl<stringT>*>(*NodeT::impl_); }
|
||||
ProcessingInstruction_impl<stringT, string_adaptorT>* piImpl() const { return dynamic_cast<ProcessingInstruction_impl<stringT, string_adaptorT>*>(*NodeT::impl_); }
|
||||
}; // class DocumentFragment
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class ProcessingInstruction_impl : virtual public Node_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class ProcessingInstruction_impl : virtual public Node_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~ProcessingInstruction_impl () { }
|
||||
|
|
|
@ -14,13 +14,17 @@ namespace SimpleDOM
|
|||
template<class stringT, class string_adaptorT> class ElementImpl;
|
||||
|
||||
template<class stringT, class string_adaptorT>
|
||||
class AttrImpl : public DOM::Attr_impl<stringT>,
|
||||
class AttrImpl : public DOM::Attr_impl<stringT, string_adaptorT>,
|
||||
public NodeImplWithChildren<stringT, string_adaptorT>
|
||||
{
|
||||
typedef NodeImplWithChildren<stringT, string_adaptorT> NodeT;
|
||||
public:
|
||||
typedef NodeImplWithChildren<stringT, string_adaptorT> NodeT;
|
||||
typedef ElementImpl<stringT, string_adaptorT> ElementImpl;
|
||||
typedef DOM::Attr_impl<stringT, string_adaptorT> DOMAttr_implT;
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
|
||||
|
||||
AttrImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& name) :
|
||||
DOM::Attr_impl<stringT>(),
|
||||
DOMAttr_implT(),
|
||||
NodeImplWithChildren<stringT, string_adaptorT>(ownerDoc),
|
||||
name_(ownerDoc->stringPool(name)),
|
||||
ownerElement_(0),
|
||||
|
@ -30,7 +34,7 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
} // AttrImpl
|
||||
|
||||
AttrImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& name, const stringT& value) :
|
||||
DOM::Attr_impl<stringT>(),
|
||||
DOMAttr_implT(),
|
||||
NodeImplWithChildren<stringT, string_adaptorT>(ownerDoc),
|
||||
name_(ownerDoc->stringPool(name)),
|
||||
ownerElement_(0),
|
||||
|
@ -61,16 +65,16 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
|
||||
/////////////////////////////////////////////////////
|
||||
// DOM::Node methods
|
||||
virtual typename DOM::Node<stringT>::Type getNodeType() const
|
||||
virtual typename DOM::Node_base::Type getNodeType() const
|
||||
{
|
||||
return DOM::Node<stringT>::ATTRIBUTE_NODE;
|
||||
return DOM::Node_base::ATTRIBUTE_NODE;
|
||||
} // getNodeType
|
||||
|
||||
virtual DOM::Node_impl<stringT>* getParentNode() const { return 0; }
|
||||
virtual DOM::Node_impl<stringT>* getPreviousSibling() const { return 0; }
|
||||
virtual DOM::Node_impl<stringT>* getNextSibling() const { return 0; }
|
||||
virtual DOMNode_implT* getParentNode() const { return 0; }
|
||||
virtual DOMNode_implT* getPreviousSibling() const { return 0; }
|
||||
virtual DOMNode_implT* getNextSibling() const { return 0; }
|
||||
|
||||
virtual DOM::Node_impl<stringT>* cloneNode(bool deep) const
|
||||
virtual DOMNode_implT* cloneNode(bool deep) const
|
||||
{
|
||||
AttrImpl* a = dynamic_cast<AttrImpl*>(NodeT::ownerDoc_->createAttribute(*name_));
|
||||
cloneChildren(a);
|
||||
|
@ -88,7 +92,7 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
if(!valueCalculated_)
|
||||
{
|
||||
value_ = string_adaptorT::construct_from_utf8("");
|
||||
for(DOM::Node_impl<stringT>* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
for(DOMNode_implT* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
string_adaptorT::append(value_, c->getNodeValue());
|
||||
valueCalculated_ = true;
|
||||
}
|
||||
|
@ -100,7 +104,7 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
NodeT::throwIfReadOnly();
|
||||
|
||||
// remove all children
|
||||
for(DOM::Node_impl<stringT>* c = NodeT::getFirstChild(); c != 0; c = NodeT::getFirstChild())
|
||||
for(DOMNode_implT* c = NodeT::getFirstChild(); c != 0; c = NodeT::getFirstChild())
|
||||
NodeT::removeChild(c);
|
||||
|
||||
// add a new text node
|
||||
|
@ -112,7 +116,7 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// this implementation
|
||||
void setOwnerElement(ElementImpl<stringT, string_adaptorT>* element)
|
||||
void setOwnerElement(ElementImplT* element)
|
||||
{
|
||||
ownerElement_ = element;
|
||||
if(NodeT::ownerDoc_)
|
||||
|
@ -132,22 +136,22 @@ class AttrImpl : public DOM::Attr_impl<stringT>,
|
|||
protected:
|
||||
void cloneChildren(AttrImpl* clone) const
|
||||
{
|
||||
for(DOM::Node_impl<stringT>* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
for(DOMNode_implT* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
clone->appendChild(c->cloneNode(true));
|
||||
} // cloneChildren
|
||||
|
||||
private:
|
||||
virtual void checkChildType(DOM::Node_impl<stringT>* child)
|
||||
virtual void checkChildType(DOMNode_implT* child)
|
||||
{
|
||||
typename DOM::Node<stringT>::Type type = child->getNodeType();
|
||||
if((type != DOM::Node<stringT>::TEXT_NODE) &&
|
||||
(type != DOM::Node<stringT>::ENTITY_REFERENCE_NODE))
|
||||
typename DOM::Node_base::Type type = child->getNodeType();
|
||||
if((type != DOM::Node_base::TEXT_NODE) &&
|
||||
(type != DOM::Node_base::ENTITY_REFERENCE_NODE))
|
||||
throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR);
|
||||
} // checkChildType
|
||||
|
||||
protected:
|
||||
stringT const* name_;
|
||||
ElementImpl<stringT, string_adaptorT>* ownerElement_;
|
||||
ElementImplT* ownerElement_;
|
||||
bool specified_;
|
||||
mutable bool valueCalculated_;
|
||||
mutable stringT value_;
|
||||
|
|
|
@ -13,10 +13,17 @@ namespace SimpleDOM
|
|||
template<class stringT, class string_adaptorT>
|
||||
class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
||||
{
|
||||
typedef NamedNodeMapImpl<stringT, string_adaptorT> MapT;
|
||||
public:
|
||||
AttrMap(DocumentImpl<stringT, string_adaptorT>* ownerDoc) :
|
||||
NamedNodeMapImpl<stringT, string_adaptorT>(ownerDoc),
|
||||
typedef NamedNodeMapImpl<stringT, string_adaptorT> MapT;
|
||||
typedef AttrImpl<stringT, string_adaptorT> AttrImplT;
|
||||
typedef AttrNSImpl<stringT, string_adaptorT> AttrNSImplT;
|
||||
typedef ElementImpl<stringT, string_adaptorT> ElementImplT;
|
||||
typedef DocumentImpl<stringT, string_adaptorT> DocumentImplT;
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
|
||||
typedef DOM::Attr_impl<stringT, string_adaptorT> DOMAttr_implT;
|
||||
typedef DOM::NamedNodeMap_impl<stringT, string_adaptorT> DOMNamedNodeMap_implT;
|
||||
AttrMap(DocumentImplT* ownerDoc) :
|
||||
NamedNodeMapImplT(ownerDoc),
|
||||
ownerElement_(0)
|
||||
{
|
||||
} // AttrMap
|
||||
|
@ -28,13 +35,13 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
|||
/////////////////////////////////////////////////////
|
||||
const stringT& getAttribute(const stringT& name) const
|
||||
{
|
||||
DOM::Node_impl<stringT>* attr = MapT::getNamedItem(name);
|
||||
DOMNode_implT* attr = MapT::getNamedItem(name);
|
||||
return attr ? attr->getNodeValue() : MapT::ownerDoc_->empty_string();
|
||||
} // getAttribute
|
||||
|
||||
void setAttribute(const stringT& name, const stringT& value)
|
||||
{
|
||||
AttrImpl<stringT, string_adaptorT>* a = new AttrImpl<stringT, string_adaptorT>(MapT::ownerDoc_, name, value);
|
||||
AttrImplT* a = new AttrImplT(MapT::ownerDoc_, name, value);
|
||||
a->setOwnerElement(ownerElement_);
|
||||
MapT::setNamedItem(a);
|
||||
} // setAttribute
|
||||
|
@ -45,18 +52,18 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
|||
createDefault(name);
|
||||
} // removeAttribute
|
||||
|
||||
DOM::Attr_impl<stringT>* getAttributeNode(const stringT& name) const
|
||||
DOMAttr_implT* getAttributeNode(const stringT& name) const
|
||||
{
|
||||
return dynamic_cast<DOM::Attr_impl<stringT>*>(MapT::getNamedItem(name));
|
||||
return dynamic_cast<DOMAttr_implT*>(MapT::getNamedItem(name));
|
||||
} // getAttributeNode
|
||||
|
||||
DOM::Attr_impl<stringT>* setAttributeNode(DOM::Attr_impl<stringT>* newAttr)
|
||||
DOMAttr_implT* setAttributeNode(DOMAttr_implT* newAttr)
|
||||
{
|
||||
dynamic_cast<AttrImpl<stringT, string_adaptorT>*>(newAttr)->setOwnerElement(ownerElement_);
|
||||
return dynamic_cast<DOM::Attr_impl<stringT>*>(MapT::setNamedItem(newAttr));
|
||||
dynamic_cast<AttrImplT*>(newAttr)->setOwnerElement(ownerElement_);
|
||||
return dynamic_cast<DOMAttr_implT*>(MapT::setNamedItem(newAttr));
|
||||
} // setAttributeNode
|
||||
|
||||
DOM::Attr_impl<stringT>* removeAttributeNode(DOM::Attr_impl<stringT>* oldAttr)
|
||||
DOMAttr_implT* removeAttributeNode(DOMAttr_implT* oldAttr)
|
||||
{
|
||||
if(MapT::removeNamedItem(oldAttr->getNodeName()) == 0)
|
||||
throw DOM::DOMException(DOM::DOMException::NOT_FOUND_ERR);
|
||||
|
@ -66,17 +73,16 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
|||
|
||||
stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
DOM::Node_impl<stringT>* attr = MapT::getNamedItemNS(namespaceURI, localName);
|
||||
DOMNode_implT* attr = MapT::getNamedItemNS(namespaceURI, localName);
|
||||
return attr ? attr->getNodeValue() : stringT();
|
||||
} // getAttributeNS
|
||||
|
||||
void setAttributeNS(const stringT& namespaceURI, const stringT& qualifiedName, const stringT& value)
|
||||
{
|
||||
AttrNSImpl<stringT, string_adaptorT>* a =
|
||||
new AttrNSImpl<stringT, string_adaptorT>(MapT::ownerDoc_,
|
||||
namespaceURI,
|
||||
!string_adaptorT::empty(namespaceURI),
|
||||
qualifiedName);
|
||||
AttrNSImplT* a = new AttrNSImplT(MapT::ownerDoc_,
|
||||
namespaceURI,
|
||||
!string_adaptorT::empty(namespaceURI),
|
||||
qualifiedName);
|
||||
a->setValue(value);
|
||||
a->setOwnerElement(ownerElement_);
|
||||
MapT::setNamedItemNS(a);
|
||||
|
@ -88,15 +94,15 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
|||
createDefault(namespaceURI, localName);
|
||||
} // removeAttributeNS
|
||||
|
||||
DOM::Attr_impl<stringT>* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
DOMAttr_implT* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return dynamic_cast<DOM::Attr_impl<stringT>*>(MapT::getNamedItemNS(namespaceURI, localName));
|
||||
return dynamic_cast<DOMAttr_implT*>(MapT::getNamedItemNS(namespaceURI, localName));
|
||||
} // getAttributeNodeNS
|
||||
|
||||
DOM::Attr_impl<stringT>* setAttributeNodeNS(DOM::Attr_impl<stringT>* newAttr)
|
||||
DOMAttr_implT* setAttributeNodeNS(DOMAttr_implT* newAttr)
|
||||
{
|
||||
dynamic_cast<AttrImpl<stringT, string_adaptorT>*>(newAttr)->setOwnerElement(ownerElement_);
|
||||
return dynamic_cast<DOM::Attr_impl<stringT>*>(MapT::setNamedItemNS(newAttr));
|
||||
dynamic_cast<AttrImplT*>(newAttr)->setOwnerElement(ownerElement_);
|
||||
return dynamic_cast<DOMAttr_implT*>(MapT::setNamedItemNS(newAttr));
|
||||
} // setAttributeNodeNS
|
||||
|
||||
bool hasAttribute(const stringT& name) const
|
||||
|
@ -109,71 +115,71 @@ class AttrMap : public NamedNodeMapImpl<stringT, string_adaptorT>
|
|||
return (MapT::getNamedItemNS(namespaceURI, localName) != 0);
|
||||
} // hasAttributeNS
|
||||
|
||||
void setOwnerElement(ElementImpl<stringT, string_adaptorT>* element)
|
||||
void setOwnerElement(ElementImplT* element)
|
||||
{
|
||||
ownerElement_ = element;
|
||||
getDefaults();
|
||||
} // setOwnerElement
|
||||
|
||||
virtual void setOwnerDoc(DocumentImpl<stringT, string_adaptorT>* ownerDoc)
|
||||
virtual void setOwnerDoc(DocumentImplT* ownerDoc)
|
||||
{
|
||||
NamedNodeMapImpl<stringT, string_adaptorT>::setOwnerDoc(ownerDoc);
|
||||
NamedNodeMapImplT::setOwnerDoc(ownerDoc);
|
||||
getDefaults();
|
||||
} // setOwnerDoc
|
||||
|
||||
private:
|
||||
void createDefault(const stringT& name)
|
||||
{
|
||||
DOM::NamedNodeMap_impl<stringT>* attrs = getDefaultAttrs();
|
||||
DOMNamedNodeMap_implT* attrs = getDefaultAttrs();
|
||||
if(attrs)
|
||||
{
|
||||
DOM::Node_impl<stringT>* attr = attrs->getNamedItem(name);
|
||||
DOMNode_implT* attr = attrs->getNamedItem(name);
|
||||
if(attr)
|
||||
setAttributeNode(dynamic_cast<DOM::Attr_impl<stringT>*>(attr->cloneNode(true)));
|
||||
setAttributeNode(dynamic_cast<DOMAttr_implT*>(attr->cloneNode(true)));
|
||||
}
|
||||
} // createDefault
|
||||
|
||||
void createDefault(const stringT& namespaceURI, const stringT& localName)
|
||||
{
|
||||
DOM::NamedNodeMap_impl<stringT>* attrs = getDefaultAttrs();
|
||||
DOMNamedNodeMap_implT* attrs = getDefaultAttrs();
|
||||
if(attrs)
|
||||
{
|
||||
DOM::Node_impl<stringT>* attr = attrs->getNamedItemNS(namespaceURI, localName);
|
||||
DOMNode_implT* attr = attrs->getNamedItemNS(namespaceURI, localName);
|
||||
if(attr)
|
||||
setAttributeNodeNS(dynamic_cast<DOM::Attr_impl<stringT>*>(attr->cloneNode(true)));
|
||||
setAttributeNodeNS(dynamic_cast<DOMAttr_implT*>(attr->cloneNode(true)));
|
||||
}
|
||||
} // createDefault
|
||||
|
||||
void getDefaults()
|
||||
{
|
||||
DOM::NamedNodeMap_impl<stringT>* attrs = getDefaultAttrs();
|
||||
DOMNamedNodeMap_implT* attrs = getDefaultAttrs();
|
||||
if(attrs)
|
||||
{
|
||||
for(unsigned int i = 0; i < attrs->getLength(); ++i)
|
||||
{
|
||||
DOM::Node_impl<stringT>* attr = attrs->item(i);
|
||||
DOMNode_implT* attr = attrs->item(i);
|
||||
if(getAttributeNodeNS(attr->getNamespaceURI(), attr->getNodeName()) == 0)
|
||||
setAttributeNodeNS(dynamic_cast<DOM::Attr_impl<stringT>*>(attr->cloneNode(true)));
|
||||
setAttributeNodeNS(dynamic_cast<DOMAttr_implT*>(attr->cloneNode(true)));
|
||||
}
|
||||
}
|
||||
} // getDefaults
|
||||
|
||||
DOM::NamedNodeMap_impl<stringT>* getDefaultAttrs()
|
||||
DOMNamedNodeMap_implT* getDefaultAttrs()
|
||||
{
|
||||
if(!MapT::ownerDoc_)
|
||||
return 0;
|
||||
|
||||
DocumentTypeImpl<stringT, string_adaptorT>* docType = dynamic_cast<DocumentTypeImpl<stringT, string_adaptorT>*>(MapT::ownerDoc_->getDoctype());
|
||||
DocumentTypeImplT* docType = dynamic_cast<DocumentTypeImplT*>(MapT::ownerDoc_->getDoctype());
|
||||
if(docType)
|
||||
{
|
||||
DOM::Node_impl<stringT>* exemplar = docType->getElements()->getNamedItem(ownerElement_->getNodeName());
|
||||
DOMNode_implT* exemplar = docType->getElements()->getNamedItem(ownerElement_->getNodeName());
|
||||
if(exemplar)
|
||||
return exemplar->getAttributes();
|
||||
}
|
||||
return 0;
|
||||
} // getDefaultAttrs
|
||||
|
||||
ElementImpl<stringT, string_adaptorT>* ownerElement_;
|
||||
ElementImplT* ownerElement_;
|
||||
}; // class AttrMap
|
||||
|
||||
|
||||
|
|
|
@ -12,15 +12,16 @@ namespace SimpleDOM
|
|||
template<class stringT, class string_adaptorT>
|
||||
class AttrNSImpl : public AttrImpl<stringT, string_adaptorT>
|
||||
{
|
||||
typedef typename string_adaptorT::size_type size_type;
|
||||
typedef AttrImpl<stringT, string_adaptorT> AttrT;
|
||||
|
||||
public:
|
||||
typedef typename string_adaptorT::size_type size_type;
|
||||
typedef AttrImpl<stringT, string_adaptorT> AttrImplT;
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT
|
||||
|
||||
AttrNSImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc,
|
||||
const stringT& namespaceURI,
|
||||
bool hasNamespaceURI,
|
||||
const stringT& qualifiedName) :
|
||||
AttrImpl<stringT, string_adaptorT>(ownerDoc, qualifiedName),
|
||||
AttrImplT(ownerDoc, qualifiedName),
|
||||
prefix_(&ownerDoc->empty_string()),
|
||||
hasNamespaceURI_(false)
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ class AttrNSImpl : public AttrImpl<stringT, string_adaptorT>
|
|||
|
||||
if(index == string_adaptorT::npos())
|
||||
{ //qualifiedName contains no ':'
|
||||
localName_ = AttrT::ownerDoc_->stringPool(qualifiedName);
|
||||
localName_ = AttrImplT::ownerDoc_->stringPool(qualifiedName);
|
||||
if(*localName_ == string_adaptorT::construct_from_utf8("xmlns"))
|
||||
{
|
||||
hasPrefix = true;
|
||||
|
@ -40,27 +41,27 @@ class AttrNSImpl : public AttrImpl<stringT, string_adaptorT>
|
|||
else
|
||||
{
|
||||
hasPrefix = true;
|
||||
prefix_ = AttrT::ownerDoc_->stringPool(string_adaptorT::substr(qualifiedName, 0, index));
|
||||
localName_ = AttrT::ownerDoc_->stringPool(string_adaptorT::substr(qualifiedName, index+1));
|
||||
prefix_ = AttrImplT::ownerDoc_->stringPool(string_adaptorT::substr(qualifiedName, 0, index));
|
||||
localName_ = AttrImplT::ownerDoc_->stringPool(string_adaptorT::substr(qualifiedName, index+1));
|
||||
prefix_for_checking = prefix_;
|
||||
} // if(index == string_adaptorT::npos)
|
||||
|
||||
std::pair<bool, stringT> mappedURI =
|
||||
checkPrefixAndNamespace<stringT, string_adaptorT>(hasPrefix, *prefix_for_checking, hasNamespaceURI, namespaceURI, DOM::Node<stringT>::ATTRIBUTE_NODE);
|
||||
checkPrefixAndNamespace<stringT, string_adaptorT>(hasPrefix, *prefix_for_checking, hasNamespaceURI, namespaceURI, DOM::Node_base::ATTRIBUTE_NODE);
|
||||
|
||||
hasNamespaceURI_ = mappedURI.first;
|
||||
namespaceURI_ = AttrT::ownerDoc_->stringPool(mappedURI.second);
|
||||
namespaceURI_ = AttrImplT::ownerDoc_->stringPool(mappedURI.second);
|
||||
} // AttrImpl
|
||||
|
||||
virtual ~AttrNSImpl() { }
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// DOM::Node methods
|
||||
virtual DOM::Node_impl<stringT>* cloneNode(bool deep) const
|
||||
virtual DOMNode_impl* cloneNode(bool deep) const
|
||||
{
|
||||
AttrNSImpl* clone = dynamic_cast<AttrNSImpl*>(AttrT::ownerDoc_->createAttributeNS(*namespaceURI_, *AttrT::name_));
|
||||
AttrT::cloneChildren(clone);
|
||||
clone->setSpecified(AttrT::getSpecified());
|
||||
AttrNSImpl* clone = dynamic_cast<AttrNSImpl*>(AttrImplT::ownerDoc_->createAttributeNS(*namespaceURI_, *AttrImplT::name_));
|
||||
AttrImplT::cloneChildren(clone);
|
||||
clone->setSpecified(AttrImplT::getSpecified());
|
||||
return clone;
|
||||
} // cloneNode
|
||||
|
||||
|
@ -81,19 +82,19 @@ class AttrNSImpl : public AttrImpl<stringT, string_adaptorT>
|
|||
|
||||
if(string_adaptorT::empty(prefix))
|
||||
{
|
||||
AttrT::name_ = localName_;
|
||||
prefix_ = &AttrT::ownerDoc_->empty_string();
|
||||
AttrImplT::name_ = localName_;
|
||||
prefix_ = &AttrImplT::ownerDoc_->empty_string();
|
||||
return;
|
||||
} // empty prefix
|
||||
|
||||
checkPrefixAndNamespace<stringT, string_adaptorT>(true, prefix, true, *namespaceURI_, DOM::Node<stringT>::ATTRIBUTE_NODE);
|
||||
checkPrefixAndNamespace<stringT, string_adaptorT>(true, prefix, true, *namespaceURI_, DOM::Node_base::ATTRIBUTE_NODE);
|
||||
|
||||
stringT newName = prefix;
|
||||
string_adaptorT::append(newName, string_adaptorT::construct_from_utf8(":"));
|
||||
string_adaptorT::append(newName, *localName_);
|
||||
|
||||
prefix_ = AttrT::ownerDoc_->stringPool(prefix);
|
||||
AttrT::name_ = AttrT::ownerDoc_->stringPool(newName);
|
||||
prefix_ = AttrImplT::ownerDoc_->stringPool(prefix);
|
||||
AttrImplT::name_ = AttrImplT::ownerDoc_->stringPool(newName);
|
||||
} // setPrefix
|
||||
|
||||
virtual const stringT& getLocalName() const
|
||||
|
@ -114,7 +115,7 @@ class AttrNSImpl : public AttrImpl<stringT, string_adaptorT>
|
|||
|
||||
virtual bool hasPrefix() const
|
||||
{
|
||||
return !(*prefix_ == AttrT::ownerDoc_->empty_string());
|
||||
return !(*prefix_ == AttrImplT::ownerDoc_->empty_string());
|
||||
} // hasPrefix
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,13 +9,16 @@ namespace SimpleDOM
|
|||
{
|
||||
|
||||
template<class stringT, class string_adaptorT>
|
||||
class CDATASectionImpl : public DOM::CDATASection_impl<stringT>,
|
||||
class CDATASectionImpl : public DOM::CDATASection_impl<stringT, string_adaptorT>,
|
||||
public CharacterDataImpl<stringT, string_adaptorT>
|
||||
{
|
||||
typedef CharacterDataImpl<stringT, string_adaptorT> CharDataT;
|
||||
public:
|
||||
typedef CharacterDataImpl<stringT, string_adaptorT> CharacterDataImplT;
|
||||
typedef DOM::Text_impl<stringT, string_adaptorT> DOMText_implT;
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
|
||||
|
||||
CDATASectionImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& data) :
|
||||
CharacterDataImpl<stringT, string_adaptorT>(ownerDoc, data)
|
||||
CharacterDataImplT(ownerDoc, data)
|
||||
{
|
||||
} // CDATASectionImpl
|
||||
|
||||
|
@ -24,15 +27,15 @@ class CDATASectionImpl : public DOM::CDATASection_impl<stringT>,
|
|||
//////////////////////////////////////////////////////////////////
|
||||
// DOM::CDATASection methods
|
||||
// on a compiler which implemented covariant return types this would return DOM::CDATASection
|
||||
virtual DOM::Text_impl<stringT>* splitText(int offset)
|
||||
virtual DOMText_implT* splitText(int offset)
|
||||
{
|
||||
CharDataT::throwIfReadOnly();
|
||||
CharacterDataImplT::throwIfReadOnly();
|
||||
|
||||
stringT second = CharDataT::substringData(offset, CharDataT::getLength() - offset);
|
||||
CharDataT::deleteData(offset, CharDataT::getLength() - offset);
|
||||
stringT second = CharacterDataImplT::substringData(offset, CharacterDataImplT::getLength() - offset);
|
||||
CharacterDataImplT::deleteData(offset, CharacterDataImplT::getLength() - offset);
|
||||
|
||||
CDATASectionImpl* splitNode = new CDATASectionImpl(CharDataT::getOwnerDoc(), second);
|
||||
CharDataT::getParentNode()->insertBefore(splitNode, CharDataT::getNextSibling());
|
||||
CDATASectionImpl* splitNode = new CDATASectionImpl(CharacterDataImplT::getOwnerDoc(), second);
|
||||
CharacterDataImplT::getParentNode()->insertBefore(splitNode, CharacterDataImplT::getNextSibling());
|
||||
return splitNode;
|
||||
} // splitText
|
||||
|
||||
|
@ -43,9 +46,9 @@ class CDATASectionImpl : public DOM::CDATASection_impl<stringT>,
|
|||
return DOM::Node_base::CDATA_SECTION_NODE;
|
||||
} // getNodeType
|
||||
|
||||
virtual DOM::Node_impl<stringT>* cloneNode(bool deep) const
|
||||
virtual DOMNode_implT* cloneNode(bool deep) const
|
||||
{
|
||||
return CharDataT::ownerDoc_->createCDATASection(CharDataT::getData());
|
||||
return CharacterDataImplT::ownerDoc_->createCDATASection(CharacterDataImplT::getData());
|
||||
} // cloneNode
|
||||
|
||||
virtual const stringT& getNodeName() const
|
||||
|
|
|
@ -13,13 +13,13 @@ template<class stringT, class string_adaptorT>
|
|||
class DocumentImpl;
|
||||
|
||||
template<class stringT, class string_adaptorT>
|
||||
class ElementByTagList : public DOM::NodeList_impl<stringT>
|
||||
class ElementByTagList : public DOM::NodeList_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
ElementByTagList(DocumentImpl<stringT, string_adaptorT>* ownerDoc,
|
||||
DOM::Node_impl<stringT>* rootNode,
|
||||
DOM::Node_impl<stringT, string_adaptorT>* rootNode,
|
||||
const stringT& tagName) :
|
||||
DOM::NodeList_impl<stringT>(),
|
||||
DOM::NodeList_impl<stringT, string_adaptorT>(),
|
||||
rootNode_(rootNode),
|
||||
ownerDoc_(ownerDoc),
|
||||
tagName_(tagName),
|
||||
|
@ -34,10 +34,10 @@ class ElementByTagList : public DOM::NodeList_impl<stringT>
|
|||
} // ElementByTagList
|
||||
|
||||
ElementByTagList(DocumentImpl<stringT, string_adaptorT>* ownerDoc,
|
||||
DOM::Node_impl<stringT>* rootNode,
|
||||
DOM::Node_impl<stringT, string_adaptorT>* rootNode,
|
||||
const stringT& namespaceURI,
|
||||
const stringT& localName) :
|
||||
DOM::NodeList_impl<stringT>(),
|
||||
DOM::NodeList_impl<stringT, string_adaptorT>(),
|
||||
rootNode_(rootNode),
|
||||
ownerDoc_(ownerDoc),
|
||||
namespaceURI_(namespaceURI),
|
||||
|
@ -72,7 +72,7 @@ class ElementByTagList : public DOM::NodeList_impl<stringT>
|
|||
|
||||
/////////////////////////////////////////////////
|
||||
// DOM::NodeList methods
|
||||
virtual DOM::Node_impl<stringT>* item(unsigned int index) const
|
||||
virtual DOM::Node_impl<stringT, string_adaptorT>* item(unsigned int index) const
|
||||
{
|
||||
if(index >= nodes_.size())
|
||||
return 0;
|
||||
|
@ -102,29 +102,29 @@ class ElementByTagList : public DOM::NodeList_impl<stringT>
|
|||
changes_ = ownerDoc_->changes();
|
||||
} // populate
|
||||
|
||||
void checkNode(DOM::Node_impl<stringT>* node) const
|
||||
void checkNode(DOM::Node_impl<stringT, string_adaptorT>* node) const
|
||||
{
|
||||
if(useNamespace_)
|
||||
{
|
||||
if((node->hasNamespaceURI() && namespaceURI_ == node->getNamespaceURI()) || allNamespaces_)
|
||||
{
|
||||
if((tagName_ == node->getLocalName()) || (allNames_ && node->getNodeType() == DOM::Node<stringT>::ELEMENT_NODE))
|
||||
if((tagName_ == node->getLocalName()) || (allNames_ && node->getNodeType() == DOM::Node<stringT, string_adaptorT>::ELEMENT_NODE))
|
||||
nodes_.push_back(node);
|
||||
}
|
||||
}
|
||||
else
|
||||
if((tagName_ == node->getNodeName()) || (allNames_ && node->getNodeType() == DOM::Node<stringT>::ELEMENT_NODE))
|
||||
if((tagName_ == node->getNodeName()) || (allNames_ && node->getNodeType() == DOM::Node<stringT, string_adaptorT>::ELEMENT_NODE))
|
||||
nodes_.push_back(node);
|
||||
|
||||
for(DOM::Node_impl<stringT>* child = node->getFirstChild(); child != 0; child = child->getNextSibling())
|
||||
if(child->getNodeType() == DOM::Node<stringT>::ELEMENT_NODE)
|
||||
for(DOM::Node_impl<stringT, string_adaptorT>* child = node->getFirstChild(); child != 0; child = child->getNextSibling())
|
||||
if(child->getNodeType() == DOM::Node<stringT, string_adaptorT>::ELEMENT_NODE)
|
||||
checkNode(child);
|
||||
} // checkNode
|
||||
|
||||
|
||||
typedef std::deque<DOM::Node_impl<stringT>*> NodeListT;
|
||||
typedef std::deque<DOM::Node_impl<stringT, string_adaptorT>*> NodeListT;
|
||||
mutable NodeListT nodes_;
|
||||
DOM::Node_impl<stringT>* rootNode_;
|
||||
DOM::Node_impl<stringT, string_adaptorT>* rootNode_;
|
||||
DocumentImpl<stringT, string_adaptorT>* ownerDoc_;
|
||||
stringT namespaceURI_;
|
||||
stringT tagName_;
|
||||
|
|
|
@ -12,16 +12,24 @@ namespace SimpleDOM
|
|||
{
|
||||
|
||||
template<class stringT, class string_adaptorT>
|
||||
class ElementImpl : public DOM::Element_impl<stringT>,
|
||||
class ElementImpl : public DOM::Element_impl<stringT, string_adaptorT>,
|
||||
public NodeImplWithChildren<stringT, string_adaptorT>
|
||||
{
|
||||
protected:
|
||||
typedef NodeImplWithChildren<stringT, string_adaptorT> NodeT;
|
||||
typedef DocumentImpl<stringT, string_adaptorT> DocumentImplT;
|
||||
typedef AttrMap<stringT, string_adaptorT> AttrMapT;
|
||||
typedef ElementByTagList<stringT, string_adaptorT> ElementByTagListT;
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
|
||||
typedef DOM::Attr_impl<stringT, string_adaptorT> DOMAttr_implT;
|
||||
typedef DOM::NodeList_impl<stringT, string_adaptorT> DOMNodeList_implT;
|
||||
typedef DOM::NamedNodeMap_impl<stringT, string_adaptorT> DOMNamedNodeMap_implT;
|
||||
typedef DOM::Element_impl<stringT, string_adaptorT> DOMElement_implT;
|
||||
|
||||
public:
|
||||
ElementImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& tagName) :
|
||||
DOM::Element_impl<stringT>(),
|
||||
NodeImplWithChildren<stringT, string_adaptorT>(ownerDoc),
|
||||
ElementImpl(DocumentImplT* ownerDoc, const stringT& tagName) :
|
||||
DOMElement_implT(),
|
||||
NodeT(ownerDoc),
|
||||
attributes_(ownerDoc),
|
||||
tagName_(ownerDoc->stringPool(tagName))
|
||||
{
|
||||
|
@ -51,26 +59,26 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
attributes_.removeAttribute(name);
|
||||
} // removeAttribute
|
||||
|
||||
virtual DOM::Attr_impl<stringT>* getAttributeNode(const stringT& name) const
|
||||
virtual DOMAttr_implT* getAttributeNode(const stringT& name) const
|
||||
{
|
||||
return attributes_.getAttributeNode(name);
|
||||
} // getAttributeNode
|
||||
|
||||
virtual DOM::Attr_impl<stringT>* setAttributeNode(DOM::Attr_impl<stringT>* newAttr)
|
||||
virtual DOMAttr_implT* setAttributeNode(DOMAttr_implT* newAttr)
|
||||
{
|
||||
return attributes_.setAttributeNode(newAttr);
|
||||
} // setAttributeNode
|
||||
|
||||
virtual DOM::Attr_impl<stringT>* removeAttributeNode(DOM::Attr_impl<stringT>* oldAttr)
|
||||
virtual DOMAttr_implT* removeAttributeNode(DOMAttr_implT* oldAttr)
|
||||
{
|
||||
return attributes_.removeAttributeNode(oldAttr);
|
||||
} // removeAttributeNode
|
||||
|
||||
virtual DOM::NodeList_impl<stringT>* getElementsByTagName(const stringT& tagName) const
|
||||
virtual DOMNodeList_implT* getElementsByTagName(const stringT& tagName) const
|
||||
{
|
||||
return new ElementByTagList<stringT, string_adaptorT>(NodeT::ownerDoc_,
|
||||
const_cast<ElementImpl*>(this),
|
||||
tagName);
|
||||
return new ElementByTagListT(NodeT::ownerDoc_,
|
||||
const_cast<ElementImpl*>(this),
|
||||
tagName);
|
||||
} // getElementsByTagName
|
||||
|
||||
virtual stringT getAttributeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
|
@ -88,21 +96,22 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
attributes_.removeAttributeNS(namespaceURI, localName);
|
||||
} // removeAttributeNS
|
||||
|
||||
virtual DOM::Attr_impl<stringT>* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
virtual DOMAttr_implT* getAttributeNodeNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return attributes_.getAttributeNodeNS(namespaceURI, localName);
|
||||
} // getAttributeNodeNS
|
||||
|
||||
virtual DOM::Attr_impl<stringT>* setAttributeNodeNS(DOM::Attr_impl<stringT>* newAttr)
|
||||
virtual DOMAttr_implT* setAttributeNodeNS(DOMAttr_implT* newAttr)
|
||||
{
|
||||
return attributes_.setAttributeNodeNS(newAttr);
|
||||
} // setAttributeNodeNS
|
||||
|
||||
virtual DOM::NodeList_impl<stringT>* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
virtual DOMNodeList_implT* getElementsByTagNameNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return new ElementByTagList<stringT, string_adaptorT>(NodeT::ownerDoc_,
|
||||
const_cast<ElementImpl*>(this),
|
||||
namespaceURI, localName);
|
||||
return new ElementByTagListT(NodeT::ownerDoc_,
|
||||
const_cast<ElementImpl*>(this),
|
||||
namespaceURI,
|
||||
localName);
|
||||
} // getElementsByTagNameNS
|
||||
|
||||
virtual bool hasAttribute(const stringT& name) const
|
||||
|
@ -127,12 +136,12 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
return *tagName_;
|
||||
} // getNodeName
|
||||
|
||||
virtual DOM::NamedNodeMap_impl<stringT>* getAttributes() const
|
||||
virtual DOMNamedNodeMap_implT* getAttributes() const
|
||||
{
|
||||
return const_cast<AttrMap<stringT, string_adaptorT>*>(&attributes_);
|
||||
return const_cast<AttrMapT*>(&attributes_);
|
||||
} // getAttributes
|
||||
|
||||
virtual DOM::Node_impl<stringT>* cloneNode(bool deep) const
|
||||
virtual DOMNode_impl* cloneNode(bool deep) const
|
||||
{
|
||||
ElementImpl* clone = dynamic_cast<ElementImpl*>(NodeT::ownerDoc_->createElement(*tagName_));
|
||||
cloneChildren(clone, deep);
|
||||
|
@ -144,16 +153,16 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
return (attributes_.getLength() > 0);
|
||||
} // hasAttributes
|
||||
|
||||
virtual void setOwnerDoc(DocumentImpl<stringT, string_adaptorT>* ownerDoc)
|
||||
virtual void setOwnerDoc(DocumentImplT* ownerDoc)
|
||||
{
|
||||
attributes_.setOwnerDoc(ownerDoc);
|
||||
NodeImplWithChildren<stringT, string_adaptorT>::setOwnerDoc(ownerDoc);
|
||||
NodeT::setOwnerDoc(ownerDoc);
|
||||
} // setOwnerDoc
|
||||
|
||||
virtual void setReadOnly(bool readOnly)
|
||||
{
|
||||
attributes_.setReadOnly(readOnly);
|
||||
NodeImplWithChildren<stringT, string_adaptorT>::setReadOnly(readOnly);
|
||||
NodeT::setReadOnly(readOnly);
|
||||
} // setReadOnly
|
||||
|
||||
protected:
|
||||
|
@ -161,10 +170,10 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
{
|
||||
for(unsigned int i = 0; i < attributes_.getLength(); ++i)
|
||||
{
|
||||
DOM::Attr_impl<stringT>* a = dynamic_cast<DOM::Attr_impl<stringT>*>(attributes_.item(i));
|
||||
DOMAttr_implT* a = dynamic_cast<DOMAttr_implT*>(attributes_.item(i));
|
||||
if(a->getSpecified())
|
||||
{
|
||||
DOM::Attr_impl<stringT>* newA = dynamic_cast<DOM::Attr_impl<stringT>*>(a->cloneNode(true));
|
||||
DOMAttr_implT* newA = dynamic_cast<DOMAttr_implT*>(a->cloneNode(true));
|
||||
if(string_adaptorT::empty(a->getLocalName()))
|
||||
clone->setAttributeNode(newA);
|
||||
else
|
||||
|
@ -173,24 +182,24 @@ class ElementImpl : public DOM::Element_impl<stringT>,
|
|||
} // for
|
||||
|
||||
if(deep)
|
||||
for(DOM::Node_impl<stringT>* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
for(DOMNode_implT* c = NodeT::getFirstChild(); c != 0; c = c->getNextSibling())
|
||||
clone->appendChild(c->cloneNode(true));
|
||||
} // cloneChildren
|
||||
|
||||
private:
|
||||
virtual void checkChildType(DOM::Node_impl<stringT>* child)
|
||||
virtual void checkChildType(DOMNode_impl* child)
|
||||
{
|
||||
typename DOM::Node<stringT>::Type type = child->getNodeType();
|
||||
if((type != DOM::Node<stringT>::ELEMENT_NODE) &&
|
||||
(type != DOM::Node<stringT>::TEXT_NODE) &&
|
||||
(type != DOM::Node<stringT>::COMMENT_NODE) &&
|
||||
(type != DOM::Node<stringT>::PROCESSING_INSTRUCTION_NODE) &&
|
||||
(type != DOM::Node<stringT>::CDATA_SECTION_NODE) &&
|
||||
(type != DOM::Node<stringT>::ENTITY_REFERENCE_NODE))
|
||||
typename DOM::Node_base::Type type = child->getNodeType();
|
||||
if((type != DOM::Node_base::ELEMENT_NODE) &&
|
||||
(type != DOM::Node_base::TEXT_NODE) &&
|
||||
(type != DOM::Node_base::COMMENT_NODE) &&
|
||||
(type != DOM::Node_base::PROCESSING_INSTRUCTION_NODE) &&
|
||||
(type != DOM::Node_base::CDATA_SECTION_NODE) &&
|
||||
(type != DOM::Node_base::ENTITY_REFERENCE_NODE))
|
||||
throw DOM::DOMException(DOM::DOMException::HIERARCHY_REQUEST_ERR);
|
||||
} // checkChildType
|
||||
|
||||
AttrMap<stringT, string_adaptorT> attributes_;
|
||||
AttrMapT attributes_;
|
||||
protected:
|
||||
stringT const* tagName_;
|
||||
}; // class ElementImpl
|
||||
|
|
|
@ -58,12 +58,17 @@ class namespaceAndNameIs : public std::unary_function<NodeImpl<stringT, string_a
|
|||
}; // class namespaceAndNameIs
|
||||
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
||||
class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
NamedNodeMapImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc) :
|
||||
DOM::NamedNodeMap_impl<stringT>(),
|
||||
nodes_(),
|
||||
typedef DOM::Node_impl<stringT, string_adaptorT> DOMNode_implT;
|
||||
typedef NodeImpl<stringT, string_adaptorT> NodeImplT;
|
||||
typedef NamedNodeMapImpl<stringT, string_adaptorT> NamedNodeMapImplT;
|
||||
typedef DocumentImpl<stringT, string_adaptorT> DocumentImplT;
|
||||
|
||||
NamedNodeMapImpl(DocumentImplT* ownerDoc) :
|
||||
DOM::NamedNodeMap_impl<stringT, string_adaptorT>(),
|
||||
nodes_(),
|
||||
readOnly_(false),
|
||||
ownerDoc_(ownerDoc)
|
||||
{
|
||||
|
@ -87,7 +92,7 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
if(ownerDoc_)
|
||||
ownerDoc_->releaseRef();
|
||||
} // releaseRef
|
||||
virtual void setOwnerDoc(DocumentImpl<stringT, string_adaptorT>* ownerDoc)
|
||||
virtual void setOwnerDoc(DocumentImplT* ownerDoc)
|
||||
{
|
||||
ownerDoc_ = ownerDoc;
|
||||
for(typename NodeListT::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
|
||||
|
@ -96,24 +101,24 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
|
||||
///////////////////////////////////////////////////
|
||||
// DOM::NamedNodeMap methods
|
||||
virtual DOM::Node_impl<stringT>* getNamedItem(const stringT& name) const
|
||||
virtual DOMNode_implT* getNamedItem(const stringT& name) const
|
||||
{
|
||||
return getNode(const_cast<NamedNodeMapImpl<stringT, string_adaptorT>*>(this)->findByName(name));
|
||||
return getNode(const_cast<NamedNodeMapImplT*>(this)->findByName(name));
|
||||
} // getNamedItem
|
||||
|
||||
virtual DOM::Node_impl<stringT>* setNamedItem(DOM::Node_impl<stringT>* arg)
|
||||
virtual DOMNode_implT* setNamedItem(DOMNode_implT* arg)
|
||||
{
|
||||
throwIfReadOnly();
|
||||
return setNode(findByName(arg->getNodeName()), dynamic_cast<NodeImpl<stringT, string_adaptorT>*>(arg));
|
||||
return setNode(findByName(arg->getNodeName()), dynamic_cast<NodeImplT*>(arg));
|
||||
} // setNamedItem
|
||||
|
||||
virtual DOM::Node_impl<stringT>* removeNamedItem(const stringT& name)
|
||||
virtual DOMNode_implT* removeNamedItem(const stringT& name)
|
||||
{
|
||||
throwIfReadOnly();
|
||||
return removeNode(findByName(name));
|
||||
} // removedNamedItem
|
||||
|
||||
virtual DOM::Node_impl<stringT>* item(unsigned int index) const
|
||||
virtual DOMNode_implT* item(unsigned int index) const
|
||||
{
|
||||
return do_item(index);
|
||||
} // item
|
||||
|
@ -123,18 +128,18 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
return static_cast<unsigned int>(nodes_.size());
|
||||
} // getLength
|
||||
|
||||
virtual DOM::Node_impl<stringT>* getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
virtual DOMNode_implT* getNamedItemNS(const stringT& namespaceURI, const stringT& localName) const
|
||||
{
|
||||
return getNode(const_cast<NamedNodeMapImpl<stringT, string_adaptorT>*>(this)->findByNamespaceAndName(namespaceURI, localName));
|
||||
return getNode(const_cast<NamedNodeMapImplT*>(this)->findByNamespaceAndName(namespaceURI, localName));
|
||||
} // getNamedItemNS
|
||||
|
||||
virtual DOM::Node_impl<stringT>* setNamedItemNS(DOM::Node_impl<stringT>* arg)
|
||||
virtual DOMNode_implT* setNamedItemNS(DOMNode_implT* arg)
|
||||
{
|
||||
throwIfReadOnly();
|
||||
return setNode(findByNamespaceAndName(arg->getNamespaceURI(), arg->getLocalName()), dynamic_cast<NodeImpl<stringT, string_adaptorT>*>(arg));
|
||||
return setNode(findByNamespaceAndName(arg->getNamespaceURI(), arg->getLocalName()), dynamic_cast<NodeImplT*>(arg));
|
||||
} // setNamedItemNS
|
||||
|
||||
virtual DOM::Node_impl<stringT>* removeNamedItemNS(const stringT& namespaceURI, const stringT& localName)
|
||||
virtual DOMNode_implT* removeNamedItemNS(const stringT& namespaceURI, const stringT& localName)
|
||||
{
|
||||
throwIfReadOnly();
|
||||
return removeNode(findByNamespaceAndName(namespaceURI, localName));
|
||||
|
@ -147,7 +152,7 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
readOnly_ = readOnly;
|
||||
} // setReadOnly
|
||||
|
||||
NodeImpl<stringT, string_adaptorT>* do_item(unsigned int index) const
|
||||
NodeImplT* do_item(unsigned int index) const
|
||||
{
|
||||
if(index >= nodes_.size())
|
||||
return 0;
|
||||
|
@ -162,16 +167,16 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
throw DOM::DOMException(DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR);
|
||||
} // throwIfReadOnly
|
||||
|
||||
typedef std::deque<NodeImpl<stringT, string_adaptorT>*> NodeListT;
|
||||
typedef std::deque<NodeImplT*> NodeListT;
|
||||
|
||||
NodeImpl<stringT, string_adaptorT>* getNode(typename NodeListT::const_iterator n) const
|
||||
NodeImplT* getNode(typename NodeListT::const_iterator n) const
|
||||
{
|
||||
if(n == nodes_.end())
|
||||
return 0;
|
||||
return *n;
|
||||
} // getNode
|
||||
|
||||
NodeImpl<stringT, string_adaptorT>* setNode(typename NodeListT::iterator n, NodeImpl<stringT, string_adaptorT>* arg)
|
||||
NodeImplT* setNode(typename NodeListT::iterator n, NodeImplT* arg)
|
||||
{
|
||||
if(n == nodes_.end())
|
||||
{
|
||||
|
@ -179,17 +184,17 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
return 0;
|
||||
} // if(n == nodes_.end())
|
||||
|
||||
NodeImpl<stringT, string_adaptorT>* removedNode = *n;
|
||||
NodeImplT* removedNode = *n;
|
||||
*n = arg;
|
||||
ownerDoc_->orphaned(removedNode);
|
||||
return removedNode;
|
||||
} // setNode
|
||||
|
||||
NodeImpl<stringT, string_adaptorT>* removeNode(typename NodeListT::iterator n)
|
||||
NodeImplT* removeNode(typename NodeListT::iterator n)
|
||||
{
|
||||
if(n == nodes_.end())
|
||||
return 0;
|
||||
NodeImpl<stringT, string_adaptorT>* removedNode = *n;
|
||||
NodeImplT* removedNode = *n;
|
||||
nodes_.erase(n);
|
||||
ownerDoc_->orphaned(removedNode);
|
||||
return removedNode;
|
||||
|
@ -209,7 +214,7 @@ class NamedNodeMapImpl : public DOM::NamedNodeMap_impl<stringT>
|
|||
bool readOnly_;
|
||||
|
||||
protected:
|
||||
DocumentImpl<stringT, string_adaptorT>* ownerDoc_;
|
||||
DocumentImplT ownerDoc_;
|
||||
}; // class NamedNodeMapImpl
|
||||
|
||||
} // namespace SAX2DOM
|
||||
|
|
|
@ -13,17 +13,20 @@ namespace Arabica
|
|||
{
|
||||
namespace DOM
|
||||
{
|
||||
template<class stringT> class Text_impl;
|
||||
template<class stringT, class string_adaptorT> class Text_impl;
|
||||
|
||||
template<class stringT>
|
||||
class Text : public CharacterData<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Text : public CharacterData<stringT, string_adaptorT>
|
||||
{
|
||||
typedef CharacterData<stringT> CharDataT;
|
||||
typedef Text_impl<stringT, string_adaptorT> Text_implT;
|
||||
public:
|
||||
Text() : CharacterData<stringT>() { }
|
||||
explicit Text(Text_impl<stringT>* impl) : CharacterData<stringT>(impl) { }
|
||||
Text(const Text& rhs) : CharacterData<stringT>(rhs) { }
|
||||
explicit Text(const Node<stringT>& rhs) : CharacterData<stringT>(rhs, 0)
|
||||
typedef Node<stringT, string_adaptorT> NodeT;
|
||||
typedef CharacterData<stringT, string_adaptorT> CharacterDataT;
|
||||
|
||||
Text() : CharacterDataT() { }
|
||||
explicit Text(Text_implT* impl) : CharacterDataT(impl) { }
|
||||
Text(const Text& rhs) : CharacterDataT(rhs) { }
|
||||
explicit Text(const NodeT& rhs) : CharacterDataT(rhs, 0)
|
||||
{
|
||||
typename Text::Type type = rhs.getNodeType();
|
||||
if((type != Text::TEXT_NODE) && (type != Text::CDATA_SECTION_NODE))
|
||||
|
@ -32,7 +35,7 @@ class Text : public CharacterData<stringT>
|
|||
} // Text
|
||||
|
||||
protected:
|
||||
Text(const Node<stringT>& rhs, int dummy) : CharacterData<stringT>(rhs, 0) { }
|
||||
Text(const NodeT& rhs, int dummy) : CharacterDataT(rhs, 0) { }
|
||||
|
||||
Text splitText(int offset)
|
||||
{
|
||||
|
@ -40,19 +43,19 @@ class Text : public CharacterData<stringT>
|
|||
} // splitText
|
||||
|
||||
protected:
|
||||
Text_impl<stringT>* tImpl() const { return dynamic_cast<Text_impl<stringT>*>(CharDataT::impl()); }
|
||||
Text_implT* tImpl() const { return dynamic_cast<Text_implT*>(CharacterDataT::impl()); }
|
||||
}; // class Text
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
class Text_impl : virtual public CharacterData_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class Text_impl : virtual public CharacterData_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
virtual ~Text_impl() { }
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// DOM::Text methods
|
||||
virtual Text_impl<stringT>* splitText(int offset) = 0;
|
||||
virtual Text_impl<stringT, string_adaptorT>* splitText(int offset) = 0;
|
||||
}; // Text_impl
|
||||
|
||||
} // namespace DOM
|
||||
|
|
|
@ -38,21 +38,27 @@ enum whatToShowFlags
|
|||
SHOW_NOTATION = 0x00000800
|
||||
};
|
||||
|
||||
template<class stringT> class NodeIterator;
|
||||
template<class stringT> class TreeWalker;
|
||||
template<class stringT> class DocumentTraversal_impl;
|
||||
template<class stringT, class string_adaptorT> class NodeIterator;
|
||||
template<class stringT, class string_adaptorT> class TreeWalker;
|
||||
template<class stringT, class string_adaptorT> class DocumentTraversal_impl;
|
||||
|
||||
template<class stringT>
|
||||
class DocumentTraversal : protected DOM::Proxy<DocumentTraversal_impl<stringT> >
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentTraversal : protected DOM::Proxy<DocumentTraversal_impl<stringT, string_adaptorT> >
|
||||
{
|
||||
public:
|
||||
typedef DOM::Proxy<DocumentTraversal_impl<stringT> > proxy_t;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef TreeWalker<stringT, string_adaptorT> TreeWalkerT;
|
||||
typedef NodeIterator<stringT, string_adaptorT> NodeIteratorT;
|
||||
typedef DocumentTraversal_impl<stringT, string_adaptorT> DocumentTraversal_implT;
|
||||
typedef DOM::Proxy<DocumentTraversal_implT> proxy_t;
|
||||
typedef typename proxy_t::value_type impl_t;
|
||||
typedef DOM::Document<stringT, string_adaptorT> DocumentT;
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
DocumentTraversal() : proxy_t(0) { }
|
||||
explicit DocumentTraversal(DocumentTraversal_impl<stringT>* const impl) : proxy_t(impl) { }
|
||||
explicit DocumentTraversal(DocumentTraversal_implT* const impl) : proxy_t(impl) { }
|
||||
DocumentTraversal(const DocumentTraversal& rhs) : proxy_t(rhs) { }
|
||||
explicit DocumentTraversal(const DOM::Document<stringT>& rhs) : proxy_t(rhs.dImpl())
|
||||
explicit DocumentTraversal(const DocumentT& rhs) : proxy_t(rhs.dImpl())
|
||||
{
|
||||
if(dynamic_cast<impl_t*>(rhs.dImpl()) == 0)
|
||||
throw DOM::DOMException(DOM::DOMException::NOT_SUPPORTED_ERR);
|
||||
|
@ -72,55 +78,59 @@ class DocumentTraversal : protected DOM::Proxy<DocumentTraversal_impl<stringT> >
|
|||
|
||||
///////////////////////////////////////////////////
|
||||
// DocumentTraversal methods
|
||||
NodeIterator<stringT> createNodeIterator(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
bool entityRefExpansion)
|
||||
NodeIteratorT createNodeIterator(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return NodeIterator<stringT>(proxy_t::impl()->createNodeIterator(root, whatToShow, 0, entityRefExpansion));
|
||||
return NodeIteratorT(proxy_t::impl()->createNodeIterator(root, whatToShow, 0, entityRefExpansion));
|
||||
} // createNodeIterator
|
||||
|
||||
NodeIterator<stringT> createNodeIterator(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>& filter,
|
||||
bool entityRefExpansion)
|
||||
NodeIteratorT createNodeIterator(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT& filter,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return NodeIterator<stringT>(proxy_t::impl()->createNodeIterator(root, whatToShow, &filter, entityRefExpansion));
|
||||
return NodeIteratorT(proxy_t::impl()->createNodeIterator(root, whatToShow, &filter, entityRefExpansion));
|
||||
} // createNodeIterator
|
||||
|
||||
TreeWalker<stringT> createTreeWalker(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
bool entityRefExpansion)
|
||||
TreeWalkerT createTreeWalker(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return TreeWalker<stringT>(proxy_t::impl()->createTreeWalker(root, whatToShow, 0, entityRefExpansion));
|
||||
return TreeWalkerT(proxy_t::impl()->createTreeWalker(root, whatToShow, 0, entityRefExpansion));
|
||||
} // createTreeWalker
|
||||
|
||||
TreeWalker<stringT> createTreeWalker(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>& filter,
|
||||
bool entityRefExpansion)
|
||||
TreeWalkerT createTreeWalker(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT& filter,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return TreeWalker<stringT>(proxy_t::impl()->createTreeWalker(root, whatToShow, &filter, entityRefExpansion));
|
||||
return TreeWalkerT(proxy_t::impl()->createTreeWalker(root, whatToShow, &filter, entityRefExpansion));
|
||||
} // createTreeWalker
|
||||
}; // class DocumentTraversal
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// implementation class
|
||||
template<class stringT> class NodeIterator_impl;
|
||||
template<class stringT> class TreeWalker_impl;
|
||||
template<class stringT, class string_adaptorT> class NodeIterator_impl;
|
||||
template<class stringT, class string_adaptorT> class TreeWalker_impl;
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentTraversal_impl : virtual public TraversalImpl
|
||||
{
|
||||
public:
|
||||
virtual NodeIterator_impl<stringT>* createNodeIterator(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>* filter,
|
||||
bool entityRefExpansion) = 0;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef TreeWalker_impl<stringT, string_adaptorT> TreeWalker_implT;
|
||||
typedef NodeIterator_impl<stringT, string_adaptorT> NodeIterator_implT;
|
||||
|
||||
virtual TreeWalker_impl<stringT>* createTreeWalker(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>* filter,
|
||||
bool entityRefExpansion) = 0;
|
||||
virtual NodeIterator_implT* createNodeIterator(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT* filter,
|
||||
bool entityRefExpansion) = 0;
|
||||
|
||||
virtual TreeWalker_implT* createTreeWalker(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT* filter,
|
||||
bool entityRefExpansion) = 0;
|
||||
}; // class DocumentTraveral_impl
|
||||
|
||||
} // namespace Traversal
|
||||
|
|
|
@ -17,36 +17,42 @@ namespace Traversal
|
|||
{
|
||||
|
||||
|
||||
template<class stringT>
|
||||
class DocumentTraversalImpl : public DocumentTraversal_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class DocumentTraversalImpl : public DocumentTraversal_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef NodeIterator_impl<stringT, string_adaptorT> NodeIterator_implT;
|
||||
typedef TreeWalker_impl<stringT, string_adaptorT> TreeWalker_implT;
|
||||
typedef TreeWalkerImpl<stringT, string_adaptorT> TreeWalkerImplT;
|
||||
|
||||
DocumentTraversalImpl() {}
|
||||
|
||||
virtual NodeIterator_impl<stringT>* createNodeIterator(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>* filter,
|
||||
bool entityRefExpansion)
|
||||
virtual NodeIterator_implT* createNodeIterator(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT* filter,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual TreeWalker_impl<stringT>* createTreeWalker(DOM::Node<stringT> root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>* filter,
|
||||
bool entityRefExpansion)
|
||||
virtual TreeWalker_implT* createTreeWalker(NodeT root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilterT* filter,
|
||||
bool entityRefExpansion)
|
||||
{
|
||||
return new TreeWalkerImpl<stringT>(root, whatToShow, filter, entityRefExpansion);
|
||||
return new TreeWalkerImplT(root, whatToShow, filter, entityRefExpansion);
|
||||
}
|
||||
}; // class DocumentTraversalImpl
|
||||
|
||||
|
||||
|
||||
//todo: move to DOM::Document?
|
||||
template<class stringT>
|
||||
DocumentTraversal<stringT> make_document_traversal_t()
|
||||
template<class stringT, class string_adaptorT>
|
||||
DocumentTraversal<stringT, string_adaptorT> make_document_traversal_t()
|
||||
{
|
||||
DocumentTraversal<stringT> docTraversal(new DocumentTraversalImpl<stringT>());
|
||||
DocumentTraversal<stringT, string_adaptorT> docTraversal(new DocumentTraversalImpl<stringT, string_adaptorT>());
|
||||
return docTraversal;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,17 @@ namespace Arabica
|
|||
namespace DOM
|
||||
{
|
||||
|
||||
template<class stringT, class string_adaptorT> class Node;
|
||||
|
||||
namespace Traversal
|
||||
{
|
||||
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NodeFilter
|
||||
{
|
||||
public:
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
protected:
|
||||
virtual ~NodeFilter() { }
|
||||
|
||||
|
@ -31,7 +36,7 @@ class NodeFilter
|
|||
FILTER_SKIP = 3
|
||||
}; // Result
|
||||
|
||||
virtual Result acceptNode(const DOM::Node<stringT>& node) const = 0;
|
||||
virtual Result acceptNode(const NodeT& node) const = 0;
|
||||
|
||||
}; // class NodeFilter
|
||||
|
||||
|
|
|
@ -18,17 +18,22 @@ namespace DOM
|
|||
namespace Traversal
|
||||
{
|
||||
|
||||
template<class stringT> class NodeIterator_impl;
|
||||
template<class stringT, class string_adaptorT> class NodeIterator_impl;
|
||||
|
||||
template<class stringT>
|
||||
class NodeIterator : protected DOM::Proxy<NodeIterator_impl<stringT> >
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NodeIterator : protected DOM::Proxy<NodeIterator_impl<stringT, string_adaptorT> >
|
||||
{
|
||||
public:
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef NodeIterator_impl<stringT, string_adaptorT> NodeIterator_implT;
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
private:
|
||||
typedef DOM::Proxy<NodeIterator_impl<stringT> > proxy_t;
|
||||
typedef DOM::Proxy<NodeIterator_implT> proxy_t;
|
||||
|
||||
public:
|
||||
NodeIterator() : proxy_t(0) { }
|
||||
explicit NodeIterator(NodeIterator_impl<stringT>* const impl) : proxy_t(impl) { }
|
||||
explicit NodeIterator(NodeIterator_implT* const impl) : proxy_t(impl) { }
|
||||
NodeIterator(const NodeIterator& rhs) : proxy_t(rhs) { }
|
||||
virtual ~NodeIterator() { }
|
||||
bool operator==(const NodeIterator& rhs) const { return proxy_t::operator==(rhs); }
|
||||
|
@ -44,37 +49,40 @@ class NodeIterator : protected DOM::Proxy<NodeIterator_impl<stringT> >
|
|||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// NodeIterator methods
|
||||
DOM::Node<stringT> getRoot() const { return proxy_t::impl()->getRoot(); }
|
||||
NodeT getRoot() const { return proxy_t::impl()->getRoot(); }
|
||||
|
||||
unsigned long getWhatToShow() const { return proxy_t::impl()->getWhatToShow(); }
|
||||
|
||||
NodeFilter<stringT>* getFilter() const { return proxy_t::impl()->getFilter(); }
|
||||
NodeFilterT* getFilter() const { return proxy_t::impl()->getFilter(); }
|
||||
|
||||
bool getExpandEntityReferences() const { return proxy_t::impl()->getExpandEntityReferences(); }
|
||||
|
||||
DOM::Node<stringT> nextNode() { return proxy_t::impl()->nextNode(); }
|
||||
NodeT nextNode() { return proxy_t::impl()->nextNode(); }
|
||||
|
||||
DOM::Node<stringT> previousNode() { return proxy_t::impl()->prevNode(); }
|
||||
NodeT previousNode() { return proxy_t::impl()->prevNode(); }
|
||||
|
||||
void detach() { return proxy_t::impl()->detach(); }
|
||||
}; // class NodeIterator
|
||||
|
||||
////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class NodeIterator_impl
|
||||
{
|
||||
public:
|
||||
virtual DOM::Node<stringT> getRoot() const = 0;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
virtual NodeT getRoot() const = 0;
|
||||
|
||||
virtual unsigned long getWhatToShow() const = 0;
|
||||
|
||||
virtual NodeFilter<stringT>* getFilter() const = 0;
|
||||
virtual NodeFilterT* getFilter() const = 0;
|
||||
|
||||
virtual bool getExpandEntityReferences() const = 0;
|
||||
|
||||
virtual DOM::Node<stringT> nextNode() = 0;
|
||||
virtual NodeT nextNode() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> previousNode() = 0;
|
||||
virtual NodeT previousNode() = 0;
|
||||
|
||||
virtual void detach() = 0;
|
||||
}; // class NodeIterator_impl
|
||||
|
|
|
@ -19,17 +19,23 @@ namespace DOM
|
|||
namespace Traversal
|
||||
{
|
||||
|
||||
template<class stringT> class TreeWalker_impl;
|
||||
template<class stringT, class string_adaptorT> class TreeWalker_impl;
|
||||
|
||||
template<class stringT>
|
||||
class TreeWalker : protected DOM::Proxy<TreeWalker_impl<stringT> >
|
||||
template<class stringT, class string_adaptorT>
|
||||
class TreeWalker : protected DOM::Proxy<TreeWalker_impl<stringT, string_adaptorT> >
|
||||
{
|
||||
public:
|
||||
typedef TreeWalker_impl<stringT, string_adaptorT> TreeWalker_implT;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
|
||||
private:
|
||||
typedef DOM::Proxy<TreeWalker_impl<stringT> > proxy_t;
|
||||
typedef DOM::Proxy<TreeWalker_implT> proxy_t;
|
||||
typedef typename proxy_t::value_type impl_t;
|
||||
|
||||
public:
|
||||
TreeWalker() : proxy_t(0) { }
|
||||
explicit TreeWalker(TreeWalker_impl<stringT>* const impl) : proxy_t(impl) { }
|
||||
explicit TreeWalker(TreeWalker_implT* const impl) : proxy_t(impl) { }
|
||||
TreeWalker(const TreeWalker& rhs) : proxy_t(rhs) { }
|
||||
virtual ~TreeWalker() { }
|
||||
bool operator==(const TreeWalker& rhs) const { return proxy_t::operator==(rhs); }
|
||||
|
@ -45,62 +51,65 @@ class TreeWalker : protected DOM::Proxy<TreeWalker_impl<stringT> >
|
|||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// TreeWalker methods
|
||||
DOM::Node<stringT> getRoot() { return proxy_t::impl()->getRoot(); }
|
||||
NodeT getRoot() { return proxy_t::impl()->getRoot(); }
|
||||
|
||||
unsigned long getWhatToShow() { return proxy_t::impl()->getWhatToShow(); }
|
||||
|
||||
NodeFilter<stringT>* getFilter() { return proxy_t::impl()->getFilter(); }
|
||||
NodeFilterT* getFilter() { return proxy_t::impl()->getFilter(); }
|
||||
|
||||
bool getExpandEntityReferences() { return proxy_t::impl()->getExpandEntityReferences(); }
|
||||
|
||||
DOM::Node<stringT> getCurrentNode() { return proxy_t::impl()->getCurrentNode(); }
|
||||
void setCurrentNode(const DOM::Node<stringT>& currentNode) { proxy_t::impl()->setCurrentNode(currentNode); }
|
||||
NodeT getCurrentNode() { return proxy_t::impl()->getCurrentNode(); }
|
||||
void setCurrentNode(const NodeT& currentNode) { proxy_t::impl()->setCurrentNode(currentNode); }
|
||||
|
||||
DOM::Node<stringT> parentNode() { return proxy_t::impl()->parentNode(); }
|
||||
NodeT parentNode() { return proxy_t::impl()->parentNode(); }
|
||||
|
||||
DOM::Node<stringT> firstChild() { return proxy_t::impl()->firstChild(); }
|
||||
NodeT firstChild() { return proxy_t::impl()->firstChild(); }
|
||||
|
||||
DOM::Node<stringT> lastChild() { return proxy_t::impl()->lastChild(); }
|
||||
NodeT lastChild() { return proxy_t::impl()->lastChild(); }
|
||||
|
||||
DOM::Node<stringT> previousSibling() { return proxy_t::impl()->previousSibling(); }
|
||||
NodeT previousSibling() { return proxy_t::impl()->previousSibling(); }
|
||||
|
||||
DOM::Node<stringT> nextSibling() { return proxy_t::impl()->nextSibling(); }
|
||||
NodeT nextSibling() { return proxy_t::impl()->nextSibling(); }
|
||||
|
||||
DOM::Node<stringT> previousNode() { return proxy_t::impl()->previousNode(); }
|
||||
NodeT previousNode() { return proxy_t::impl()->previousNode(); }
|
||||
|
||||
DOM::Node<stringT> nextNode() { return proxy_t::impl()->nextNode(); }
|
||||
NodeT nextNode() { return proxy_t::impl()->nextNode(); }
|
||||
}; // class TreeWalker
|
||||
|
||||
////////////////////////////////////////////////
|
||||
template<class stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class TreeWalker_impl : public TraversalImpl
|
||||
{
|
||||
public:
|
||||
virtual DOM::Node<stringT> getRoot() = 0;
|
||||
typedef DOM::Node<stringT, string_adaptorT> NodeT;
|
||||
typedef NodeFilter<stringT, string_adaptorT> NodeFilterT;
|
||||
|
||||
virtual NodeT getRoot() = 0;
|
||||
|
||||
virtual unsigned long getWhatToShow() = 0;
|
||||
|
||||
virtual NodeFilter<stringT>* getFilter() = 0;
|
||||
virtual NodeFilterT* getFilter() = 0;
|
||||
|
||||
virtual bool getExpandEntityReferences() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> getCurrentNode() = 0;
|
||||
virtual NodeT getCurrentNode() = 0;
|
||||
|
||||
virtual void setCurrentNode(const DOM::Node<stringT>& currentNode) = 0;
|
||||
virtual void setCurrentNode(const NodeT& currentNode) = 0;
|
||||
|
||||
virtual DOM::Node<stringT> parentNode() = 0;
|
||||
virtual NodeT parentNode() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> firstChild() = 0;
|
||||
virtual NodeT firstChild() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> lastChild() = 0;
|
||||
virtual NodeT lastChild() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> previousSibling() = 0;
|
||||
virtual NodeT previousSibling() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> nextSibling() = 0;
|
||||
virtual NodeT nextSibling() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> previousNode() = 0;
|
||||
virtual NodeT previousNode() = 0;
|
||||
|
||||
virtual DOM::Node<stringT> nextNode() = 0;
|
||||
virtual NodeT nextNode() = 0;
|
||||
}; // class TreeWalker_impl
|
||||
|
||||
} // namespace Traversal
|
||||
|
|
|
@ -16,19 +16,19 @@ namespace DOM
|
|||
namespace Traversal
|
||||
{
|
||||
|
||||
template<class stringT>
|
||||
class TreeWalkerImpl : public TreeWalker_impl<stringT>
|
||||
template<class stringT, class string_adaptorT>
|
||||
class TreeWalkerImpl : public TreeWalker_impl<stringT, string_adaptorT>
|
||||
{
|
||||
public:
|
||||
typedef DOM::Node<stringT> node_t;
|
||||
typedef DOM::Traversal::NodeFilter<stringT> filter_t;
|
||||
typedef DOM::Node<stringT, string_adaptorT> node_t;
|
||||
typedef NodeFilter<stringT, string_adaptorT> filter_t;
|
||||
typedef typename filter_t::Result filter_result_t;
|
||||
|
||||
TreeWalkerImpl
|
||||
(
|
||||
node_t root,
|
||||
unsigned long whatToShow,
|
||||
NodeFilter<stringT>* nodeFilter,
|
||||
filter_t* nodeFilter,
|
||||
bool expandEntityRef
|
||||
)
|
||||
: root_(root),
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
unsigned long getWhatToShow() { return whatToShow_; }
|
||||
|
||||
NodeFilter<stringT>* getFilter() { return nodeFilter_; }
|
||||
filter_t* getFilter() { return nodeFilter_; }
|
||||
|
||||
bool getExpandEntityReferences() { return expandEntityRef_; }
|
||||
|
||||
|
@ -290,7 +290,7 @@ private:
|
|||
node_t root_;
|
||||
node_t currentNode_;
|
||||
unsigned long whatToShow_;
|
||||
NodeFilter<stringT>* nodeFilter_;
|
||||
filter_t* nodeFilter_;
|
||||
bool expandEntityRef_;
|
||||
|
||||
}; // class TreeWalkerImpl
|
||||
|
|
Loading…
Reference in a new issue