summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commentscan.l14
-rw-r--r--src/definition.cpp122
-rw-r--r--src/definition.h9
-rw-r--r--src/doxygen.cpp4
-rw-r--r--src/entry.cpp9
-rw-r--r--src/entry.h3
-rw-r--r--src/index.cpp4
-rw-r--r--src/marshal.cpp42
-rw-r--r--src/pagedef.cpp17
-rw-r--r--src/pagedef.h9
-rw-r--r--src/types.h45
-rw-r--r--src/xmlgen.cpp4
12 files changed, 158 insertions, 124 deletions
diff --git a/src/commentscan.l b/src/commentscan.l
index f6cf099..c364312 100644
--- a/src/commentscan.l
+++ b/src/commentscan.l
@@ -2897,26 +2897,22 @@ static bool handleToc(const QCString &, const QCString &opt)
{
if (opt == "html")
{
- current->localToc |= (1 << Definition::Html);
- current->localTocLevel[Definition::Html] = level;
+ current->localToc.enableHtml(level);
}
else if (opt == "latex")
{
- current->localToc |= (1 << Definition::Latex);
- current->localTocLevel[Definition::Latex] = level;
+ current->localToc.enableLatex(level);
}
else if (opt == "xml")
{
- current->localToc |= (1 << Definition::Xml);
- current->localTocLevel[Definition::Xml] = level;
+ current->localToc.enableXml(level);
}
else warn(yyFileName,yyLineNr,"Unknown option specified with \\tableofcontents: `%s'", (*it).stripWhiteSpace().data());
}
}
- if (current->localToc == Definition::None)
+ if (current->localToc.nothingEnabled())
{
- current->localToc |= (1 << Definition::Html);
- current->localTocLevel[Definition::Html] = 5;
+ current->localToc.enableHtml(5); // for backward compatibility
}
}
return FALSE;
diff --git a/src/definition.cpp b/src/definition.cpp
index f44c403..cbfad94 100644
--- a/src/definition.cpp
+++ b/src/definition.cpp
@@ -1614,83 +1614,83 @@ void Definition::writeNavigationPath(OutputList &ol) const
}
// TODO: move to htmlgen
-void Definition::writeToc(OutputList &ol, int localToc, int *localTocLevel)
+void Definition::writeToc(OutputList &ol, const LocalToc &localToc)
{
SectionDict *sectionDict = m_impl->sectionDict;
if (sectionDict==0) return;
- if (PageDef::isLocalToc(localToc, Definition::Html))
- {
- int maxLevel = localTocLevel[Definition::Html];
- ol.pushGeneratorState();
- ol.disableAllBut(OutputGenerator::Html);
- ol.writeString("<div class=\"toc\">");
- ol.writeString("<h3>");
- ol.writeString(theTranslator->trRTFTableOfContents());
- ol.writeString("</h3>\n");
- ol.writeString("<ul>");
- SDict<SectionInfo>::Iterator li(*sectionDict);
- SectionInfo *si;
- int level=1,l;
- char cs[2];
- cs[1]='\0';
- bool inLi[5]={ FALSE, FALSE, FALSE, FALSE };
- for (li.toFirst();(si=li.current());++li)
- {
- if (si->type==SectionInfo::Section ||
- si->type==SectionInfo::Subsection ||
- si->type==SectionInfo::Subsubsection ||
- si->type==SectionInfo::Paragraph)
+ if (localToc.isHtmlEnabled())
+ {
+ int maxLevel = localToc.htmlLevel();
+ ol.pushGeneratorState();
+ ol.disableAllBut(OutputGenerator::Html);
+ ol.writeString("<div class=\"toc\">");
+ ol.writeString("<h3>");
+ ol.writeString(theTranslator->trRTFTableOfContents());
+ ol.writeString("</h3>\n");
+ ol.writeString("<ul>");
+ SDict<SectionInfo>::Iterator li(*sectionDict);
+ SectionInfo *si;
+ int level=1,l;
+ char cs[2];
+ cs[1]='\0';
+ bool inLi[5]={ FALSE, FALSE, FALSE, FALSE };
+ for (li.toFirst();(si=li.current());++li)
{
- //printf(" level=%d title=%s\n",level,si->title.data());
- int nextLevel = (int)si->type;
- if (nextLevel>level)
+ if (si->type==SectionInfo::Section ||
+ si->type==SectionInfo::Subsection ||
+ si->type==SectionInfo::Subsubsection ||
+ si->type==SectionInfo::Paragraph)
{
- for (l=level;l<nextLevel;l++)
+ //printf(" level=%d title=%s\n",level,si->title.data());
+ int nextLevel = (int)si->type;
+ if (nextLevel>level)
{
- if (l < maxLevel) ol.writeString("<ul>");
+ for (l=level;l<nextLevel;l++)
+ {
+ if (l < maxLevel) ol.writeString("<ul>");
+ }
}
- }
- else if (nextLevel<level)
- {
- for (l=level;l>nextLevel;l--)
+ else if (nextLevel<level)
{
- if (l <= maxLevel && inLi[l]) ol.writeString("</li>\n");
- inLi[l]=FALSE;
- if (l <= maxLevel) ol.writeString("</ul>\n");
+ for (l=level;l>nextLevel;l--)
+ {
+ if (l <= maxLevel && inLi[l]) ol.writeString("</li>\n");
+ inLi[l]=FALSE;
+ if (l <= maxLevel) ol.writeString("</ul>\n");
+ }
}
+ cs[0]='0'+nextLevel;
+ if (nextLevel <= maxLevel && inLi[nextLevel]) ol.writeString("</li>\n");
+ QCString titleDoc = convertToHtml(si->title);
+ if (nextLevel <= maxLevel) ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+(si->title.isEmpty()?si->label:titleDoc)+"</a>");
+ inLi[nextLevel]=TRUE;
+ level = nextLevel;
}
- cs[0]='0'+nextLevel;
- if (nextLevel <= maxLevel && inLi[nextLevel]) ol.writeString("</li>\n");
- QCString titleDoc = convertToHtml(si->title);
- if (nextLevel <= maxLevel) ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+(si->title.isEmpty()?si->label:titleDoc)+"</a>");
- inLi[nextLevel]=TRUE;
- level = nextLevel;
}
- }
- while (level>1 && level <= maxLevel)
- {
- if (inLi[level]) ol.writeString("</li>\n");
+ while (level>1 && level <= maxLevel)
+ {
+ if (inLi[level]) ol.writeString("</li>\n");
+ inLi[level]=FALSE;
+ ol.writeString("</ul>\n");
+ level--;
+ }
+ if (level <= maxLevel && inLi[level]) ol.writeString("</li>\n");
inLi[level]=FALSE;
ol.writeString("</ul>\n");
- level--;
- }
- if (level <= maxLevel && inLi[level]) ol.writeString("</li>\n");
- inLi[level]=FALSE;
- ol.writeString("</ul>\n");
- ol.writeString("</div>\n");
- ol.popGeneratorState();
+ ol.writeString("</div>\n");
+ ol.popGeneratorState();
}
- if (PageDef::isLocalToc(localToc, Definition::Latex))
+ if (localToc.isLatexEnabled())
{
- char tmp[100];
- ol.pushGeneratorState();
- ol.disableAllBut(OutputGenerator::Latex);
- sprintf(tmp,"\\etocsetnexttocdepth{%d}\n",localTocLevel[Definition::Latex]);
- ol.writeString(tmp);
-
- ol.writeString("\\localtableofcontents\n");
- ol.popGeneratorState();
+ ol.pushGeneratorState();
+ ol.disableAllBut(OutputGenerator::Latex);
+ int maxLevel = localToc.latexLevel();
+
+ ol.writeString("\\etocsetnexttocdepth{"+QCString().setNum(maxLevel)+"}\n");
+
+ ol.writeString("\\localtableofcontents\n");
+ ol.popGeneratorState();
}
}
diff --git a/src/definition.h b/src/definition.h
index ac9cc56..c0428a0 100644
--- a/src/definition.h
+++ b/src/definition.h
@@ -97,13 +97,6 @@ class Definition : public DefinitionIntf
virtual ~Cookie() {}
};
- enum outputLocalTocType {
- None = 0, // absolute value
- Html = 0, // index / also to be used as (1 << Definition::Html)
- Latex = 1, // ...
- Xml = 2, // ...
- numOutputLocalTocType = 3 // number of outputLocalTocType
- };
/*! Create a new definition */
Definition(
const char *defFileName,int defLine,int defColumn,
@@ -356,7 +349,7 @@ class Definition : public DefinitionIntf
void setLocalName(const QCString name);
void addSectionsToIndex();
- void writeToc(OutputList &ol, int localToc, int *localTocLevel);
+ void writeToc(OutputList &ol, const LocalToc &lt);
void setCookie(Cookie *cookie) { delete m_cookie; m_cookie = cookie; }
Cookie *cookie() const { return m_cookie; }
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 8facb3f..7353516 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -609,7 +609,7 @@ static void addRelatedPage(EntryNav *rootNav)
{
pd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
pd->addSectionsToDefinition(root->anchors);
- pd->setShowToc(root->localToc, root->localTocLevel);
+ pd->setLocalToc(root->localToc);
addPageToContext(pd,rootNav);
}
}
@@ -8716,7 +8716,7 @@ static void findMainPage(EntryNav *rootNav)
//setFileNameForSections(root->anchors,"index",Doxygen::mainPage);
Doxygen::mainPage->setBriefDescription(root->brief,root->briefFile,root->briefLine);
Doxygen::mainPage->setFileName(indexName);
- Doxygen::mainPage->setShowToc(root->localToc, root->localTocLevel);
+ Doxygen::mainPage->setLocalToc(root->localToc);
addPageToContext(Doxygen::mainPage,rootNav);
SectionInfo *si = Doxygen::sectionDict->find(Doxygen::mainPage->name());
diff --git a/src/entry.cpp b/src/entry.cpp
index e4fb0a5..a0460da 100644
--- a/src/entry.cpp
+++ b/src/entry.cpp
@@ -74,10 +74,6 @@ Entry::Entry(const Entry &e)
initLines = e.initLines;
stat = e.stat;
localToc = e.localToc;
- for (int i = 0; i < sizeof(localTocLevel) / sizeof(*localTocLevel) ; i++)
- {
- localTocLevel[i] = e.localTocLevel[i];
- }
explicitExternal = e.explicitExternal;
proto = e.proto;
subGrouping = e.subGrouping;
@@ -258,11 +254,6 @@ void Entry::reset()
mtype = Method;
virt = Normal;
stat = FALSE;
- localToc = Definition::None;
- for (int i = 0; i < sizeof(localTocLevel) / sizeof(*localTocLevel) ; i++)
- {
- localTocLevel[i] = 0;
- }
proto = FALSE;
explicitExternal = FALSE;
spec = 0;
diff --git a/src/entry.h b/src/entry.h
index 8513fb9..fac3831 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -288,8 +288,7 @@ class Entry
bool artificial; //!< Artificially introduced item
GroupDocType groupDocType;
QCString id; //!< libclang id
- int localToc; //!< types of local TOC, command \tableofcontents
- int localTocLevel[3];//!< depth of local TOC, command \tableofcontents
+ LocalToc localToc;
static int num; //!< counts the total number of entries
diff --git a/src/index.cpp b/src/index.cpp
index b403de3..3c231fc 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -3883,9 +3883,9 @@ static void writeIndex(OutputList &ol)
if (Doxygen::mainPage)
{
Doxygen::insideMainPage=TRUE;
- if (Doxygen::mainPage->showToc() && Doxygen::mainPage->hasSections())
+ if (Doxygen::mainPage->localToc().isHtmlEnabled() && Doxygen::mainPage->hasSections())
{
- Doxygen::mainPage->writeToc(ol,Doxygen::mainPage->showToc(),Doxygen::mainPage->showTocLevel());
+ Doxygen::mainPage->writeToc(ol,Doxygen::mainPage->localToc());
}
ol.startTextBlock();
diff --git a/src/marshal.cpp b/src/marshal.cpp
index 43c5511..f13b6fd 100644
--- a/src/marshal.cpp
+++ b/src/marshal.cpp
@@ -344,6 +344,14 @@ void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls)
}
}
+void marshalLocalToc(StorageIntf *s,const LocalToc &lt)
+{
+ marshalInt(s,lt.mask());
+ marshalInt(s,lt.htmlLevel());
+ marshalInt(s,lt.latexLevel());
+ marshalInt(s,lt.xmlLevel());
+}
+
void marshalEntry(StorageIntf *s,Entry *e)
{
marshalUInt(s,HEADER);
@@ -355,11 +363,7 @@ void marshalEntry(StorageIntf *s,Entry *e)
marshalUInt64(s,e->spec);
marshalInt(s,e->initLines);
marshalBool(s,e->stat);
- marshalInt(s,e->localToc);
- for (int i = 0; i < sizeof(e->localTocLevel) / sizeof(*(e->localTocLevel)) ; i++)
- {
- marshalInt(s,e->localTocLevel[i]);
- }
+ marshalLocalToc(s,e->localToc);
marshalBool(s,e->explicitExternal);
marshalBool(s,e->proto);
marshalBool(s,e->subGrouping);
@@ -729,6 +733,28 @@ SDict<MemberList> *unmarshalMemberLists(StorageIntf *s)
return result;
}
+LocalToc unmarshalLocalToc(StorageIntf *s)
+{
+ LocalToc result;
+ int mask = unmarshalInt(s);
+ int htmlLevel = unmarshalInt(s);
+ int latexLevel = unmarshalInt(s);
+ int xmlLevel = unmarshalInt(s);
+ if ((mask & LocalToc::Html)!=0)
+ {
+ result.enableHtml(htmlLevel);
+ }
+ if ((mask & LocalToc::Latex)!=0)
+ {
+ result.enableLatex(latexLevel);
+ }
+ if ((mask & LocalToc::Xml)!=0)
+ {
+ result.enableXml(xmlLevel);
+ }
+ return result;
+}
+
Entry * unmarshalEntry(StorageIntf *s)
{
Entry *e = new Entry;
@@ -742,11 +768,7 @@ Entry * unmarshalEntry(StorageIntf *s)
e->spec = unmarshalUInt64(s);
e->initLines = unmarshalInt(s);
e->stat = unmarshalBool(s);
- e->localToc = unmarshalInt(s);
- for (int i = 0; i < sizeof(e->localTocLevel) / sizeof(*(e->localTocLevel)) ; i++)
- {
- e->localTocLevel[i] = unmarshalInt(s);
- }
+ e->localToc = unmarshalLocalToc(s);
e->explicitExternal = unmarshalBool(s);
e->proto = unmarshalBool(s);
e->subGrouping = unmarshalBool(s);
diff --git a/src/pagedef.cpp b/src/pagedef.cpp
index df5cf0d..4721306 100644
--- a/src/pagedef.cpp
+++ b/src/pagedef.cpp
@@ -35,11 +35,6 @@ PageDef::PageDef(const char *f,int l,const char *n,
m_pageScope = 0;
m_nestingLevel = 0;
m_fileName = ::convertNameToFile(n,FALSE,TRUE);
- m_showToc = Definition::None;
- for (int i = 0; i < sizeof(m_localTocLevel) / sizeof(*m_localTocLevel) ; i++)
- {
- m_localTocLevel[i] = 0;
- }
}
PageDef::~PageDef()
@@ -211,9 +206,9 @@ void PageDef::writeDocumentation(OutputList &ol)
ol.popGeneratorState();
//2.}
- if (m_showToc && hasSections())
+ if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled()) && hasSections())
{
- writeToc(ol, m_showToc, m_localTocLevel);
+ writeToc(ol, m_localToc);
}
writePageDocumentation(ol);
@@ -330,11 +325,7 @@ void PageDef::setNestingLevel(int l)
m_nestingLevel = l;
}
-void PageDef::setShowToc(int localToc, int *localTocLevel)
+void PageDef::setLocalToc(const LocalToc &lt)
{
- m_showToc |= localToc;
- for (int i = 0; i < sizeof(m_localTocLevel) / sizeof(*m_localTocLevel) ; i++)
- {
- m_localTocLevel[i] += localTocLevel[i];
- }
+ m_localToc = lt;
}
diff --git a/src/pagedef.h b/src/pagedef.h
index 7016049..27316cb 100644
--- a/src/pagedef.h
+++ b/src/pagedef.h
@@ -34,7 +34,7 @@ class PageDef : public Definition
// setters
void setFileName(const char *name);
- void setShowToc(int localToc, int *localTocLevel);
+ void setLocalToc(const LocalToc &tl);
// getters
DefType definitionType() const { return TypePage; }
@@ -59,9 +59,7 @@ class PageDef : public Definition
bool documentedPage() const;
bool hasSubPages() const;
bool hasParentPage() const;
- int showToc() const { return m_showToc; }
- int *showTocLevel() { return m_localTocLevel; }
- static bool isLocalToc(int localToc, int tocType) { return(localToc & (1 << tocType)); }
+ LocalToc localToc() const { return m_localToc; }
void setPageScope(Definition *d){ m_pageScope = d; }
Definition *getPageScope() const { return m_pageScope; }
QCString displayName(bool=TRUE) const { return !m_title.isEmpty() ? m_title : Definition::name(); }
@@ -77,8 +75,7 @@ class PageDef : public Definition
PageSDict *m_subPageDict; // list of pages in the group
Definition *m_pageScope;
int m_nestingLevel;
- int m_showToc;
- int m_localTocLevel[numOutputLocalTocType];
+ LocalToc m_localToc;
};
class PageSDict : public SDict<PageDef>
diff --git a/src/types.h b/src/types.h
index 806e6fc..36f31fe 100644
--- a/src/types.h
+++ b/src/types.h
@@ -16,6 +16,7 @@
#ifndef TYPES_H
#define TYPES_H
+#include <string.h>
#include <qcstring.h>
/** @file
@@ -218,4 +219,48 @@ enum FortranFormat
FortranFormat_Fixed
};
+class LocalToc
+{
+ public:
+ enum Type {
+ None = 0, // initial value
+ Html = 0, // index / also to be used as (1 << Definition::Html)
+ Latex = 1, // ...
+ Xml = 2, // ...
+ numTocTypes = 3 // number of enum values
+ };
+ LocalToc() : m_mask(None) { memset(m_level,0,sizeof(m_level)); }
+
+ // setters
+ void enableHtml(int level)
+ {
+ m_mask|=(1<<Html);
+ m_level[Html]=level;
+ }
+ void enableLatex(int level)
+ {
+ m_mask|=(1<<Latex);
+ m_level[Latex]=level;
+ }
+ void enableXml(int level)
+ {
+ m_mask|=(1<<Xml);
+ m_level[Xml]=level;
+ }
+
+ // getters
+ bool isHtmlEnabled() const { return (m_mask & Html)!=0; }
+ bool isLatexEnabled() const { return (m_mask & Latex)!=0; }
+ bool isXmlEnabled() const { return (m_mask & Xml)!=0; }
+ bool nothingEnabled() const { return m_mask == None; }
+ int htmlLevel() const { return m_level[Html]; }
+ int latexLevel() const { return m_level[Latex]; }
+ int xmlLevel() const { return m_level[Xml]; }
+ int mask() const { return m_mask; }
+
+ private:
+ int m_mask;
+ int m_level[numTocTypes];
+};
+
#endif
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index 02756d3..e68c454 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -1838,7 +1838,7 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample)
}
}
writeInnerPages(pd->getSubPages(),t);
- if (PageDef::isLocalToc(pd->showToc(), Definition::Xml))
+ if (pd->localToc().isXmlEnabled())
{
t << " <tableofcontents>" << endl;
SectionDict *sectionDict = pd->getSectionDict();
@@ -1846,7 +1846,7 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample)
SectionInfo *si;
int level=1,l;
bool inLi[5]={ FALSE, FALSE, FALSE, FALSE };
- int maxLevel = (pd -> showTocLevel())[Definition::Xml];
+ int maxLevel = pd->localToc().xmlLevel();
for (li.toFirst();(si=li.current());++li)
{
if (si->type==SectionInfo::Section ||