summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classdef.cpp48
-rw-r--r--src/classdef.h4
-rw-r--r--src/configimpl.l2
-rw-r--r--src/context.cpp20
-rw-r--r--src/doxygen.cpp27
-rw-r--r--src/example.h32
-rw-r--r--src/memberdef.cpp46
-rw-r--r--src/memberdef.h4
-rw-r--r--src/util.cpp12
-rw-r--r--src/util.h2
10 files changed, 83 insertions, 114 deletions
diff --git a/src/classdef.cpp b/src/classdef.cpp
index c573d27..c1c9859 100644
--- a/src/classdef.cpp
+++ b/src/classdef.cpp
@@ -237,7 +237,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable>
virtual QCString generatedFromFiles() const;
virtual const FileList &usedFiles() const;
virtual const ArgumentList &typeConstraints() const;
- virtual const ExampleSDict *exampleList() const;
+ virtual const ExampleList &getExamples() const;
virtual bool hasExamples() const;
virtual QCString getMemberListFileName() const;
virtual bool subGrouping() const;
@@ -523,8 +523,8 @@ class ClassDefAliasImpl : public DefinitionAliasMixin<ClassDef>
{ return getCdAlias()->usedFiles(); }
virtual const ArgumentList &typeConstraints() const
{ return getCdAlias()->typeConstraints(); }
- virtual const ExampleSDict *exampleList() const
- { return getCdAlias()->exampleList(); }
+ virtual const ExampleList &getExamples() const
+ { return getCdAlias()->getExamples(); }
virtual bool hasExamples() const
{ return getCdAlias()->hasExamples(); }
virtual QCString getMemberListFileName() const
@@ -627,7 +627,7 @@ class ClassDefImpl::IMPL
FileList files;
/*! Examples that use this class */
- ExampleSDict *exampleSDict = 0;
+ ExampleList examples;
/*! Holds the kind of "class" this is. */
ClassDef::CompoundType compType;
@@ -732,7 +732,6 @@ void ClassDefImpl::IMPL::init(const char *defFileName, const char *name,
{
fileName=ctStr+name;
}
- exampleSDict = 0;
incInfo=0;
prot=Public;
nspace=0;
@@ -780,7 +779,6 @@ ClassDefImpl::IMPL::IMPL() : vhdlSummaryTitles(17)
ClassDefImpl::IMPL::~IMPL()
{
- delete exampleSDict;
delete usesImplClassDict;
delete usedByImplClassDict;
delete usesIntfClassDict;
@@ -1439,12 +1437,12 @@ void ClassDefImpl::writeDetailedDocumentationBody(OutputList &ol) const
writeTypeConstraints(ol,this,m_impl->typeConstraints);
// write examples
- if (hasExamples() && m_impl->exampleSDict)
+ if (hasExamples())
{
ol.startExamples();
ol.startDescForItem();
//ol.startParagraph();
- writeExample(ol,m_impl->exampleSDict);
+ writeExamples(ol,m_impl->examples);
//ol.endParagraph();
ol.endDescForItem();
ol.endExamples();
@@ -3137,35 +3135,15 @@ void ClassDefImpl::writeMemberList(OutputList &ol) const
}
// add a reference to an example
-bool ClassDefImpl::addExample(const char *anchor,const char *nameStr,
- const char *file)
+bool ClassDefImpl::addExample(const char *anchor,const char *nameStr, const char *file)
{
- if (m_impl->exampleSDict==0)
- {
- m_impl->exampleSDict = new ExampleSDict;
- m_impl->exampleSDict->setAutoDelete(TRUE);
- }
- if (!m_impl->exampleSDict->find(nameStr))
- {
- Example *e=new Example;
- e->anchor=anchor;
- e->name=nameStr;
- e->file=file;
- m_impl->exampleSDict->inSort(nameStr,e);
- return TRUE;
- }
- return FALSE;
+ return m_impl->examples.inSort(Example(anchor,nameStr,file));
}
// returns TRUE if this class is used in an example
bool ClassDefImpl::hasExamples() const
{
- bool result=FALSE;
- if (m_impl->exampleSDict)
- {
- result = m_impl->exampleSDict->count()>0;
- }
- return result;
+ return !m_impl->examples.empty();
}
void ClassDefImpl::addTypeConstraint(const QCString &typeConstraint,const QCString &type)
@@ -4012,6 +3990,7 @@ ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName,
templateClass->setTemplateMaster(this);
templateClass->setOuterScope(getOuterScope());
templateClass->setHidden(isHidden());
+ templateClass->setArtificial(isArtificial());
m_impl->templateInstances->insert(templSpec,templateClass);
// also add nested classes
@@ -4028,9 +4007,10 @@ ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName,
templateClass->addInnerCompound(innerClass);
innerClass->setOuterScope(templateClass);
innerClass->setHidden(isHidden());
+ templateClass->setArtificial(isArtificial());
+ freshInstance=TRUE;
}
}
- freshInstance=TRUE;
}
return templateClass;
}
@@ -5004,9 +4984,9 @@ const ArgumentList &ClassDefImpl::typeConstraints() const
return m_impl->typeConstraints;
}
-const ExampleSDict *ClassDefImpl::exampleList() const
+const ExampleList &ClassDefImpl::getExamples() const
{
- return m_impl->exampleSDict;
+ return m_impl->examples;
}
bool ClassDefImpl::subGrouping() const
diff --git a/src/classdef.h b/src/classdef.h
index 408c8d2..9299e3d 100644
--- a/src/classdef.h
+++ b/src/classdef.h
@@ -42,7 +42,7 @@ class FileDef;
class FileList;
class NamespaceDef;
class MemberDef;
-class ExampleSDict;
+class ExampleList;
class MemberNameInfoLinkedMap;
class UsesClassDict;
class ConstraintClassDict;
@@ -346,7 +346,7 @@ class ClassDef : public Definition
virtual const FileList &usedFiles() const = 0;
virtual const ArgumentList &typeConstraints() const = 0;
- virtual const ExampleSDict *exampleList() const = 0;
+ virtual const ExampleList &getExamples() const = 0;
virtual bool hasExamples() const = 0;
virtual QCString getMemberListFileName() const = 0;
virtual bool subGrouping() const = 0;
diff --git a/src/configimpl.l b/src/configimpl.l
index 17e56b3..7f73ec0 100644
--- a/src/configimpl.l
+++ b/src/configimpl.l
@@ -873,7 +873,7 @@ static void readIncludeFile(const char *incName)
g_config->appendUserComment(yytext);
g_yyLineNr++;
}
-<Start>"#"[^#].*"\n" { /* normal comment */
+<Start>"#".*"\n" { /* normal comment */
g_yyLineNr++;
}
diff --git a/src/context.cpp b/src/context.cpp
index 24ef4b4..9b4100c 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -2376,15 +2376,13 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
{
if (m_classDef->hasExamples())
{
- ExampleSDict::Iterator it(*m_classDef->exampleList());
- Example *ex;
- for (it.toFirst();(ex=it.current());++it)
+ for (const auto &ex : m_classDef->getExamples())
{
TemplateStruct *s = TemplateStruct::alloc();
- s->set("text",ex->name);
+ s->set("text",ex.name);
s->set("isLinkable",TRUE);
- s->set("anchor",ex->anchor);
- s->set("fileName",ex->file);
+ s->set("anchor",ex.anchor);
+ s->set("fileName",ex.file);
s->set("isReference",FALSE);
s->set("externalReference","");
list->append(s);
@@ -4845,15 +4843,13 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
{
if (m_memberDef->hasExamples())
{
- ExampleSDict::Iterator it(*m_memberDef->getExamples());
- Example *ex;
- for (it.toFirst();(ex=it.current());++it)
+ for (const auto &ex : m_memberDef->getExamples())
{
TemplateStruct *s = TemplateStruct::alloc();
- s->set("text",ex->name);
+ s->set("text",ex.name);
s->set("isLinkable",TRUE);
- s->set("anchor",ex->anchor);
- s->set("fileName",ex->file);
+ s->set("anchor",ex.anchor);
+ s->set("fileName",ex.file);
s->set("isReference",FALSE);
s->set("externalReference","");
list->append(s);
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index dea5cac..1e7a663 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -1190,10 +1190,11 @@ static void resolveClassNestingRelations()
++iteration;
struct ClassAlias
{
- ClassAlias(const QCString &name,std::unique_ptr<ClassDef> cd) :
- aliasFullName(name),aliasCd(std::move(cd)) {}
+ ClassAlias(const QCString &name,std::unique_ptr<ClassDef> cd,DefinitionMutable *ctx) :
+ aliasFullName(name),aliasCd(std::move(cd)), aliasContext(ctx) {}
const QCString aliasFullName;
std::unique_ptr<ClassDef> aliasCd;
+ DefinitionMutable *aliasContext;
};
std::vector<ClassAlias> aliases;
for (const auto &icd : *Doxygen::classLinkedMap)
@@ -1230,9 +1231,8 @@ static void resolveClassNestingRelations()
if (dm)
{
std::unique_ptr<ClassDef> aliasCd { createClassDefAlias(d,cd) };
- dm->addInnerCompound(aliasCd.get());
QCString aliasFullName = d->qualifiedName()+"::"+aliasCd->localName();
- aliases.push_back(ClassAlias(aliasFullName,std::move(aliasCd)));
+ aliases.push_back(ClassAlias(aliasFullName,std::move(aliasCd),dm));
//printf("adding %s to %s as %s\n",qPrint(aliasCd->name()),qPrint(d->name()),qPrint(aliasFullName));
}
}
@@ -1255,7 +1255,11 @@ static void resolveClassNestingRelations()
// add aliases
for (auto &alias : aliases)
{
- Doxygen::classLinkedMap->add(alias.aliasFullName,std::move(alias.aliasCd));
+ ClassDef *aliasCd = Doxygen::classLinkedMap->add(alias.aliasFullName,std::move(alias.aliasCd));
+ if (aliasCd)
+ {
+ alias.aliasContext->addInnerCompound(aliasCd);
+ }
}
}
@@ -4156,7 +4160,18 @@ static bool findTemplateInstanceRelation(const Entry *root,
ClassDefMutable *instanceClass = toClassDefMutable(
templateClass->insertTemplateInstance(
root->fileName,root->startLine,root->startColumn,templSpec,freshInstance));
- if (isArtificial) instanceClass->setArtificial(TRUE);
+ if (isArtificial)
+ {
+ instanceClass->setArtificial(TRUE);
+ for (const auto innerClass : instanceClass->getClasses())
+ {
+ ClassDefMutable *innerClassMutable = toClassDefMutable(innerClass);
+ if (innerClassMutable)
+ {
+ innerClassMutable->setArtificial(TRUE);
+ }
+ }
+ }
instanceClass->setLanguage(root->lang);
if (freshInstance)
diff --git a/src/example.h b/src/example.h
index 2af06ba..7929c24 100644
--- a/src/example.h
+++ b/src/example.h
@@ -1,12 +1,10 @@
/******************************************************************************
*
- *
- *
- * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ * Copyright (C) 1997-2021 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
@@ -18,8 +16,10 @@
#ifndef EXAMPLE_H
#define EXAMPLE_H
+#include <algorithm>
+#include <vector>
+
#include <qcstring.h>
-#include "sortdict.h"
class ClassDef;
class MemberName;
@@ -27,21 +27,27 @@ class MemberName;
/** Data associated with an example. */
struct Example
{
+ Example(const QCString &a,const QCString &n,const QCString &f) : anchor(a), name(n), file(f) {}
QCString anchor;
QCString name;
QCString file;
};
-/** A sorted dictionary of Example objects. */
-class ExampleSDict : public SDict<Example>
+class ExampleList : public std::vector<Example>
{
public:
- ExampleSDict(uint size=17) : SDict<Example>(size) { setAutoDelete(TRUE); }
- ~ExampleSDict() {}
- private:
- int compareValues(const Example *item1,const Example *item2) const
+ bool inSort( const Example& ex )
{
- return qstricmp(item1->name,item2->name);
+ auto it = std::find_if(begin(),end(),[&ex](const Example &e) { return e.name==ex.name; });
+ if (it==end())
+ {
+ insert( std::upper_bound( begin(), end(), ex,
+ [](const auto &e1,const auto &e2) { return e1.name < e2.name; }
+ ), ex
+ );
+ return true;
+ }
+ return false;
}
};
diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index 638af9e..5499dc5 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -195,7 +195,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable>
virtual void setEnumBaseType(const QCString &type);
virtual QCString enumBaseType() const;
virtual bool hasExamples() const;
- virtual ExampleSDict *getExamples() const;
+ virtual const ExampleList &getExamples() const;
virtual bool isPrototype() const;
virtual const ArgumentList &argumentList() const;
virtual ArgumentList &argumentList();
@@ -655,7 +655,7 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef>
{ return getMdAlias()->enumBaseType(); }
virtual bool hasExamples() const
{ return getMdAlias()->hasExamples(); }
- virtual ExampleSDict *getExamples() const
+ virtual const ExampleList &getExamples() const
{ return getMdAlias()->getExamples(); }
virtual bool isPrototype() const
{ return getMdAlias()->isPrototype(); }
@@ -1198,7 +1198,7 @@ class MemberDefImpl::IMPL
MemberDef *memDec = 0; // member declaration for this definition
ClassDef *relatedAlso = 0; // points to class marked by relatedAlso
- ExampleSDict *exampleSDict = 0; // a dictionary of all examples for quick access
+ ExampleList examples; // a dictionary of all examples for quick access
QCString type; // return actual type
QCString accessorType; // return type that tell how to get to this member
@@ -1302,7 +1302,6 @@ class MemberDefImpl::IMPL
MemberDefImpl::IMPL::IMPL() :
enumFields(0),
redefinedBy(0),
- exampleSDict(0),
classSectionSDict(0),
category(0),
categoryRelation(0),
@@ -1315,7 +1314,6 @@ MemberDefImpl::IMPL::IMPL() :
MemberDefImpl::IMPL::~IMPL()
{
delete redefinedBy;
- delete exampleSDict;
delete enumFields;
delete classSectionSDict;
}
@@ -1338,7 +1336,6 @@ void MemberDefImpl::IMPL::init(Definition *d,
memDec=0;
group=0;
grpId=-1;
- exampleSDict=0;
enumFields=0;
enumScope=0;
livesInsideEnum=FALSE;
@@ -1462,7 +1459,6 @@ MemberDef *MemberDefImpl::deepCopy() const
*result->m_impl = *m_impl;
// clear pointers owned by object
result->m_impl->redefinedBy= 0;
- result->m_impl->exampleSDict=0;
result->m_impl->enumFields=0;
result->m_impl->classSectionSDict=0;
// replace pointers owned by the object by deep copies
@@ -1475,15 +1471,6 @@ MemberDef *MemberDefImpl::deepCopy() const
result->insertReimplementedBy(md);
}
}
- if (m_impl->exampleSDict)
- {
- ExampleSDict::Iterator it(*m_impl->exampleSDict);
- Example *e;
- for (it.toFirst();(e=it.current());++it)
- {
- result->addExample(e->anchor,e->name,e->file);
- }
- }
if (m_impl->enumFields)
{
MemberListIterator mli(*m_impl->enumFields);
@@ -1598,30 +1585,15 @@ void MemberDefImpl::insertEnumField(MemberDef *md)
m_impl->enumFields->append(md);
}
-bool MemberDefImpl::addExample(const char *anchor,const char *nameStr,
- const char *file)
+bool MemberDefImpl::addExample(const char *anchor,const char *nameStr, const char *file)
{
//printf("%s::addExample(%s,%s,%s)\n",name().data(),anchor,nameStr,file);
- if (m_impl->exampleSDict==0) m_impl->exampleSDict = new ExampleSDict;
- if (m_impl->exampleSDict->find(nameStr)==0)
- {
- //printf("Add reference to example %s to member %s\n",nameStr,name.data());
- Example *e=new Example;
- e->anchor=anchor;
- e->name=nameStr;
- e->file=file;
- m_impl->exampleSDict->inSort(nameStr,e);
- return TRUE;
- }
- return FALSE;
+ return m_impl->examples.inSort(Example(anchor,nameStr,file));
}
bool MemberDefImpl::hasExamples() const
{
- if (m_impl->exampleSDict==0)
- return FALSE;
- else
- return m_impl->exampleSDict->count()>0;
+ return !m_impl->examples.empty();
}
QCString MemberDefImpl::getOutputFileBase() const
@@ -3001,7 +2973,7 @@ void MemberDefImpl::_writeExamples(OutputList &ol) const
{
ol.startExamples();
ol.startDescForItem();
- writeExample(ol,m_impl->exampleSDict);
+ writeExamples(ol,m_impl->examples);
ol.endDescForItem();
ol.endExamples();
}
@@ -5353,9 +5325,9 @@ const MemberList *MemberDefImpl::enumFieldList() const
return m_impl->enumFields;
}
-ExampleSDict *MemberDefImpl::getExamples() const
+const ExampleList &MemberDefImpl::getExamples() const
{
- return m_impl->exampleSDict;
+ return m_impl->examples;
}
bool MemberDefImpl::isPrototype() const
diff --git a/src/memberdef.h b/src/memberdef.h
index 11d403c..1fbfc27 100644
--- a/src/memberdef.h
+++ b/src/memberdef.h
@@ -34,7 +34,7 @@ class GroupDef;
class FileDef;
class MemberList;
class MemberGroup;
-class ExampleSDict;
+class ExampleList;
class OutputList;
class GroupDef;
class QTextStream;
@@ -214,7 +214,7 @@ class MemberDef : public Definition
virtual QCString enumBaseType() const = 0;
virtual bool hasExamples() const = 0;
- virtual ExampleSDict *getExamples() const = 0;
+ virtual const ExampleList &getExamples() const = 0;
virtual bool isPrototype() const = 0;
// argument related members
diff --git a/src/util.cpp b/src/util.cpp
index d64994b..665df8b 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1070,9 +1070,9 @@ void linkifyText(const TextGeneratorIntf &out, const Definition *scope,
}
-void writeExample(OutputList &ol,ExampleSDict *ed)
+void writeExamples(OutputList &ol,const ExampleList &list)
{
- QCString exampleLine=theTranslator->trWriteList(ed->count());
+ QCString exampleLine=theTranslator->trWriteList(list.size());
//bool latexEnabled = ol.isEnabled(OutputGenerator::Latex);
//bool manEnabled = ol.isEnabled(OutputGenerator::Man);
@@ -1085,9 +1085,9 @@ void writeExample(OutputList &ol,ExampleSDict *ed)
bool ok;
ol.parseText(exampleLine.mid(index,newIndex-index));
uint entryIndex = exampleLine.mid(newIndex+1,matchLen-1).toUInt(&ok);
- Example *e=ed->at(entryIndex);
- if (ok && e)
+ if (ok && entryIndex<list.size())
{
+ const auto &e = list[entryIndex];
ol.pushGeneratorState();
//if (latexEnabled) ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::Latex);
@@ -1095,7 +1095,7 @@ void writeExample(OutputList &ol,ExampleSDict *ed)
ol.disable(OutputGenerator::Docbook);
// link for Html / man
//printf("writeObjectLink(file=%s)\n",e->file.data());
- ol.writeObjectLink(0,e->file,e->anchor,e->name);
+ ol.writeObjectLink(0,e.file,e.anchor,e.name);
ol.popGeneratorState();
ol.pushGeneratorState();
@@ -1104,7 +1104,7 @@ void writeExample(OutputList &ol,ExampleSDict *ed)
ol.disable(OutputGenerator::Html);
// link for Latex / pdf with anchor because the sources
// are not hyperlinked (not possible with a verbatim environment).
- ol.writeObjectLink(0,e->file,0,e->name);
+ ol.writeObjectLink(0,e.file,0,e.name);
//if (manEnabled) ol.enable(OutputGenerator::Man);
//if (htmlEnabled) ol.enable(OutputGenerator::Html);
ol.popGeneratorState();
diff --git a/src/util.h b/src/util.h
index 4a8464e..b327254 100644
--- a/src/util.h
+++ b/src/util.h
@@ -206,7 +206,7 @@ QCString tempArgListToString(const ArgumentList &al,SrcLangExt lang,bool include
QCString generateMarker(int id);
-void writeExample(OutputList &ol,ExampleSDict *el);
+void writeExamples(OutputList &ol,const ExampleList &el);
QCString stripAnonymousNamespaceScope(const QCString &s);