You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2003/01/24 03:30:35 UTC

cvs commit: xml-xalan/c/src/XercesParserLiaison XercesDOMWalker.cpp XercesDOMWalker.hpp

dbertoni    2003/01/23 18:30:34

  Modified:    c/src/XercesParserLiaison XercesDOMWalker.cpp
                        XercesDOMWalker.hpp
  Log:
  Added non-const traversal.
  
  Revision  Changes    Path
  1.3       +99 -1     xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.cpp
  
  Index: XercesDOMWalker.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesDOMWalker.cpp	22 Nov 2002 01:12:49 -0000	1.2
  +++ XercesDOMWalker.cpp	24 Jan 2003 02:30:34 -0000	1.3
  @@ -95,7 +95,43 @@
   		{
   			endNode(thePos);
   
  -			nextNode = pos->getNextSibling();
  +			nextNode = thePos->getNextSibling();
  +
  +			if(nextNode == 0)
  +			{
  +				thePos = thePos->getParentNode();
  +
  +				if(thePos == 0)
  +				{
  +					nextNode = thePos;
  +
  +					break;
  +				}
  +			}
  +		}
  +
  +		thePos = nextNode;
  +	}
  +}
  +
  +
  +
  +void
  +XercesDOMWalker::traverse(DOMNodeType*	pos)
  +{
  +	DOMNodeType*	thePos = pos;
  +
  +	while(thePos != 0)
  +	{
  +		startNode(thePos);
  +
  +		DOMNodeType*	nextNode = thePos->getFirstChild();
  +
  +		while(nextNode == 0)
  +		{
  +			endNode(thePos);
  +
  +			nextNode = thePos->getNextSibling();
   
   			if(nextNode == 0)
   			{
  @@ -150,6 +186,68 @@
   
   		thePos = nextNode;
   	}
  +}
  +
  +
  +
  +void
  +XercesDOMWalker::traverse(
  +			DOMNodeType*	pos,
  +			DOMNodeType*	parent)
  +{
  +	DOMNodeType*	thePos = pos;
  +
  +	while(parent != thePos)
  +	{	  
  +		startNode(thePos);
  +	  
  +		DOMNodeType*	nextNode = thePos->getFirstChild();
  +
  +		while(nextNode == 0)
  +		{
  +			endNode(thePos);
  +
  +			nextNode = thePos->getNextSibling();
  +
  +			if(nextNode == 0)
  +			{
  +				thePos = thePos->getParentNode();
  +
  +				if(parent == thePos)
  +				{
  +					nextNode = thePos;
  +
  +					break;
  +				}
  +			}
  +		}
  +
  +		thePos = nextNode;
  +	}
  +}
  +
  +
  +
  +void
  +XercesDOMWalker::startNode(DOMNodeType*		node)
  +{
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +	startNode((const DOMNodeType*)node);
  +#else
  +	startNode(const_cast<const DOMNodeType*>(node));
  +#endif
  +}
  +
  +
  +
  +void
  +XercesDOMWalker::endNode(DOMNodeType*	node)
  +{
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +	endNode((const DOMNodeType*)node);
  +#else
  +	endNode(const_cast<const DOMNodeType*>(node));
  +#endif
   }
   
   
  
  
  
  1.3       +20 -0     xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.hpp
  
  Index: XercesDOMWalker.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDOMWalker.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XercesDOMWalker.hpp	22 Nov 2002 01:12:49 -0000	1.2
  +++ XercesDOMWalker.hpp	24 Jan 2003 02:30:34 -0000	1.3
  @@ -90,17 +90,37 @@
   	 * Perform a pre-order traversal non-recursive style.
   	 */
   	virtual void
  +	traverse(DOMNodeType*	pos);
  +
  +	/**
  +	 * Perform a pre-order traversal non-recursive style.
  +	 */
  +	virtual void
   	traverse(
   			const DOMNodeType*	pos,
   			const DOMNodeType*	parent);
   
  +	/**
  +	 * Perform a pre-order traversal non-recursive style.
  +	 */
  +	virtual void
  +	traverse(
  +			DOMNodeType*	pos,
  +			DOMNodeType*	parent);
  +
   protected:
   
   	virtual void
   	startNode(const DOMNodeType*	node) = 0;
   
   	virtual void
  +	startNode(DOMNodeType*	node);
  +
  +	virtual void
   	endNode(const DOMNodeType*	node) = 0;
  +
  +	virtual void
  +	endNode(DOMNodeType*	node);
   };
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org