~ubuntu-branches/ubuntu/vivid/tidy/vivid-updates

« back to all changes in this revision

Viewing changes to experimental/TidyNodeIter.h

  • Committer: Bazaar Package Importer
  • Author(s): Jason Thomas
  • Date: 2008-01-20 21:46:03 UTC
  • mfrom: (0.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080120214603-oqicq5jwr1exrm55
Tags: 20080116cvs-2
* debian/control: build depends on xsltproc
  (closes: #461608)
* debian/tidy.preinst,postinst: add code to move old config file
  (closes: #461623)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* TidyNodeIter
 
2
 
 
3
  (c) 1998-2003 (W3C) MIT, ERCIM, Keio University
 
4
  See tidy.h for the copyright notice.
 
5
  
 
6
  These files contain utility routines to perform in-order traversals of the
 
7
  Tidy document tree, beginning at an arbitrary node.
 
8
 
 
9
  A traversal of the tree can be performed in a manner similar to the following:
 
10
 
 
11
  Node *testNode;
 
12
  TidyNodeIter *iter = newTidyNodeIter( FindBody( tdoc ));
 
13
  for (testNode = nextTidyNode( &iter );
 
14
       NULL != testNode;
 
15
       testNode = nextTidyNode( &iter ))
 
16
  {
 
17
  }
 
18
 
 
19
  TODO:  Add a prevTidyNode() function.
 
20
*/
 
21
 
 
22
#include "lexer.h"
 
23
 
 
24
typedef struct _TidyNodeIter
 
25
{
 
26
    Node *pTop, *pCurrent;
 
27
} TidyNodeIter;
 
28
 
 
29
TidyNodeIter *newTidyNodeIter( Node *pStart );
 
30
 
 
31
/* 
 
32
    nextTidyNode( TidyNodeIter *pIter )
 
33
 
 
34
    if pCurrent is NULL, this function initializes it to match pTop, and
 
35
    returns that value, otherwise it advances to the next node in order, 
 
36
    and returns that value. When pTop == pCurrent, the function returns NULL
 
37
    to indicate that the entire tree has been visited.
 
38
*/
 
39
Node *nextTidyNode( TidyNodeIter *pIter );
 
40
 
 
41
/*
 
42
    setCurrentNode( TidyNodeIter *pThis, Node *newCurr )
 
43
 
 
44
    Resets pCurrent to match the passed value; useful if you need to back up
 
45
    to an unaltered point in the tree, or to skip a section. The next call to 
 
46
    nextTidyNode() will return the node which follows newCurr in order.
 
47
 
 
48
    Minimal error checking is performed; unexpected results _will_ occur if 
 
49
    newCurr is not a descendant node of pTop.
 
50
*/
 
51
void setCurrentNode( TidyNodeIter *pThis, Node *newCurr );