Doxygen
Loading...
Searching...
No Matches
QhpSectionTree Class Reference
+ Collaboration diagram for QhpSectionTree:

Classes

struct  Node
 

Public Member Functions

void addSection (const QCString &title, const QCString &ref)
 
void incLevel ()
 
void decLevel ()
 
void writeToc (TextStream &t) const
 

Private Member Functions

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

Private Attributes

Node m_root
 
Nodem_current = &m_root
 

Detailed Description

Definition at line 45 of file qhp.cpp.

Member Function Documentation

◆ addSection()

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

Definition at line 123 of file qhp.cpp.

124 {
125 m_current->children.push_back(std::make_unique<Node>(m_current,title,ref));
126 }
Node * m_current
Definition qhp.cpp:66

References m_current.

◆ decLevel()

void QhpSectionTree::decLevel ( )
inline

Definition at line 133 of file qhp.cpp.

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

References m_current.

◆ incLevel()

void QhpSectionTree::incLevel ( )
inline

Definition at line 127 of file qhp.cpp.

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

References m_current.

◆ traverse()

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

Definition at line 68 of file qhp.cpp.

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 }
void traverse(const Node &root, TextStream &t, int indent) const
Definition qhp.cpp:68
static void writeIndent(TextStream &t, int indent)
Definition qhp.cpp:37
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266

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

Referenced by traverse(), and writeToc().

◆ writeToc()

void QhpSectionTree::writeToc ( TextStream & t) const
inline

Definition at line 141 of file qhp.cpp.

142 {
143 writeIndent(t,2);
144 t << "<toc>\n";
145 traverse(m_root,t,3);
146 writeIndent(t,2);
147 t << "</toc>\n";
148 }
Node m_root
Definition qhp.cpp:65

References m_root, traverse(), and writeIndent().

Member Data Documentation

◆ m_current

Node* QhpSectionTree::m_current = &m_root
private

Definition at line 66 of file qhp.cpp.

Referenced by addSection(), decLevel(), and incLevel().

◆ m_root

Node QhpSectionTree::m_root
private

Definition at line 65 of file qhp.cpp.

Referenced by writeToc().


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