reworked for gcc 4.0.1, I hope

This commit is contained in:
jez_higgins 2005-08-21 14:25:14 +00:00
parent 1b4e8ebca4
commit 476e8c32ed

View file

@ -28,18 +28,20 @@ enum Axis
SELF SELF
}; // Axis }; // Axis
namespace impl
{
template<class string_type> class AxisWalker;
template<class axis_walker, class string_type>
AxisWalker<string_type>* CreateAxis(const DOM::Node<string_type>& context) { return new axis_walker(context); }
} // namespace impl
template<class string_type, class string_adaptor> template<class string_type, class string_adaptor>
class AxisEnumerator class AxisEnumerator
{ {
class AxisWalker; typedef impl::AxisWalker<string_type>* (*CreateAxisPtr)(const DOM::Node<string_type>& context);
template<class axis_walker>
static AxisWalker* CreateAxis(const DOM::Node<string_type>& context) { return new axis_walker(context); }
typedef AxisWalker* (*CreateAxisPtr)(const DOM::Node<string_type>& context);
struct NamedAxis { Axis name; CreateAxisPtr creator; }; struct NamedAxis { Axis name; CreateAxisPtr creator; };
static const NamedAxis AxisLookupTable[]; static const NamedAxis AxisLookupTable[];
public: public:
@ -61,7 +63,7 @@ public:
AxisEnumerator& operator=(const AxisEnumerator& rhs) AxisEnumerator& operator=(const AxisEnumerator& rhs)
{ {
AxisWalker* newwalker = rhs.walker_->clone(); impl::AxisWalker<string_type>* newwalker = rhs.walker_->clone();
delete walker_; delete walker_;
walker_ = newwalker; walker_ = newwalker;
return *this; return *this;
@ -80,11 +82,17 @@ public:
AxisEnumerator operator++(int) { AxisEnumerator copy(*this); walker_->advance(); return copy; } AxisEnumerator operator++(int) { AxisEnumerator copy(*this); walker_->advance(); return copy; }
private: private:
AxisWalker* walker_; impl::AxisWalker<string_type>* walker_;
AxisEnumerator(); AxisEnumerator();
}; // class AxisEnumerator
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
namespace impl
{
template<class string_type>
class AxisWalker class AxisWalker
{ {
public: public:
@ -92,7 +100,7 @@ private:
const DOM::Node<string_type>& get() const { return current_; } const DOM::Node<string_type>& get() const { return current_; }
virtual void advance() = 0; virtual void advance() = 0;
bool forward() { return forward_; } bool forward() { return forward_; }
virtual AxisWalker* clone() const = 0; virtual AxisWalker<string_type>* clone() const = 0;
protected: protected:
AxisWalker(bool forward) : forward_(forward) { } AxisWalker(bool forward) : forward_(forward) { }
@ -100,6 +108,32 @@ private:
void set(const DOM::Node<string_type>& current) { current_ = current; } void set(const DOM::Node<string_type>& current) { current_ = current; }
void end() { current_ = 0; } void end() { current_ = 0; }
static DOM::Node<string_type> walkDown(const DOM::Node<string_type>& context, const DOM::Node<string_type>& origin)
{
if(context.getNodeType() == DOM::Node<string_type>::ATTRIBUTE_NODE)
return 0;
DOM::Node<string_type> next = context.getFirstChild();
if((next == 0) && (context == origin)) // node with no children
return 0;
if(next != 0)
return next;
next = context.getNextSibling();
if(next != 0)
return next;
DOM::Node<string_type> parent = context.getParentNode();
while(parent != origin && next == 0)
{
next = parent.getNextSibling();
parent = parent.getParentNode();
} // while ...
return next;
} // walkDown
private: private:
DOM::Node<string_type> current_; DOM::Node<string_type> current_;
bool forward_; bool forward_;
@ -108,60 +142,63 @@ private:
bool operator==(const AxisWalker&); bool operator==(const AxisWalker&);
}; // AxisWalker }; // AxisWalker
class AncestorAxisWalker : public AxisWalker template<class string_type>
class AncestorAxisWalker : public AxisWalker<string_type>
{ {
public: public:
AncestorAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(false) AncestorAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(false)
{ {
if(context == 0) if(context == 0)
return; return;
if(context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE) if(context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE)
AxisWalker::set(context.getParentNode()); AxisWalker<string_type>::set(context.getParentNode());
else else
AxisWalker::set((static_cast<DOM::Attr<string_type> >(context)).getOwnerElement()); AxisWalker<string_type>::set((static_cast<DOM::Attr<string_type> >(context)).getOwnerElement());
} // AncestorAxisWalker } // AncestorAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() != 0) if(AxisWalker<string_type>::get() != 0)
AxisWalker::set(AxisWalker::get().getParentNode()); AxisWalker<string_type>::set(AxisWalker<string_type>::get().getParentNode());
} // advance } // advance
virtual AxisWalker* clone() const { return new AncestorAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new AncestorAxisWalker(*this); }
private: private:
AncestorAxisWalker(const AncestorAxisWalker& rhs) : AxisWalker(rhs) { } AncestorAxisWalker(const AncestorAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class AncestorAxisWalker }; // class AncestorAxisWalker
class AncestorOrSelfAxisWalker : public AxisWalker template<class string_type>
class AncestorOrSelfAxisWalker : public AxisWalker<string_type>
{ {
public: public:
AncestorOrSelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(false) AncestorOrSelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(false)
{ {
if(context != 0) if(context != 0)
AxisWalker::set(context); AxisWalker<string_type>::set(context);
} // AncestorAxisWalker } // AncestorAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() == 0) if(AxisWalker<string_type>::get() == 0)
return; return;
if(AxisWalker::get().getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE) if(AxisWalker<string_type>::get().getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE)
AxisWalker::set(AxisWalker::get().getParentNode()); AxisWalker<string_type>::set(AxisWalker<string_type>::get().getParentNode());
else else
AxisWalker::set((static_cast<DOM::Attr<string_type> >(AxisWalker::get())).getOwnerElement()); AxisWalker<string_type>::set((static_cast<DOM::Attr<string_type> >(AxisWalker<string_type>::get())).getOwnerElement());
} // advance } // advance
virtual AxisWalker* clone() const { return new AncestorOrSelfAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new AncestorOrSelfAxisWalker(*this); }
private: private:
AncestorOrSelfAxisWalker(const AncestorOrSelfAxisWalker& rhs) : AxisWalker(rhs) { } AncestorOrSelfAxisWalker(const AncestorOrSelfAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class AncestorOrSelfAxisWalker }; // class AncestorOrSelfAxisWalker
class AttributeAxisWalker : public AxisWalker template<class string_type>
class AttributeAxisWalker : public AxisWalker<string_type>
{ {
public: public:
AttributeAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true), AttributeAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true),
index_(0), count_(0) index_(0), count_(0)
{ {
if((context != 0) && (context.hasAttributes())) if((context != 0) && (context.hasAttributes()))
@ -174,16 +211,16 @@ private:
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() == 0) if(AxisWalker<string_type>::get() == 0)
return; return;
set_next(); set_next();
} // advance } // advance
virtual AxisWalker* clone() const { return new AttributeAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new AttributeAxisWalker(*this); }
private: private:
AttributeAxisWalker(const AttributeAxisWalker& rhs) : AttributeAxisWalker(const AttributeAxisWalker& rhs) :
AxisWalker(rhs), AxisWalker<string_type>(rhs),
attrs_(rhs.attrs_), attrs_(rhs.attrs_),
index_(rhs.index_), index_(rhs.index_),
count_(rhs.count_) { } count_(rhs.count_) { }
@ -196,7 +233,7 @@ private:
{ {
if(index_ == count_) if(index_ == count_)
{ {
AxisWalker::end(); AxisWalker<string_type>::end();
return; return;
} // if ... } // if ...
@ -206,57 +243,59 @@ private:
a = attrs_.item(index_++); a = attrs_.item(index_++);
} while ((a != 0) && (a.getNamespaceURI() == "http://www.w3.org/2000/xmlns/")); } while ((a != 0) && (a.getNamespaceURI() == "http://www.w3.org/2000/xmlns/"));
AxisWalker::set(a); AxisWalker<string_type>::set(a);
} // set_next } // set_next
}; // class AttributeAxisEnumerator }; // class AttributeAxisEnumerator
class ChildAxisWalker : public AxisWalker template<class string_type>
class ChildAxisWalker : public AxisWalker<string_type>
{ {
public: public:
ChildAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true) ChildAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true)
{ {
if(context != 0) if(context != 0)
AxisWalker::set(context.getFirstChild()); AxisWalker<string_type>::set(context.getFirstChild());
} // ChildAxisWalker } // ChildAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() != 0) if(AxisWalker<string_type>::get() != 0)
AxisWalker::set(AxisWalker::get().getNextSibling()); AxisWalker<string_type>::set(AxisWalker<string_type>::get().getNextSibling());
} // advance } // advance
virtual AxisWalker* clone() const { return new ChildAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new ChildAxisWalker(*this); }
private: private:
ChildAxisWalker(const ChildAxisWalker& rhs) : AxisWalker(rhs) { } ChildAxisWalker(const ChildAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class ChildAxisWalker }; // class ChildAxisWalker
class DescendantAxisWalker : public AxisWalker template<class string_type>
class DescendantAxisWalker : public AxisWalker<string_type>
{ {
public: public:
DescendantAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true), DescendantAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true),
origin_(context) origin_(context)
{ {
if((context != 0) && (context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE)) if((context != 0) && (context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE))
AxisWalker::set(context.getFirstChild()); AxisWalker<string_type>::set(context.getFirstChild());
} // DescendantAxisWalker } // DescendantAxisWalker
virtual void advance() virtual void advance()
{ {
AxisWalker::set(nextDescendant()); AxisWalker<string_type>::set(nextDescendant());
} // advance } // advance
virtual AxisWalker* clone() const { return new DescendantAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new DescendantAxisWalker(*this); }
private: private:
DOM::Node<string_type> nextDescendant() DOM::Node<string_type> nextDescendant()
{ {
DOM::Node<string_type> next = AxisWalker::get().getFirstChild(); DOM::Node<string_type> next = AxisWalker<string_type>::get().getFirstChild();
if(next == 0) if(next == 0)
next = AxisWalker::get().getNextSibling(); next = AxisWalker<string_type>::get().getNextSibling();
if(next != 0) if(next != 0)
return next; return next;
DOM::Node<string_type> parent = AxisWalker::get().getParentNode(); DOM::Node<string_type> parent = AxisWalker<string_type>::get().getParentNode();
while(parent != origin_ && next == 0) while(parent != origin_ && next == 0)
{ {
next = parent.getNextSibling(); next = parent.getNextSibling();
@ -266,45 +305,47 @@ private:
return next; return next;
} // nextDescendant } // nextDescendant
DescendantAxisWalker(const DescendantAxisWalker& rhs) : AxisWalker(rhs), origin_(rhs.origin_) { } DescendantAxisWalker(const DescendantAxisWalker& rhs) : AxisWalker<string_type>(rhs), origin_(rhs.origin_) { }
const DOM::Node<string_type> origin_; const DOM::Node<string_type> origin_;
}; // class DescendantAxisWalker }; // class DescendantAxisWalker
class DescendantOrSelfAxisWalker : public AxisWalker template<class string_type>
class DescendantOrSelfAxisWalker : public AxisWalker<string_type>
{ {
public: public:
DescendantOrSelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true), DescendantOrSelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true),
origin_(context) origin_(context)
{ {
if(context != 0) if(context != 0)
AxisWalker::set(context); AxisWalker<string_type>::set(context);
} // DescendantAxisWalker } // DescendantAxisWalker
virtual void advance() virtual void advance()
{ {
AxisWalker::set(walkDown(AxisWalker::get(), origin_)); AxisWalker<string_type>::set(AxisWalker<string_type>::walkDown(AxisWalker<string_type>::get(), origin_));
} // advance } // advance
virtual AxisWalker* clone() const { return new DescendantOrSelfAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new DescendantOrSelfAxisWalker(*this); }
private: private:
DescendantOrSelfAxisWalker(const DescendantOrSelfAxisWalker& rhs) : AxisWalker(rhs), origin_(rhs.origin_) { } DescendantOrSelfAxisWalker(const DescendantOrSelfAxisWalker& rhs) : AxisWalker<string_type>(rhs), origin_(rhs.origin_) { }
const DOM::Node<string_type> origin_; const DOM::Node<string_type> origin_;
}; // class DescendantOrSelfAxisWalker }; // class DescendantOrSelfAxisWalker
class FollowingAxisWalker : public AxisWalker template<class string_type>
class FollowingAxisWalker : public AxisWalker<string_type>
{ {
public: public:
FollowingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true) FollowingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true)
{ {
AxisWalker::set(firstFollowing(context)); AxisWalker<string_type>::set(firstFollowing(context));
} // FollowingAxisWalker } // FollowingAxisWalker
virtual void advance() virtual void advance()
{ {
AxisWalker::set(walkDown(AxisWalker::get(), AxisWalker::get().getOwnerDocument())); AxisWalker<string_type>::set(AxisWalker<string_type>::walkDown(AxisWalker<string_type>::get(), AxisWalker<string_type>::get().getOwnerDocument()));
} // advance } // advance
virtual AxisWalker* clone() const { return new FollowingAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new FollowingAxisWalker(*this); }
private: private:
DOM::Node<string_type> firstFollowing(const DOM::Node<string_type>& context) const DOM::Node<string_type> firstFollowing(const DOM::Node<string_type>& context) const
@ -326,33 +367,35 @@ private:
return next; return next;
} // firstFollowing } // firstFollowing
FollowingAxisWalker(const FollowingAxisWalker& rhs) : AxisWalker(rhs) { } FollowingAxisWalker(const FollowingAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class FollowingAxisWalker }; // class FollowingAxisWalker
class FollowingSiblingAxisWalker : public AxisWalker template<class string_type>
class FollowingSiblingAxisWalker : public AxisWalker<string_type>
{ {
public: public:
FollowingSiblingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true) FollowingSiblingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true)
{ {
if(context != 0) if(context != 0)
AxisWalker::set(context.getNextSibling()); AxisWalker<string_type>::set(context.getNextSibling());
} // FollowingSiblingAxisWalker } // FollowingSiblingAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() != 0) if(AxisWalker<string_type>::get() != 0)
AxisWalker::set(AxisWalker::get().getNextSibling()); AxisWalker<string_type>::set(AxisWalker<string_type>::get().getNextSibling());
} // advance } // advance
virtual AxisWalker* clone() const { return new FollowingSiblingAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new FollowingSiblingAxisWalker(*this); }
private: private:
FollowingSiblingAxisWalker(const FollowingSiblingAxisWalker& rhs) : AxisWalker(rhs) { } FollowingSiblingAxisWalker(const FollowingSiblingAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class FollowingSiblingAxisWalker }; // class FollowingSiblingAxisWalker
class NamespaceAxisWalker : public AxisWalker template<class string_type, class string_adaptor>
class NamespaceAxisWalker : public AxisWalker<string_type>
{ {
public: public:
NamespaceAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true), NamespaceAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true),
xmlns_prefix_(string_adaptor().makeStringT("xmlns")), xmlns_prefix_(string_adaptor().makeStringT("xmlns")),
index_(0) index_(0)
{ {
@ -372,63 +415,65 @@ private:
current = current.getParentNode(); current = current.getParentNode();
} // while } // while
list_.push_back(DOM::Node<string_type>(0)); list_.push_back(DOM::Node<string_type>(0));
AxisWalker::set(list_[index_]); AxisWalker<string_type>::set(list_[index_]);
} // NamespaceAxisWalker } // NamespaceAxisWalker
virtual void advance() virtual void advance()
{ {
if(index_ != list_.size()) if(index_ != list_.size())
AxisWalker::set(list_[++index_]); AxisWalker<string_type>::set(list_[++index_]);
} // advance } // advance
virtual AxisWalker* clone() const { return new NamespaceAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new NamespaceAxisWalker(*this); }
private: private:
NamespaceAxisWalker(const NamespaceAxisWalker& rhs) : AxisWalker(rhs) { } NamespaceAxisWalker(const NamespaceAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
std::vector<DOM::Node<string_type> > list_; std::vector<DOM::Node<string_type> > list_;
const string_type xmlns_prefix_; const string_type xmlns_prefix_;
unsigned int index_; unsigned int index_;
}; // class NamespaceAxisWalker }; // class NamespaceAxisWalker
class ParentAxisWalker : public AxisWalker template<class string_type>
class ParentAxisWalker : public AxisWalker<string_type>
{ {
public: public:
ParentAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(false) ParentAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(false)
{ {
if(context == 0) if(context == 0)
return; return;
if(context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE) if(context.getNodeType() != DOM::Node<string_type>::ATTRIBUTE_NODE)
AxisWalker::set(context.getParentNode()); AxisWalker<string_type>::set(context.getParentNode());
else else
AxisWalker::set((static_cast<DOM::Attr<string_type> >(context)).getOwnerElement()); AxisWalker<string_type>::set((static_cast<DOM::Attr<string_type> >(context)).getOwnerElement());
} // ParentAxisWalker } // ParentAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() != 0) if(AxisWalker<string_type>::get() != 0)
AxisWalker::set(0); AxisWalker<string_type>::set(0);
} // advance } // advance
virtual AxisWalker* clone() const { return new ParentAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new ParentAxisWalker(*this); }
private: private:
ParentAxisWalker(const ParentAxisWalker& rhs) : AxisWalker(rhs) { } ParentAxisWalker(const ParentAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class ParentAxisWalker }; // class ParentAxisWalker
class PrecedingAxisWalker : public AxisWalker template<class string_type>
class PrecedingAxisWalker : public AxisWalker<string_type>
{ {
public: public:
PrecedingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(false) PrecedingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(false)
{ {
nextAncestor_ = context.getParentNode(); nextAncestor_ = context.getParentNode();
AxisWalker::set(previousInDocument(context)); AxisWalker<string_type>::set(previousInDocument(context));
} // PrecedingAxisWalker } // PrecedingAxisWalker
virtual void advance() virtual void advance()
{ {
AxisWalker::set(previousInDocument(AxisWalker::get())); AxisWalker<string_type>::set(previousInDocument(AxisWalker<string_type>::get()));
} // advance } // advance
virtual AxisWalker* clone() const { return new PrecedingAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new PrecedingAxisWalker(*this); }
private: private:
DOM::Node<string_type> previousInDocument(const DOM::Node<string_type>& context) DOM::Node<string_type> previousInDocument(const DOM::Node<string_type>& context)
@ -461,89 +506,66 @@ private:
return getLastDescendant(c); return getLastDescendant(c);
} // getLastDescendant } // getLastDescendant
PrecedingAxisWalker(const PrecedingAxisWalker& rhs) : AxisWalker(rhs), nextAncestor_(rhs.nextAncestor_) { } PrecedingAxisWalker(const PrecedingAxisWalker& rhs) : AxisWalker<string_type>(rhs), nextAncestor_(rhs.nextAncestor_) { }
DOM::Node<string_type> nextAncestor_; DOM::Node<string_type> nextAncestor_;
}; // PrecedingAxisWalker }; // PrecedingAxisWalker
class PrecedingSiblingAxisWalker : public AxisWalker template<class string_type>
class PrecedingSiblingAxisWalker : public AxisWalker<string_type>
{ {
public: public:
PrecedingSiblingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(false) PrecedingSiblingAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(false)
{ {
if(context != 0) if(context != 0)
AxisWalker::set(context.getPreviousSibling()); AxisWalker<string_type>::set(context.getPreviousSibling());
} // PrecedingSiblingAxisWalker } // PrecedingSiblingAxisWalker
virtual void advance() virtual void advance()
{ {
if(AxisWalker::get() != 0) if(AxisWalker<string_type>::get() != 0)
AxisWalker::set(AxisWalker::get().getPreviousSibling()); AxisWalker<string_type>::set(AxisWalker<string_type>::get().getPreviousSibling());
} // advance } // advance
virtual AxisWalker* clone() const { return new PrecedingSiblingAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new PrecedingSiblingAxisWalker(*this); }
private: private:
PrecedingSiblingAxisWalker(const PrecedingSiblingAxisWalker& rhs) : AxisWalker(rhs) { } PrecedingSiblingAxisWalker(const PrecedingSiblingAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class PrecedingSiblingAxisWalker }; // class PrecedingSiblingAxisWalker
class SelfAxisWalker : public AxisWalker template<class string_type>
class SelfAxisWalker : public AxisWalker<string_type>
{ {
public: public:
SelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker(true) SelfAxisWalker(const DOM::Node<string_type>& context) : AxisWalker<string_type>(true)
{ {
AxisWalker::set(context); AxisWalker<string_type>::set(context);
} // SelfAxisWalker } // SelfAxisWalker
virtual void advance() { AxisWalker::end(); } virtual void advance() { AxisWalker<string_type>::end(); }
virtual AxisWalker* clone() const { return new SelfAxisWalker(*this); } virtual AxisWalker<string_type>* clone() const { return new SelfAxisWalker(*this); }
private: private:
SelfAxisWalker(const SelfAxisWalker& rhs) : AxisWalker(rhs) { } SelfAxisWalker(const SelfAxisWalker& rhs) : AxisWalker<string_type>(rhs) { }
}; // class SelfAxisWalker }; // class SelfAxisWalker
static DOM::Node<string_type> walkDown(const DOM::Node<string_type>& context, const DOM::Node<string_type>& origin) } // namespace impl
{
if(context.getNodeType() == DOM::Node<string_type>::ATTRIBUTE_NODE)
return 0;
DOM::Node<string_type> next = context.getFirstChild();
if((next == 0) && (context == origin)) // node with no children
return 0;
if(next != 0)
return next;
next = context.getNextSibling();
if(next != 0)
return next;
DOM::Node<string_type> parent = context.getParentNode();
while(parent != origin && next == 0)
{
next = parent.getNextSibling();
parent = parent.getParentNode();
} // while ...
return next;
} // walkDown
}; // class AxisEnumerator
template<class string_type, class string_adaptor> template<class string_type, class string_adaptor>
const typename AxisEnumerator<string_type, string_adaptor>::NamedAxis const typename AxisEnumerator<string_type, string_adaptor>::NamedAxis
AxisEnumerator<string_type, string_adaptor>::AxisLookupTable[] = AxisEnumerator<string_type, string_adaptor>::AxisLookupTable[] =
{ {
{ ANCESTOR, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator<string_type, string_adaptor>::AncestorAxisWalker> }, { ANCESTOR, impl::CreateAxis<impl::AncestorAxisWalker<string_type>, string_type> },
{ ANCESTOR_OR_SELF, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::AncestorOrSelfAxisWalker> }, { ANCESTOR_OR_SELF, impl::CreateAxis<impl::AncestorOrSelfAxisWalker<string_type>, string_type> },
{ ATTRIBUTE, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::AttributeAxisWalker> }, { ATTRIBUTE, impl::CreateAxis<impl::AttributeAxisWalker<string_type>, string_type> },
{ CHILD, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::ChildAxisWalker> }, { CHILD, impl::CreateAxis<impl::ChildAxisWalker<string_type>, string_type> },
{ DESCENDANT, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::DescendantAxisWalker> }, { DESCENDANT, impl::CreateAxis<impl::DescendantAxisWalker<string_type>, string_type> },
{ DESCENDANT_OR_SELF, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::DescendantOrSelfAxisWalker> }, { DESCENDANT_OR_SELF, impl::CreateAxis<impl::DescendantOrSelfAxisWalker<string_type>, string_type> },
{ FOLLOWING, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::FollowingAxisWalker> }, { FOLLOWING, impl::CreateAxis<impl::FollowingAxisWalker<string_type>, string_type> },
{ FOLLOWING_SIBLING, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::FollowingSiblingAxisWalker> }, { FOLLOWING_SIBLING, impl::CreateAxis<impl::FollowingSiblingAxisWalker<string_type>, string_type> },
{ NAMESPACE, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::NamespaceAxisWalker> }, { NAMESPACE, impl::CreateAxis<impl::NamespaceAxisWalker<string_type, string_adaptor>, string_type> },
{ PARENT, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::ParentAxisWalker> }, { PARENT, impl::CreateAxis<impl::ParentAxisWalker<string_type>, string_type> },
{ PRECEDING, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::PrecedingAxisWalker> }, { PRECEDING, impl::CreateAxis<impl::PrecedingAxisWalker<string_type>, string_type> },
{ PRECEDING_SIBLING, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::PrecedingSiblingAxisWalker> }, { PRECEDING_SIBLING, impl::CreateAxis<impl::PrecedingSiblingAxisWalker<string_type>, string_type> },
{ SELF, AxisEnumerator<string_type, string_adaptor>::CreateAxis<AxisEnumerator::SelfAxisWalker> }, { SELF, impl::CreateAxis<impl::SelfAxisWalker<string_type>, string_type> },
{ static_cast<Axis>(0), 0 } { static_cast<Axis>(0), 0 }
}; };