File: TidyNodeIter.h

package info (click to toggle)
tidy-html5 2%3A5.6.0-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,508 kB
  • sloc: ansic: 40,477; ruby: 841; sh: 293; makefile: 30; cpp: 30
file content (51 lines) | stat: -rw-r--r-- 1,549 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* TidyNodeIter

  (c) 1998-2003 (W3C) MIT, ERCIM, Keio University
  See tidy.h for the copyright notice.
  
  These files contain utility routines to perform in-order traversals of the
  Tidy document tree, beginning at an arbitrary node.

  A traversal of the tree can be performed in a manner similar to the following:

  Node *testNode;
  TidyNodeIter *iter = newTidyNodeIter( FindBody( tdoc ));
  for (testNode = nextTidyNode( &iter );
       NULL != testNode;
       testNode = nextTidyNode( &iter ))
  {
  }

  TODO:  Add a prevTidyNode() function.
*/

#include "lexer.h"

typedef struct _TidyNodeIter
{
    Node *pTop, *pCurrent;
} TidyNodeIter;

TidyNodeIter *newTidyNodeIter( Node *pStart );

/* 
    nextTidyNode( TidyNodeIter *pIter )

    if pCurrent is NULL, this function initializes it to match pTop, and
    returns that value, otherwise it advances to the next node in order, 
    and returns that value. When pTop == pCurrent, the function returns NULL
    to indicate that the entire tree has been visited.
*/
Node *nextTidyNode( TidyNodeIter *pIter );

/*
    setCurrentNode( TidyNodeIter *pThis, Node *newCurr )

    Resets pCurrent to match the passed value; useful if you need to back up
    to an unaltered point in the tree, or to skip a section. The next call to 
    nextTidyNode() will return the node which follows newCurr in order.

    Minimal error checking is performed; unexpected results _will_ occur if 
    newCurr is not a descendant node of pTop.
*/
void setCurrentNode( TidyNodeIter *pThis, Node *newCurr );