Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
doctree.hh
Go to the documentation of this file.
1#ifndef __DOCTREE_HH__
2#define __DOCTREE_HH__
3
4#include "lout/misc.hh"
5
7 public:
11 int num; // unique ascending id
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
48class Doctree {
49 private:
52 int num;
53
54 public:
58 num = 0;
59 };
60
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
DoctreeNode * sibling
Definition doctree.hh:9
const char * pseudo
Definition doctree.hh:14
const char * id
Definition doctree.hh:15
lout::misc::SimpleVector< char * > * klass
Definition doctree.hh:13
DoctreeNode * parent
Definition doctree.hh:8
int element
Definition doctree.hh:12
DoctreeNode * lastChild
Definition doctree.hh:10
HTML document tree interface.
Definition doctree.hh:48
DoctreeNode * parent(const DoctreeNode *node)
Definition doctree.hh:87
Doctree()
Definition doctree.hh:55
DoctreeNode * topNode
Definition doctree.hh:50
int num
Definition doctree.hh:52
DoctreeNode * rootNode
Definition doctree.hh:51
DoctreeNode * push()
Definition doctree.hh:65
DoctreeNode * sibling(const DoctreeNode *node)
Definition doctree.hh:94
~Doctree()
Definition doctree.hh:61
void pop()
Definition doctree.hh:75
DoctreeNode * top()
Definition doctree.hh:80
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition misc.hh:115
T get(int i) const
Return the one element, explicitly.
Definition misc.hh:222
int size() const
Return the number of elements put into this vector.
Definition misc.hh:162
void dFree(void *mem)
Definition dlib.c:68