#include "platform.h"
#include "tidy-int.h"
#include "TidyNodeIter.h"
TidyNodeIter *newTidyNodeIter( Node *pStart )
{
TidyNodeIter *pThis = NULL;
if (NULL != (pThis = MemAlloc( sizeof( TidyNodeIter ))))
{
ClearMemory( pThis, sizeof( TidyNodeIter ));
pThis->pTop = pStart;
}
return pThis;
}
Node *nextTidyNode( TidyNodeIter *pThis )
{
if (NULL == pThis->pCurrent)
{
pThis->pCurrent = pThis->pTop->content;
}
else if (NULL != pThis->pCurrent->content)
{
pThis->pCurrent = pThis->pCurrent->content;
}
else
{
while ( NULL == pThis->pCurrent->next
&& pThis->pTop != pThis->pCurrent->parent )
{
pThis->pCurrent = pThis->pCurrent->parent;
}
pThis->pCurrent = pThis->pCurrent->next;
}
return pThis->pCurrent;
}
void setCurrentNode( TidyNodeIter *pThis, Node *newCurr )
{
if (NULL != newCurr)
pThis->pCurrent = newCurr;
}