HTML Tidy
0.1
|
00001 /* TidyNodeIter 00002 00003 (c) 1998-2003 (W3C) MIT, ERCIM, Keio University 00004 See tidy.h for the copyright notice. 00005 00006 These files contain utility routines to perform in-order traversals of the 00007 Tidy document tree, beginning at an arbitrary node. 00008 00009 A traversal of the tree can be performed in a manner similar to the following: 00010 00011 Node *testNode; 00012 TidyNodeIter *iter = newTidyNodeIter( FindBody( tdoc )); 00013 for (testNode = nextTidyNode( &iter ); 00014 NULL != testNode; 00015 testNode = nextTidyNode( &iter )) 00016 { 00017 } 00018 00019 TODO: Add a prevTidyNode() function. 00020 */ 00021 00022 #include "lexer.h" 00023 00024 typedef struct _TidyNodeIter 00025 { 00026 Node *pTop, *pCurrent; 00027 } TidyNodeIter; 00028 00029 TidyNodeIter *newTidyNodeIter( Node *pStart ); 00030 00031 /* 00032 nextTidyNode( TidyNodeIter *pIter ) 00033 00034 if pCurrent is NULL, this function initializes it to match pTop, and 00035 returns that value, otherwise it advances to the next node in order, 00036 and returns that value. When pTop == pCurrent, the function returns NULL 00037 to indicate that the entire tree has been visited. 00038 */ 00039 Node *nextTidyNode( TidyNodeIter *pIter ); 00040 00041 /* 00042 setCurrentNode( TidyNodeIter *pThis, Node *newCurr ) 00043 00044 Resets pCurrent to match the passed value; useful if you need to back up 00045 to an unaltered point in the tree, or to skip a section. The next call to 00046 nextTidyNode() will return the node which follows newCurr in order. 00047 00048 Minimal error checking is performed; unexpected results _will_ occur if 00049 newCurr is not a descendant node of pTop. 00050 */ 00051 void setCurrentNode( TidyNodeIter *pThis, Node *newCurr );