dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

doctree.hh
Go to the documentation of this file.
1 #ifndef __DOCTREE_HH__
2 #define __DOCTREE_HH__
3 
4 #include "lout/misc.hh"
5 
6 class DoctreeNode {
7  public:
11  int num; // unique ascending id
12  int element;
14  const char *pseudo;
15  const char *id;
16 
18  parent = NULL;
19  sibling = NULL;
20  lastChild = NULL;
21  klass = NULL;
22  pseudo = NULL;
23  id = NULL;
24  element = 0;
25  };
26 
28  dFree ((void*) id);
29  while (lastChild) {
32  delete n;
33  }
34  if (klass) {
35  for (int i = 0; i < klass->size (); i++)
36  dFree (klass->get(i));
37  delete klass;
38  }
39  }
40 };
41 
48 class Doctree {
49  private:
52  int num;
53 
54  public:
55  Doctree () {
56  rootNode = new DoctreeNode;
57  topNode = rootNode;
58  num = 0;
59  };
60 
61  ~Doctree () {
62  delete rootNode;
63  };
64 
66  DoctreeNode *dn = new DoctreeNode ();
67  dn->parent = topNode;
68  dn->sibling = dn->parent->lastChild;
69  dn->parent->lastChild = dn;
70  dn->num = num++;
71  topNode = dn;
72  return dn;
73  };
74 
75  void pop () {
76  assert (topNode != rootNode); // never pop the root node
78  };
79 
80  inline DoctreeNode *top () {
81  if (topNode != rootNode)
82  return topNode;
83  else
84  return NULL;
85  };
86 
87  inline DoctreeNode *parent (const DoctreeNode *node) {
88  if (node->parent != rootNode)
89  return node->parent;
90  else
91  return NULL;
92  };
93 
94  inline DoctreeNode *sibling (const DoctreeNode *node) {
95  return node->sibling;
96  };
97 };
98 
99 #endif
Doctree
HTML document tree interface.
Definition: doctree.hh:48
Doctree::push
DoctreeNode * push()
Definition: doctree.hh:65
Doctree::num
int num
Definition: doctree.hh:52
DoctreeNode::element
int element
Definition: doctree.hh:12
lout::misc::SimpleVector::get
T get(int i) const
Return the one element, explicitly.
Definition: misc.hh:177
DoctreeNode::DoctreeNode
DoctreeNode()
Definition: doctree.hh:17
Doctree::Doctree
Doctree()
Definition: doctree.hh:55
Doctree::~Doctree
~Doctree()
Definition: doctree.hh:61
DoctreeNode::id
const char * id
Definition: doctree.hh:15
dFree
void dFree(void *mem)
Definition: dlib.c:66
DoctreeNode
Definition: doctree.hh:6
DoctreeNode::klass
lout::misc::SimpleVector< char * > * klass
Definition: doctree.hh:13
DoctreeNode::lastChild
DoctreeNode * lastChild
Definition: doctree.hh:10
lout::misc::SimpleVector::size
int size() const
Return the number of elements put into this vector.
Definition: misc.hh:119
Doctree::topNode
DoctreeNode * topNode
Definition: doctree.hh:50
Doctree::parent
DoctreeNode * parent(const DoctreeNode *node)
Definition: doctree.hh:87
Doctree::rootNode
DoctreeNode * rootNode
Definition: doctree.hh:51
Doctree::top
DoctreeNode * top()
Definition: doctree.hh:80
Doctree::sibling
DoctreeNode * sibling(const DoctreeNode *node)
Definition: doctree.hh:94
DoctreeNode::num
int num
Definition: doctree.hh:11
Doctree::pop
void pop()
Definition: doctree.hh:75
DoctreeNode::~DoctreeNode
~DoctreeNode()
Definition: doctree.hh:27
DoctreeNode::parent
DoctreeNode * parent
Definition: doctree.hh:8
DoctreeNode::pseudo
const char * pseudo
Definition: doctree.hh:14
misc.hh
lout::misc::SimpleVector< char * >
DoctreeNode::sibling
DoctreeNode * sibling
Definition: doctree.hh:9