Skip to main content

The QhpSectionTree Class Reference

Declaration

class QhpSectionTree { ... }

Public Member Functions Index

voidaddSection (const QCString &title, const QCString &ref)
voidincLevel ()
voiddecLevel ()
voidwriteToc (TextStream &t) const

Private Member Functions Index

voidtraverse (const Node &root, TextStream &t, int indent) const

Private Member Attributes Index

Nodem_root
Node *m_current = &m_root

Definition at line 45 of file qhp.cpp.

Public Member Functions

addSection()

void QhpSectionTree::addSection (const QCString & title, const QCString & ref)
inline

Definition at line 123 of file qhp.cpp.

123 void addSection(const QCString &title,const QCString &ref)
124 {
125 m_current->children.push_back(std::make_unique<Node>(m_current,title,ref));
126 }

Reference m_current.

decLevel()

void QhpSectionTree::decLevel ()
inline

Definition at line 133 of file qhp.cpp.

133 void decLevel()
134 {
135 assert(m_current->parent!=nullptr);
136 if (m_current->parent)
137 {
138 m_current = m_current->parent;
139 }
140 }

Reference m_current.

incLevel()

void QhpSectionTree::incLevel ()
inline

Definition at line 127 of file qhp.cpp.

127 void incLevel()
128 {
129 auto newNode = new Node(m_current);
130 m_current->children.push_back(std::unique_ptr<Node>(newNode));
131 m_current = newNode;
132 }

Reference m_current.

writeToc()

void QhpSectionTree::writeToc (TextStream & t)
inline

Definition at line 141 of file qhp.cpp.

141 void writeToc(TextStream &t) const
142 {
143 writeIndent(t,2);
144 t << "<toc>\n";
145 traverse(m_root,t,3);
146 writeIndent(t,2);
147 t << "</toc>\n";
148 }

References m_root, traverse and writeIndent.

Private Member Functions

traverse()

void QhpSectionTree::traverse (const Node & root, TextStream & t, int indent)
inline

Definition at line 68 of file qhp.cpp.

68 void traverse(const Node &root,TextStream &t,int indent) const
69 {
70 /* Input: Output:
71 * =================================================
72 * Section1 <section title=".." ref="..">
73 * Dir1
74 * Section2 <section title=".." ref="..">
75 * Dir2
76 * Section3 <section title=".." ref=".."/>
77 * </section>
78 * </section>
79 * Section4 <section title=".." ref="..>
80 * Dir3
81 * Dir4
82 * Section5 <section title=.." ref=.."/>
83 * </section>
84 * Section6 <section title=".." ref=".."/>
85 */
86 size_t numChildren = root.children.size();
87 size_t i=0;
88 while (i<numChildren)
89 {
90 if (root.children[i]->type==Node::Type::Section)
91 {
92 i++;
93 if (i<numChildren && root.children[i]->type==Node::Type::Dir)
94 {
95 // we have a dir node
96 writeIndent(t,indent);
97 t << "<section title=\"" << convertToXML(root.children[i-1]->title) << "\""
98 << " ref=\"" << convertToXML(root.children[i-1]->ref) << "\">\n";
99 while (i<numChildren && root.children[i]->type==Node::Type::Dir)
100 {
101 traverse(*root.children[i].get(),t,indent+1);
102 i++;
103 }
104 writeIndent(t,indent);
105 t << "</section>\n";
106 }
107 else // we have a leaf section node
108 {
109 writeIndent(t,indent);
110 t << "<section title=\"" << convertToXML(root.children[i-1]->title) << "\""
111 << " ref=\"" << convertToXML(root.children[i-1]->ref) << "\"/>\n";
112 }
113 }
114 else // dir without preceding section (no extra indent)
115 {
116 traverse(*root.children[i].get(),t,indent);
117 i++;
118 }
119 }
120 }

References QhpSectionTree::Node::children, convertToXML, QhpSectionTree::Node::Dir, QhpSectionTree::Node::Section, traverse and writeIndent.

Referenced by traverse and writeToc.

Private Member Attributes

m_current

Node* QhpSectionTree::m_current = &m_root

Definition at line 66 of file qhp.cpp.

Referenced by addSection, decLevel and incLevel.

m_root

Node QhpSectionTree::m_root

Definition at line 65 of file qhp.cpp.

Referenced by writeToc.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus by Doxygen 1.14.0.