Skip to content

Commit d1d0559

Browse files
committed
Replaced marcos by member functions and some renaming
1 parent 0e0f735 commit d1d0559

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

src/docbookgen.cpp

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,6 @@
7070
#define DB_GEN_C2a(x,y)
7171
#endif
7272

73-
74-
// helper defines for opening / closing sections
75-
// currently only closing. possible also usage for debug.
76-
77-
#define OPEN_SECTION(mt) \
78-
{ \
79-
mt << "<section>\n"; \
80-
m_openSection++; \
81-
}
82-
#define OPEN_SECTION1(mt,txt) \
83-
{ \
84-
mt << "<section " << txt <<">\n"; \
85-
m_openSection++; \
86-
}
87-
#define CLOSE_SECTION(mt) \
88-
{ \
89-
mt << "</section>\n"; \
90-
m_openSection--; \
91-
}
9273
//------------------
9374

9475
inline void writeDocbookString(TextStream &t,const QCString &s)
@@ -374,10 +355,7 @@ DB_GEN_C
374355
void DocbookGenerator::endFile()
375356
{
376357
DB_GEN_C
377-
while (m_openSection > 0)
378-
{
379-
CLOSE_SECTION(m_t);
380-
}
358+
closeAllSections();
381359
m_inLevel = -1;
382360
m_inGroup = FALSE;
383361

@@ -769,16 +747,16 @@ DB_GEN_C2("extraIndentLevel " << extraIndentLevel)
769747
if (m_inSimpleSect[m_levelListItem]) m_t << "</simplesect>\n";
770748
m_inSimpleSect[m_levelListItem] = FALSE;
771749
if (m_inLevel != -1) m_inGroup = TRUE;
772-
if (m_inLevel == extraIndentLevel) CLOSE_SECTION(m_t);
750+
if (m_inLevel == extraIndentLevel) closeSection();
773751
m_inLevel = extraIndentLevel;
774-
OPEN_SECTION(m_t);
752+
openSection();
775753
m_t << "<title>";
776754
}
777755
void DocbookGenerator::writeRuler()
778756
{
779757
DB_GEN_C2("m_inLevel " << m_inLevel)
780758
DB_GEN_C2("m_inGroup " << m_inGroup)
781-
if (m_inGroup) CLOSE_SECTION(m_t);
759+
if (m_inGroup) closeSection();
782760
m_inGroup = FALSE;
783761
}
784762

@@ -839,7 +817,7 @@ void DocbookGenerator::startMemberDoc(const QCString &clname, const QCString &me
839817
int memCount, int memTotal, bool)
840818
{
841819
DB_GEN_C2("m_inLevel " << m_inLevel)
842-
OPEN_SECTION(m_t);
820+
openSection();
843821
m_t << " <title>" << convertToDocBook(title);
844822
if (memTotal>1)
845823
{
@@ -875,7 +853,7 @@ void DocbookGenerator::startDoxyAnchor(const QCString &fName,const QCString &,
875853
DB_GEN_C
876854
if (!m_inListItem[m_levelListItem] && !m_descTable && !m_simpleTable)
877855
{
878-
if (!m_firstMember) CLOSE_SECTION(m_t);
856+
if (!m_firstMember) closeSection();
879857
m_firstMember = FALSE;
880858
}
881859
if (!anchor.isEmpty())
@@ -1032,14 +1010,14 @@ DB_GEN_C
10321010
void DocbookGenerator::startSection(const QCString &lab,const QCString &,SectionType)
10331011
{
10341012
DB_GEN_C
1035-
OPEN_SECTION1(m_t, "xml:id=\"_" + stripPath(lab) + "\"");
1013+
openSection("xml:id=\"_" + stripPath(lab) + "\"");
10361014
m_t << "<title>";
10371015
}
10381016
void DocbookGenerator::endSection(const QCString &,SectionType)
10391017
{
10401018
DB_GEN_C
10411019
m_t << "</title>";
1042-
CLOSE_SECTION(m_t);
1020+
closeSection();
10431021
}
10441022
void DocbookGenerator::addIndexItem(const QCString &prim,const QCString &sec)
10451023
{
@@ -1269,3 +1247,26 @@ void DocbookGenerator::endConstraintList()
12691247
DB_GEN_C
12701248
m_t << "</simplesect>\n";
12711249
}
1250+
1251+
void DocbookGenerator::openSection(const QCString &attr)
1252+
{
1253+
m_t << "<section";
1254+
if (!attr.isEmpty()) m_t << " " << attr;
1255+
m_t << ">\n";
1256+
m_openSectionCount++;
1257+
}
1258+
1259+
void DocbookGenerator::closeSection()
1260+
{
1261+
m_t << "</section>\n";
1262+
m_openSectionCount--;
1263+
}
1264+
1265+
void DocbookGenerator::closeAllSections()
1266+
{
1267+
while (m_openSectionCount>0)
1268+
{
1269+
closeSection();
1270+
}
1271+
}
1272+

src/docbookgen.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ class DocbookGenerator : public OutputGenerator
338338
void addWord(const QCString &,bool) {DB_GEN_EMPTY}
339339

340340
private:
341+
void openSection(const QCString &attr=QCString());
342+
void closeSection();
343+
void closeAllSections();
341344

342345
QCString relPath;
343346
DocbookCodeGenerator m_codeGen;
@@ -351,7 +354,7 @@ class DocbookGenerator : public OutputGenerator
351354
bool m_simpleTable = false;
352355
int m_inLevel = -1;
353356
bool m_firstMember = false;
354-
int m_openSection = 0;
357+
int m_openSectionCount = 0;
355358
};
356359

357360
#endif

0 commit comments

Comments
 (0)