diff options
Diffstat (limited to 'src/memberdef.cpp')
-rw-r--r-- | src/memberdef.cpp | 1282 |
1 files changed, 608 insertions, 674 deletions
diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 8f09347..af05535 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -13,10 +13,10 @@ * */ + #include <stdio.h> -#include <qglobal.h> -#include <qregexp.h> #include <assert.h> + #include "md5.h" #include "memberdef.h" #include "membername.h" @@ -36,7 +36,6 @@ #include "dotcallgraph.h" #include "searchindex.h" #include "parserintf.h" - #include "vhdldocgen.h" #include "arguments.h" #include "memberlist.h" @@ -44,17 +43,18 @@ #include "filedef.h" #include "config.h" #include "definitionimpl.h" +#include "regex.h" //----------------------------------------------------------------------------- class MemberDefImpl : public DefinitionMixin<MemberDefMutable> { public: - MemberDefImpl(const char *defFileName,int defLine,int defColumn, - const char *type,const char *name,const char *args, - const char *excp,Protection prot,Specifier virt,bool stat, + MemberDefImpl(const QCString &defFileName,int defLine,int defColumn, + const QCString &type,const QCString &name,const QCString &args, + const QCString &excp,Protection prot,Specifier virt,bool stat, Relationship related,MemberType t,const ArgumentList &tal, - const ArgumentList &al,const char *metaData); + const ArgumentList &al,const QCString &metaData); virtual ~MemberDefImpl(); virtual DefType definitionType() const { return TypeMember; } @@ -65,13 +65,13 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual QCString getOutputFileBase() const; virtual QCString getReference() const; virtual QCString anchor() const; - virtual const char *declaration() const; - virtual const char *definition() const; - virtual const char *typeString() const; - virtual const char *argsString() const; - virtual const char *excpString() const; - virtual const char *bitfieldString() const; - virtual const char *extraTypeChars() const; + virtual QCString declaration() const; + virtual QCString definition() const; + virtual QCString typeString() const; + virtual QCString argsString() const; + virtual QCString excpString() const; + virtual QCString bitfieldString() const; + virtual QCString extraTypeChars() const; virtual const QCString &initializer() const; virtual int initializerLines() const; virtual uint64 getMemberSpecifiers() const; @@ -82,10 +82,10 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual const NamespaceDef* getNamespaceDef() const; virtual const GroupDef *getGroupDef() const; virtual ClassDef *accessorClass() const; - virtual const char *getReadAccessor() const; - virtual const char *getWriteAccessor() const; + virtual QCString getReadAccessor() const; + virtual QCString getWriteAccessor() const; virtual Grouping::GroupPri_t getGroupPri() const; - virtual const char *getGroupFileName() const; + virtual QCString getGroupFileName() const; virtual int getGroupStartLine() const; virtual bool getGroupHasDocs() const; virtual QCString qualifiedName() const; @@ -93,7 +93,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual Protection protection() const; virtual Specifier virtualness(int count=0) const; virtual MemberType memberType() const; - virtual QCString memberTypeName() const; + virtual QCString memberTypeName() const; virtual bool isSignal() const; virtual bool isSlot() const; virtual bool isVariable() const; @@ -138,6 +138,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual bool isRetain() const; virtual bool isWeak() const; virtual bool isStrong() const; + virtual bool isEnumStruct() const; virtual bool isUnretained() const; virtual bool isNew() const; virtual bool isSealed() const; @@ -183,15 +184,15 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual bool isDetailedSectionLinkable() const; virtual bool isFriendClass() const; virtual bool isDocumentedFriendClass() const; - virtual MemberDef *reimplements() const; - virtual MemberList *reimplementedBy() const; + virtual const MemberDef *reimplements() const; + virtual const MemberList &reimplementedBy() const; virtual bool isReimplementedBy(const ClassDef *cd) const; virtual ClassDef *relatedAlso() const; virtual bool hasDocumentedEnumValues() const; virtual const MemberDef *getAnonymousEnumType() const; virtual bool isDocsForDefinition() const; virtual const MemberDef *getEnumScope() const; - virtual const MemberList *enumFieldList() const; + virtual const MemberList &enumFieldList() const; virtual void setEnumBaseType(const QCString &type); virtual QCString enumBaseType() const; virtual bool hasExamples() const; @@ -212,7 +213,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual bool visibleMemberGroup(bool hideNoHeader) const; virtual bool hasReferencesRelation() const; virtual bool hasReferencedByRelation() const; - virtual MemberDef *templateMaster() const; + virtual const MemberDef *templateMaster() const; virtual QCString getScopeString() const; virtual ClassDef *getClassDefOfAnonymousType() const; virtual bool isTypedefValCached() const; @@ -221,14 +222,15 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual QCString getCachedResolvedTypedef() const; virtual MemberDef *memberDefinition() const; virtual MemberDef *memberDeclaration() const; - virtual MemberDef *inheritsDocsFrom() const; + virtual const MemberDef *inheritsDocsFrom() const; virtual const MemberDef *getGroupAlias() const; virtual ClassDef *category() const; - virtual MemberDef *categoryRelation() const; + virtual const MemberDef *categoryRelation() const; virtual QCString displayName(bool=TRUE) const; virtual QCString getDeclType() const; - virtual void getLabels(QStrList &sl,const Definition *container) const; + virtual StringVector getLabels(const Definition *container) const; virtual const ArgumentList &typeConstraints() const; + virtual QCString requiresClause() const; virtual QCString documentation() const; virtual QCString briefDescription(bool abbr=FALSE) const; virtual QCString fieldType() const; @@ -237,37 +239,37 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual int getDeclLine() const; virtual int getDeclColumn() const; virtual void setMemberType(MemberType t); - virtual void setDefinition(const char *d); + virtual void setDefinition(const QCString &d); virtual void setFileDef(const FileDef *fd); virtual void setAnchor(); virtual void setProtection(Protection p); virtual void setMemberSpecifiers(uint64 s); virtual void mergeMemberSpecifiers(uint64 s); - virtual void setInitializer(const char *i); - virtual void setBitfields(const char *s); + virtual void setInitializer(const QCString &i); + virtual void setBitfields(const QCString &s); virtual void setMaxInitLines(int lines); virtual void setMemberClass(const ClassDef *cd); virtual void setSectionList(const Definition *container,const MemberList *sl); virtual void setGroupDef(const GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine,bool hasDocs, MemberDef *member=0); - virtual void setReadAccessor(const char *r); - virtual void setWriteAccessor(const char *w); + virtual void setReadAccessor(const QCString &r); + virtual void setWriteAccessor(const QCString &w); virtual void setTemplateSpecialization(bool b); virtual void makeRelated(); virtual void makeForeign(); - virtual void setInheritsDocsFrom(MemberDef *md); + virtual void setInheritsDocsFrom(const MemberDef *md); virtual void setTagInfo(const TagInfo *i); - virtual void setArgsString(const char *as); - virtual void setReimplements(MemberDef *md); - virtual void insertReimplementedBy(MemberDef *md); + virtual void setArgsString(const QCString &as); + virtual void setReimplements(const MemberDef *md); + virtual void insertReimplementedBy(const MemberDef *md); virtual void setRelatedAlso(ClassDef *cd); - virtual void insertEnumField(MemberDef *md); - virtual void setEnumScope(MemberDef *md,bool livesInsideEnum=FALSE); - virtual void setEnumClassScope(ClassDef *cd); + virtual void insertEnumField(const MemberDef *md); + virtual void setEnumScope(const MemberDef *md,bool livesInsideEnum=FALSE); + virtual void setEnumClassScope(const ClassDef *cd); virtual void setDocumentedEnumValues(bool value); virtual void setAnonymousEnumType(const MemberDef *md); - virtual bool addExample(const char *anchor,const char *name,const char *file); + virtual bool addExample(const QCString &anchor,const QCString &name,const QCString &file); virtual void setPrototype(bool p,const QCString &df,int line, int column); virtual void setExplicitExternal(bool b,const QCString &df,int line,int column); virtual void setDeclFile(const QCString &df,int line,int column); @@ -275,8 +277,8 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual void moveDeclArgumentList(std::unique_ptr<ArgumentList> al); virtual void setDefinitionTemplateParameterLists(const ArgumentLists &lists); virtual void setTypeConstraints(const ArgumentList &al); - virtual void setType(const char *t); - virtual void setAccessorType(ClassDef *cd,const char *t); + virtual void setType(const QCString &t); + virtual void setAccessorType(ClassDef *cd,const QCString &t); virtual void setNamespace(const NamespaceDef *nd); virtual void setMemberGroup(MemberGroup *grp); virtual void setMemberGroupId(int id); @@ -287,7 +289,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual void enableCallerGraph(bool e); virtual void enableReferencedByRelation(bool e); virtual void enableReferencesRelation(bool e); - virtual void setTemplateMaster(MemberDef *mt); + virtual void setTemplateMaster(const MemberDef *mt); virtual void addListReference(Definition *d); virtual void setDocsForDefinition(bool b); virtual void setGroupAlias(const MemberDef *md); @@ -297,25 +299,26 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual void setMemberDefinition(MemberDef *md); virtual void setMemberDeclaration(MemberDef *md); virtual void setAnonymousUsed() const; - virtual void copyArgumentNames(MemberDef *bmd); + virtual void copyArgumentNames(const MemberDef *bmd); virtual void setCategory(ClassDef *); - virtual void setCategoryRelation(MemberDef *); - virtual void setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace=TRUE); - virtual void setBriefDescription(const char *b,const char *briefFile,int briefLine); - virtual void setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine); + virtual void setCategoryRelation(const MemberDef *); + virtual void setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace=TRUE); + virtual void setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine); + virtual void setInbodyDocumentation(const QCString &d,const QCString &inbodyFile,int inbodyLine); virtual void setHidden(bool b); + virtual void setRequiresClause(const QCString &req); virtual void incrementFlowKeyWordCount(); virtual void writeDeclaration(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, - bool inGroup, const ClassDef *inheritFrom=0,const char *inheritId=0) const; + bool inGroup, const ClassDef *inheritFrom=0,const QCString &inheritId=QCString()) const; virtual void writeDocumentation(const MemberList *ml,int memCount,int memTotal,OutputList &ol, - const char *scopeName,const Definition *container, + const QCString &scopeName,const Definition *container, bool inGroup,bool showEnumValues=FALSE,bool showInline=FALSE) const; virtual void writeMemberDocSimple(OutputList &ol,const Definition *container) const; virtual void writeEnumDeclaration(OutputList &typeDecl, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd) const; - virtual void writeTagFile(FTextStream &) const; + virtual void writeTagFile(TextStream &) const; virtual void warnIfUndocumented() const; virtual void warnIfUndocumentedParams() const; virtual void detectUndocumentedParams(bool hasParamCommand,bool hasReturnCommand) const; @@ -344,6 +347,8 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> const QCString &cname) const; void _writeCategoryRelation(OutputList &ol) const; void _writeTagData(const DefType) const; + void _writeTemplatePrefix(OutputList &ol, const Definition *def, + const ArgumentList &al, bool writeReqClause=true) const; static int s_indentLevel; @@ -360,11 +365,11 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> uchar m_isDestructorCached; // 1 = not cached, 1=FALSE, 2=TRUE }; -MemberDefMutable *createMemberDef(const char *defFileName,int defLine,int defColumn, - const char *type,const char *name,const char *args, - const char *excp,Protection prot,Specifier virt,bool stat, +MemberDefMutable *createMemberDef(const QCString &defFileName,int defLine,int defColumn, + const QCString &type,const QCString &name,const QCString &args, + const QCString &excp,Protection prot,Specifier virt,bool stat, Relationship related,MemberType t,const ArgumentList &tal, - const ArgumentList &al,const char *metaData) + const ArgumentList &al,const QCString &metaData) { return new MemberDefImpl(defFileName,defLine,defColumn,type,name,args,excp,prot,virt, stat,related,t,tal,al,metaData); @@ -397,19 +402,19 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->getReference(); } virtual QCString anchor() const { return getMdAlias()->anchor(); } - virtual const char *declaration() const + virtual QCString declaration() const { return getMdAlias()->declaration(); } - virtual const char *definition() const + virtual QCString definition() const { return getMdAlias()->definition(); } - virtual const char *typeString() const + virtual QCString typeString() const { return getMdAlias()->typeString(); } - virtual const char *argsString() const + virtual QCString argsString() const { return getMdAlias()->argsString(); } - virtual const char *excpString() const + virtual QCString excpString() const { return getMdAlias()->excpString(); } - virtual const char *bitfieldString() const + virtual QCString bitfieldString() const { return getMdAlias()->bitfieldString(); } - virtual const char *extraTypeChars() const + virtual QCString extraTypeChars() const { return getMdAlias()->extraTypeChars(); } virtual const QCString &initializer() const { return getMdAlias()->initializer(); } @@ -429,15 +434,15 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->getNamespaceDef(); } virtual const ClassDef *accessorClass() const { return getMdAlias()->accessorClass(); } - virtual const char *getReadAccessor() const + virtual QCString getReadAccessor() const { return getMdAlias()->getReadAccessor(); } - virtual const char *getWriteAccessor() const + virtual QCString getWriteAccessor() const { return getMdAlias()->getWriteAccessor(); } virtual const GroupDef *getGroupDef() const { return getMdAlias()->getGroupDef(); } virtual Grouping::GroupPri_t getGroupPri() const { return getMdAlias()->getGroupPri(); } - virtual const char *getGroupFileName() const + virtual QCString getGroupFileName() const { return getMdAlias()->getGroupFileName(); } virtual int getGroupStartLine() const { return getMdAlias()->getGroupStartLine(); } @@ -543,6 +548,8 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->isWeak(); } virtual bool isStrong() const { return getMdAlias()->isStrong(); } + virtual bool isEnumStruct() const + { return getMdAlias()->isEnumStruct(); } virtual bool isUnretained() const { return getMdAlias()->isUnretained(); } virtual bool isNew() const @@ -633,9 +640,9 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->isFriendClass(); } virtual bool isDocumentedFriendClass() const { return getMdAlias()->isDocumentedFriendClass(); } - virtual MemberDef *reimplements() const + virtual const MemberDef *reimplements() const { return getMdAlias()->reimplements(); } - virtual MemberList *reimplementedBy() const + virtual const MemberList &reimplementedBy() const { return getMdAlias()->reimplementedBy(); } virtual bool isReimplementedBy(const ClassDef *cd) const { return getMdAlias()->isReimplementedBy(cd); } @@ -649,7 +656,7 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->isDocsForDefinition(); } virtual const MemberDef *getEnumScope() const { return getMdAlias()->getEnumScope(); } - virtual const MemberList *enumFieldList() const + virtual const MemberList &enumFieldList() const { return getMdAlias()->enumFieldList(); } virtual QCString enumBaseType() const { return getMdAlias()->enumBaseType(); } @@ -687,7 +694,7 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->hasReferencesRelation(); } virtual bool hasReferencedByRelation() const { return getMdAlias()->hasReferencedByRelation(); } - virtual MemberDef *templateMaster() const + virtual const MemberDef *templateMaster() const { return getMdAlias()->templateMaster(); } virtual QCString getScopeString() const { return getMdAlias()->getScopeString(); } @@ -705,20 +712,20 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->memberDefinition(); } virtual MemberDef *memberDeclaration() const { return getMdAlias()->memberDeclaration(); } - virtual MemberDef *inheritsDocsFrom() const + virtual const MemberDef *inheritsDocsFrom() const { return getMdAlias()->inheritsDocsFrom(); } virtual const MemberDef *getGroupAlias() const { return getMdAlias()->getGroupAlias(); } virtual ClassDef *category() const { return getMdAlias()->category(); } - virtual MemberDef *categoryRelation() const + virtual const MemberDef *categoryRelation() const { return getMdAlias()->categoryRelation(); } virtual QCString displayName(bool b=TRUE) const { return getMdAlias()->displayName(b); } virtual QCString getDeclType() const { return getMdAlias()->getDeclType(); } - virtual void getLabels(QStrList &sl,const Definition *container) const - { return getMdAlias()->getLabels(sl,container); } + virtual StringVector getLabels(const Definition *container) const + { return getMdAlias()->getLabels(container); } virtual const ArgumentList &typeConstraints() const { return getMdAlias()->typeConstraints(); } virtual QCString documentation() const @@ -735,6 +742,8 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> { return getMdAlias()->getDeclLine(); } virtual int getDeclColumn() const { return getMdAlias()->getDeclColumn(); } + virtual QCString requiresClause() const + { return getMdAlias()->requiresClause(); } virtual void warnIfUndocumented() const {} virtual void warnIfUndocumentedParams() const {} @@ -746,7 +755,7 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> virtual void writeDeclaration(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, - bool inGroup, const ClassDef *inheritFrom=0,const char *inheritId=0) const + bool inGroup, const ClassDef *inheritFrom=0,const QCString &inheritId=QCString()) const { getMdAlias()->writeDeclaration(ol,cd,nd,fd,gd,inGroup,inheritFrom,inheritId); } @@ -763,7 +772,7 @@ class MemberDefAliasImpl : public DefinitionAliasMixin<MemberDef> MemberDef *createMemberDefAlias(const Definition *newScope,const MemberDef *aliasMd) { MemberDef *amd = new MemberDefAliasImpl(newScope,aliasMd); - //printf("amd: name=%s displayName=%s\n",amd->name().data(),amd->displayName().data()); + //printf("amd: name=%s displayName=%s\n",qPrint(amd->name()),qPrint(amd->displayName())); return amd; } @@ -792,18 +801,18 @@ static QCString addTemplateNames(const QCString &s,const QCString &n,const QCStr uint j=clRealName.length()+i; if (s.length()==j || (s.at(j)!='<' && !isId(s.at(j)))) { // add template names - //printf("Adding %s+%s\n",clRealName.data(),t.data()); + //printf("Adding %s+%s\n",qPrint(clRealName),qPrint(t)); result+=clRealName+t; } else { // template names already present - //printf("Adding %s\n",clRealName.data()); + //printf("Adding %s\n",qPrint(clRealName)); result+=clRealName; } p=i+clRealName.length(); } result+=s.right(s.length()-p); - //printf("addTemplateNames(%s,%s,%s)=%s\n",s.data(),n.data(),t.data(),result.data()); + //printf("addTemplateNames(%s,%s,%s)=%s\n",qPrint(s),qPrint(n),qPrint(t),qPrint(result)); return result; } @@ -844,7 +853,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me { const ArgumentList &defArgList=(md->isDocsForDefinition()) ? md->argumentList() : md->declArgumentList(); - //printf("writeDefArgumentList '%s' isDocsForDefinition()=%d\n",md->name().data(),md->isDocsForDefinition()); + //printf("writeDefArgumentList '%s' isDocsForDefinition()=%d\n",qPrint(md->name()),md->isDocsForDefinition()); if (!defArgList.hasParameters() || md->isProperty() || md->isTypedef()) { return FALSE; // member has no function like argument list @@ -877,7 +886,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me ol.endMemberDocName(); } ol.popGeneratorState(); - //printf("===> name=%s isDefine=%d\n",md->name().data(),md->isDefine()); + //printf("===> name=%s isDefine=%d\n",qPrint(md->name()),md->isDefine()); QCString cName; if (scope) @@ -888,20 +897,20 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me if (il!=-1 && ir!=-1 && ir>il) { cName=cName.mid(il,ir-il+1); - //printf("1. cName=%s\n",cName.data()); + //printf("1. cName=%s\n",qPrint(cName)); } else if (scope->definitionType()==Definition::TypeClass) { cName=tempArgListToString((toClassDef(scope))->templateArguments(), scope->getLanguage()); - //printf("2. cName=%s\n",cName.data()); + //printf("2. cName=%s\n",qPrint(cName)); } else // no template specifier { cName.resize(0); } } - //printf("~~~ %s cName=%s\n",md->name().data(),cName.data()); + //printf("~~~ %s cName=%s\n",qPrint(md->name()),qPrint(cName)); bool first=TRUE; bool paramTypeStarted=FALSE; @@ -912,7 +921,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me Argument a = *alIt; if (isDefine || first) { - ol.startParameterType(first,0); + ol.startParameterType(first,QCString()); paramTypeStarted=TRUE; if (isDefine) { @@ -920,27 +929,12 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me ol.startParameterName(TRUE); } } - QRegExp re(")("),res("(.*\\*"); - int vp=a.type.find(re); - int wp=a.type.find(res); - - // use the following to put the function pointer type before the name - bool hasFuncPtrType=FALSE; if (!a.attrib.isEmpty() && !md->isObjCMethod()) // argument has an IDL attribute { ol.docify(a.attrib+" "); } - if (hasFuncPtrType) // argument type is a function pointer - { - //printf("a.type='%s' a.name='%s'\n",a.type.data(),a.name.data()); - QCString n=a.type.left(vp); - if (hasFuncPtrType) n=a.type.left(wp); - if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } - if (!cName.isEmpty()) n=addTemplateNames(n,scope->name(),cName); - linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n); - } - else // non-function pointer type + { QCString n=a.type; if (md->isObjCMethod()) { n.prepend("("); n.append(")"); } @@ -950,6 +944,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(),md,n); } } + if (!isDefine) { if (paramTypeStarted) @@ -959,16 +954,8 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me } ol.startParameterName(defArgList.size()<2); } - if (hasFuncPtrType) - { - ol.docify(a.type.mid(wp,vp-wp)); - } if (!a.name.isEmpty() || a.type=="...") // argument has a name { - //if (!hasFuncPtrType) - //{ - // ol.docify(" "); - //} ol.disable(OutputGenerator::Latex); ol.disable(OutputGenerator::Docbook); ol.disable(OutputGenerator::Html); @@ -992,12 +979,6 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me { ol.docify(a.array); } - if (hasFuncPtrType) // write the part of the argument type - // that comes after the name - { - linkifyText(TextGeneratorOLImpl(ol),scope,md->getBodyDef(), - md,a.type.right(a.type.length()-vp)); - } if (!a.defval.isEmpty()) // write the default value { QCString n=a.defval; @@ -1019,7 +1000,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me QCString key; if (md->isObjCMethod() && a.attrib.length()>=2) { - //printf("Found parameter keyword %s\n",a.attrib.data()); + //printf("Found parameter keyword %s\n",a.qPrint(attrib)); // strip [ and ] key=a.attrib.mid(1,a.attrib.length()-2); if (key!=",") key+=":"; // for normal keywords add colon @@ -1051,7 +1032,7 @@ static bool writeDefArgumentList(OutputList &ol,const Definition *scope,const Me if (first) ol.startParameterName(defArgList.size()<2); ol.endParameterName(TRUE,defArgList.size()<2,!md->isObjCMethod()); ol.popGeneratorState(); - if (md->extraTypeChars()) + if (!md->extraTypeChars().isEmpty()) { ol.docify(md->extraTypeChars()); } @@ -1089,7 +1070,7 @@ static void writeExceptionListImpl( OutputList &ol, const ClassDef *cd, const MemberDef *md, QCString const& exception) { // this is ordinary exception spec - there must be a '(' - //printf("exception='%s'\n",exception.data()); + //printf("exception='%s'\n",qPrint(exception)); int index = exception.find('('); if (index!=-1) { @@ -1100,7 +1081,7 @@ static void writeExceptionListImpl( ++comma; // include comma linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md, exception.mid(index,comma-index)); - ol.exceptionEntry(0,false); + ol.exceptionEntry(QCString(),false); index=comma; comma = exception.find(',', index); } @@ -1109,7 +1090,7 @@ static void writeExceptionListImpl( { QCString type=removeRedundantWhiteSpace(exception.mid(index,close-index)); linkifyText(TextGeneratorOLImpl(ol),cd,md->getBodyDef(),md,type); - ol.exceptionEntry(0,true); + ol.exceptionEntry(QCString(),true); } else { @@ -1147,26 +1128,6 @@ static void writeExceptionList(OutputList &ol, const ClassDef *cd, const MemberD } } -static void writeTemplatePrefix(OutputList &ol,const ArgumentList &al) -{ - ol.docify("template<"); - for (auto it = al.begin(); it!=al.end();) - { - Argument a = *it; - ol.docify(a.type); - ol.docify(" "); - ol.docify(a.name); - if (a.defval.length()!=0) - { - ol.docify(" = "); - ol.docify(a.defval); - } - ++it; - if (it!=al.end()) ol.docify(", "); - } - ol.docify("> "); -} - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -1176,23 +1137,23 @@ class MemberDefImpl::IMPL public: IMPL(); ~IMPL(); - void init(Definition *def,const char *t,const char *a,const char *e, + void init(Definition *def,const QCString &t,const QCString &a,const QCString &e, Protection p,Specifier v,bool s,Relationship r, MemberType mt,const ArgumentList &tal, - const ArgumentList &al,const char *meta + const ArgumentList &al,const QCString &meta ); const ClassDef *classDef = 0; // member of or related to const FileDef *fileDef = 0; // member of file definition const NamespaceDef *nspace = 0; // the namespace this member is in. - MemberDef *enumScope = 0; // the enclosing scope, if this is an enum field + const MemberDef *enumScope = 0; // the enclosing scope, if this is an enum field bool livesInsideEnum = false; const MemberDef *annEnumType = 0; // the anonymous enum that is the type of this member - MemberList *enumFields = 0; // enumeration fields + MemberList enumFields; // enumeration fields - MemberDef *redefines = 0; // the members that this member redefines - MemberList *redefinedBy = 0; // the list of members that redefine this one + const MemberDef *redefines = 0; // the members that this member redefines + MemberList redefinedBy; // the list of members that redefine this one MemberDef *memDef = 0; // member definition for this declaration MemberDef *memDec = 0; // member declaration for this definition @@ -1217,6 +1178,7 @@ class MemberDefImpl::IMPL QCString initializer; // initializer QCString extraTypeChars; // extra type info found after the argument list QCString enumBaseType; // base type of the enum (C++11) + QCString requiresClause; // requires clause (C++20) int initLines = 0; // number of lines in the initializer uint64 memSpec = 0; // The specifiers present for this member @@ -1230,7 +1192,7 @@ class MemberDefImpl::IMPL ArgumentList tArgList; // template argument list of function template ArgumentList typeConstraints; // type constraints for template parameters - MemberDef *templateMaster; + const MemberDef *templateMaster; ArgumentLists defTmpArgLists; // lists of template argument lists // (for template functions in nested template classes) @@ -1262,7 +1224,7 @@ class MemberDefImpl::IMPL //QCString inbodyDocs; // documentation inheritance - MemberDef *docProvider = 0; + const MemberDef *docProvider = 0; // to store the output file base from tag files QCString explicitOutputFileBase; @@ -1292,49 +1254,38 @@ class MemberDefImpl::IMPL // definition. // FALSE => block is put before declaration. ClassDef *category = 0; - MemberDef *categoryRelation = 0; + const MemberDef *categoryRelation = 0; QCString declFileName; - int declLine = 0; - int declColumn = 0; + int declLine = -1; + int declColumn = -1; int numberOfFlowKW = 0; }; -MemberDefImpl::IMPL::IMPL() : - enumFields(0), - redefinedBy(0), - category(0), - categoryRelation(0), - declLine(-1), - declColumn(-1), - numberOfFlowKW(0) +MemberDefImpl::IMPL::IMPL() : enumFields(MemberListType_enumFields) { } MemberDefImpl::IMPL::~IMPL() { - delete redefinedBy; - delete enumFields; } void MemberDefImpl::IMPL::init(Definition *d, - const char *t,const char *a,const char *e, + const QCString &t,const QCString &a,const QCString &e, Protection p,Specifier v,bool s,Relationship r, MemberType mt,const ArgumentList &tal, - const ArgumentList &al,const char *meta + const ArgumentList &al,const QCString &meta ) { classDef=0; fileDef=0; redefines=0; relatedAlso=0; - redefinedBy=0; accessorClass=0; nspace=0; memDef=0; memDec=0; group=0; grpId=-1; - enumFields=0; enumScope=0; livesInsideEnum=FALSE; hasCallGraph = FALSE; @@ -1381,8 +1332,8 @@ void MemberDefImpl::IMPL::init(Definition *d, if (!args.isEmpty()) { declArgList = *stringToArgumentList(d->getLanguage(),args,&extraTypeChars); - //printf("setDeclArgList %s to %s const=%d\n",args.data(), - // argListToString(declArgList).data(),declArgList->constSpecifier); + //printf("setDeclArgList %s to %s const=%d\n",qPrint(args), + // qPrint(argListToString(declArgList)),declArgList->constSpecifier); } metaData = meta; templateMaster = 0; @@ -1426,10 +1377,10 @@ void MemberDefImpl::IMPL::init(Definition *d, * \param meta Slice metadata. */ -MemberDefImpl::MemberDefImpl(const char *df,int dl,int dc, - const char *t,const char *na,const char *a,const char *e, +MemberDefImpl::MemberDefImpl(const QCString &df,int dl,int dc, + const QCString &t,const QCString &na,const QCString &a,const QCString &e, Protection p,Specifier v,bool s,Relationship r,MemberType mt, - const ArgumentList &tal,const ArgumentList &al,const char *meta + const ArgumentList &tal,const ArgumentList &al,const QCString &meta ) : DefinitionMixin(df,dl,dc,removeRedundantWhiteSpace(na)) { //printf("MemberDefImpl::MemberDef(%s)\n",na); @@ -1454,28 +1405,6 @@ MemberDef *MemberDefImpl::deepCopy() const MemberDefImpl *result = new MemberDefImpl(*this); // first copy everything by reference *result->m_impl = *m_impl; - // clear pointers owned by object - result->m_impl->redefinedBy= 0; - result->m_impl->enumFields=0; - // replace pointers owned by the object by deep copies - if (m_impl->redefinedBy) - { - MemberListIterator mli(*m_impl->redefinedBy); - MemberDef *md; - for (mli.toFirst();(md=mli.current());++mli) - { - result->insertReimplementedBy(md); - } - } - if (m_impl->enumFields) - { - MemberListIterator mli(*m_impl->enumFields); - MemberDef *md; - for (mli.toFirst();(md=mli.current());++mli) - { - result->insertEnumField(md); - } - } result->m_impl->defArgList = m_impl->defArgList; result->m_impl->tArgList = m_impl->tArgList; result->m_impl->typeConstraints = m_impl->typeConstraints; @@ -1512,12 +1441,12 @@ MemberDefImpl::~MemberDefImpl() m_impl=0; } -void MemberDefImpl::setReimplements(MemberDef *md) +void MemberDefImpl::setReimplements(const MemberDef *md) { m_impl->redefines = md; } -void MemberDefImpl::insertReimplementedBy(MemberDef *md) +void MemberDefImpl::insertReimplementedBy(const MemberDef *md) { if (m_impl->templateMaster) { @@ -1527,30 +1456,27 @@ void MemberDefImpl::insertReimplementedBy(MemberDef *md) mdm->insertReimplementedBy(md); } } - if (m_impl->redefinedBy==0) m_impl->redefinedBy = new MemberList(MemberListType_redefinedBy); - if (m_impl->redefinedBy->findRef(md)==-1) + if (!m_impl->redefinedBy.contains(md)) { - m_impl->redefinedBy->inSort(md); + m_impl->redefinedBy.inSort(md); } } -MemberDef *MemberDefImpl::reimplements() const +const MemberDef *MemberDefImpl::reimplements() const { return m_impl->redefines; } -MemberList *MemberDefImpl::reimplementedBy() const +const MemberList &MemberDefImpl::reimplementedBy() const { return m_impl->redefinedBy; } bool MemberDefImpl::isReimplementedBy(const ClassDef *cd) const { - if (cd && m_impl->redefinedBy) + if (cd) { - MemberListIterator mi(*m_impl->redefinedBy); - MemberDef *md; - for (mi.toFirst();(md=mi.current());++mi) + for (const auto &md : m_impl->redefinedBy) { const ClassDef *mcd = md->getClassDef(); if (mcd) @@ -1565,15 +1491,14 @@ bool MemberDefImpl::isReimplementedBy(const ClassDef *cd) const return FALSE; } -void MemberDefImpl::insertEnumField(MemberDef *md) +void MemberDefImpl::insertEnumField(const MemberDef *md) { - if (m_impl->enumFields==0) m_impl->enumFields=new MemberList(MemberListType_enumFields); - m_impl->enumFields->append(md); + m_impl->enumFields.push_back(md); } -bool MemberDefImpl::addExample(const char *anchor,const char *nameStr, const char *file) +bool MemberDefImpl::addExample(const QCString &anchor,const QCString &nameStr, const QCString &file) { - //printf("%s::addExample(%s,%s,%s)\n",name().data(),anchor,nameStr,file); + //printf("%s::addExample(%s,%s,%s)\n",qPrint(name()),anchor,nameStr,file); return m_impl->examples.inSort(Example(anchor,nameStr,file)); } @@ -1589,7 +1514,7 @@ QCString MemberDefImpl::getOutputFileBase() const QCString baseName; //printf("Member: %s: templateMaster=%p group=%p classDef=%p nspace=%p fileDef=%p\n", - // name().data(),m_impl->templateMaster,m_impl->group,m_impl->classDef, + // qPrint(name()),m_impl->templateMaster,m_impl->group,m_impl->classDef, // m_impl->nspace,m_impl->fileDef); const NamespaceDef *nspace = getNamespaceDef(); const FileDef *fileDef = getFileDef(); @@ -1708,7 +1633,7 @@ void MemberDefImpl::_computeLinkableInProject() static bool extractStatic = Config_getBool(EXTRACT_STATIC); static bool extractPrivateVirtual = Config_getBool(EXTRACT_PRIV_VIRTUAL); m_isLinkableCached = 2; // linkable - //printf("MemberDefImpl::isLinkableInProject(name=%s)\n",name().data()); + //printf("MemberDefImpl::isLinkableInProject(name=%s)\n",qPrint(name())); if (isHidden()) { //printf("is hidden\n"); @@ -1781,19 +1706,19 @@ void MemberDefImpl::_computeLinkableInProject() return; // linkable! } -void MemberDefImpl::setDocumentation(const char *d,const char *docFile,int docLine,bool stripWhiteSpace) +void MemberDefImpl::setDocumentation(const QCString &d,const QCString &docFile,int docLine,bool stripWhiteSpace) { DefinitionMixin::setDocumentation(d,docFile,docLine,stripWhiteSpace); m_isLinkableCached = 0; } -void MemberDefImpl::setBriefDescription(const char *b,const char *briefFile,int briefLine) +void MemberDefImpl::setBriefDescription(const QCString &b,const QCString &briefFile,int briefLine) { DefinitionMixin::setBriefDescription(b,briefFile,briefLine); m_isLinkableCached = 0; } -void MemberDefImpl::setInbodyDocumentation(const char *d,const char *inbodyFile,int inbodyLine) +void MemberDefImpl::setInbodyDocumentation(const QCString &d,const QCString &inbodyFile,int inbodyLine) { DefinitionMixin::setInbodyDocumentation(d,inbodyFile,inbodyLine); m_isLinkableCached = 0; @@ -1892,6 +1817,8 @@ void MemberDefImpl::writeLink(OutputList &ol, */ ClassDef *MemberDefImpl::getClassDefOfAnonymousType() const { + //printf("%s:getClassDefOfAnonymousType() cache=%s\n",qPrint(name()), + // m_impl->cachedAnonymousType?qPrint(m_impl->cachedAnonymousType->name()):"<empty>"); if (m_impl->cachedAnonymousType) return m_impl->cachedAnonymousType; QCString cname; @@ -1908,20 +1835,18 @@ ClassDef *MemberDefImpl::getClassDefOfAnonymousType() const //if (ltype.left(7)=="static ") ltype=ltype.right(ltype.length()-7); // strip 'friend' keyword from ltype ltype.stripPrefix("friend "); - static QRegExp r("@[0-9]+"); - int l,i=r.match(ltype,0,&l); - //printf("ltype='%s' i=%d\n",ltype.data(),i); + // search for the last anonymous scope in the member type ClassDef *annoClassDef=0; - if (i!=-1) // found anonymous scope in type - { - int il=i-1,ir=i+l; - // extract anonymous scope - while (il>=0 && (isId(ltype.at(il)) || ltype.at(il)==':' || ltype.at(il)=='@')) il--; - if (il>0) il++; else if (il<0) il=0; - while (ir<(int)ltype.length() && (isId(ltype.at(ir)) || ltype.at(ir)==':' || ltype.at(ir)=='@')) ir++; - QCString annName = ltype.mid(il,ir-il); + // match expression if it contains at least one @1 marker, e.g. + // 'struct A::@1::@2::B' matches 'A::@1::@2::B' but 'struct A::B' does not match. + std::string stype = ltype.str(); + static const reg::Ex r(R"([\w@:]*@\d+[\w@:]*)"); + reg::Match match; + if (reg::search(stype,match,r)) // found anonymous scope in type + { + QCString annName = match.str(); // if inside a class or namespace try to prepend the scope name if (!cname.isEmpty() && annName.left(cname.length()+2)!=cname+"::") @@ -1953,9 +1878,9 @@ bool MemberDefImpl::isBriefSectionVisible() const static bool hideFriendCompounds = Config_getBool(HIDE_FRIEND_COMPOUNDS); //printf("Member %s grpId=%d docs=%s file=%s args=%s\n", - // name().data(), + // qPrint(name()), // 0,"", //grpId,grpId==-1?"<none>":Doxygen::memberDocDict[grpId]->data(), - // "", //getFileDef()->name().data(), + // "", //qPrint(getFileDef()->name()), // argsString()); auto it = Doxygen::memberGroupInfoMap.find(m_impl->grpId); @@ -1963,7 +1888,7 @@ bool MemberDefImpl::isBriefSectionVisible() const if (it!=Doxygen::memberGroupInfoMap.end()) { auto &info = it->second; - //printf("name=%s m_impl->grpId=%d info=%p\n",name().data(),m_impl->grpId,info); + //printf("name=%s m_impl->grpId=%d info=%p\n",qPrint(name()),m_impl->grpId,info); //QCString *pMemGrp = Doxygen::memberDocDict[grpId]; hasDocs = hasDocs || // part of a documented member group @@ -2073,11 +1998,51 @@ QCString MemberDefImpl::getDeclType() const return ltype; } +void MemberDefImpl::_writeTemplatePrefix(OutputList &ol, const Definition *def, + const ArgumentList &al, bool writeReqClause) const +{ + ol.docify("template<"); + for (auto it = al.begin(); it!=al.end();) + { + Argument a = *it; + linkifyText(TextGeneratorOLImpl(ol), // out + def, // scope + getFileDef(), // fileScope + this, // self + a.type, // text + FALSE // autoBreak + ); + ol.docify(" "); + ol.docify(a.name); + if (a.defval.length()!=0) + { + ol.docify(" = "); + ol.docify(a.defval); + } + ++it; + if (it!=al.end()) ol.docify(", "); + } + ol.docify("> "); + if (writeReqClause && !m_impl->requiresClause.isEmpty()) + { + ol.lineBreak(); + ol.docify("requires "); + linkifyText(TextGeneratorOLImpl(ol), // out + def, // scope + getFileDef(), // fileScope + this, // self + m_impl->requiresClause, // text + FALSE // autoBreak + ); + } +} + + void MemberDefImpl::writeDeclaration(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, - bool inGroup, const ClassDef *inheritedFrom,const char *inheritId) const + bool inGroup, const ClassDef *inheritedFrom,const QCString &inheritId) const { - //printf("%s MemberDefImpl::writeDeclaration() inGroup=%d\n",qualifiedName().data(),inGroup); + //printf("%s MemberDefImpl::writeDeclaration() inGroup=%d\n",qPrint(qualifiedName()),inGroup); // hide enum value, since they appear already as part of the enum, unless they // are explicitly grouped. @@ -2107,7 +2072,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, // start a new member declaration bool isAnonType = annoClassDef || m_impl->annMemb || m_impl->annEnumType; - ///printf("startMemberItem for %s\n",name().data()); + ///printf("startMemberItem for %s\n",qPrint(name())); ol.startMemberItem(anchor(), isAnonType ? 1 : !m_impl->tArgList.empty() ? 3 : 0, inheritId @@ -2151,10 +2116,11 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, if (m_impl->tArgList.hasParameters() && getLanguage()==SrcLangExt_Cpp) { if (!isAnonType) ol.startMemberTemplateParams(); - writeTemplatePrefix(ol,m_impl->tArgList); + _writeTemplatePrefix(ol,d,m_impl->tArgList); if (!isAnonType) ol.endMemberTemplateParams(anchor(),inheritId); } + // *** write type QCString ltype(m_impl->type); if (isTypedef() && getLanguage() != SrcLangExt_Slice) @@ -2167,14 +2133,16 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } // strip 'friend' keyword from ltype ltype.stripPrefix("friend "); - static QRegExp r("@[0-9]+"); - + static const reg::Ex r(R"(@\d+)"); + reg::Match match; + std::string stype = ltype.str(); bool endAnonScopeNeeded=FALSE; - int l,i=r.match(ltype,0,&l); - if (i!=-1) // member has an anonymous type + if (reg::search(stype,match,r)) // member has an anonymous type { + int i = (int)match.position(); + int l = (int)match.length(); //printf("annoClassDef=%p annMemb=%p scopeName='%s' anonymous='%s'\n", - // annoClassDef,annMemb,cname.data(),ltype.mid(i,l).data()); + // annoClassDef,annMemb,qPrint(cname),qPrint(ltype.mid(i,l))); if (annoClassDef) // type is an anonymous compound { @@ -2190,7 +2158,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.writeNonBreakableSpace(3); } QCString varName=ltype.right(ltype.length()-ir).stripWhiteSpace(); - //printf(">>>>>> ltype='%s' varName='%s'\n",ltype.data(),varName.data()); + //printf(">>>>>> ltype='%s' varName='%s'\n",qPrint(ltype),qPrint(varName)); ol.docify("}"); if (varName.isEmpty() && isAnonymous()) { @@ -2280,7 +2248,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, static bool extractPrivateVirtual = Config_getBool(EXTRACT_PRIV_VIRTUAL); static bool extractStatic = Config_getBool(EXTRACT_STATIC); MemberDefMutable *annMemb = toMemberDefMutable(m_impl->annMemb); - //printf("Member name=`%s gd=%p md->groupDef=%p inGroup=%d isLinkable()=%d hasDocumentation=%d\n",name().data(),gd,getGroupDef(),inGroup,isLinkable(),hasDocumentation()); + //printf("Member name=`%s gd=%p md->groupDef=%p inGroup=%d isLinkable()=%d hasDocumentation=%d\n",qPrint(name()),gd,getGroupDef(),inGroup,isLinkable(),hasDocumentation()); if (!name().isEmpty() && // name valid (hasDocumentation() || isReference()) && // has docs !(m_impl->prot==Private && !extractPrivate && (m_impl->virt==Normal || !extractPrivateVirtual) && m_impl->mtype!=MemberType_Friend) && // hidden due to protection @@ -2300,7 +2268,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } else { - //printf("writeLink %s->%d\n",name.data(),hasDocumentation()); + //printf("writeLink %s->%d\n",qPrint(name),hasDocumentation()); const ClassDef *rcd = cd; if (isReference() && getClassDef()) rcd = getClassDef(); writeLink(ol,rcd,nd,fd,gd); @@ -2348,7 +2316,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } // *** write arguments - if (argsString() && !isObjCMethod()) + if (!argsString().isEmpty() && !isObjCMethod()) { if (!isDefine() && !isTypedef()) ol.writeString(" "); linkifyText(TextGeneratorOLImpl(ol), // out @@ -2356,9 +2324,9 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, getBodyDef(), // fileScope this, // self isDefine() ? - (const char*)substitute(argsString(),",",", ") : + substitute(argsString(),",",", ") : isTypedef() ? - (const char*)substitute(argsString(),")(",") (") : + substitute(argsString(),")(",") (") : argsString(), // text m_impl->annMemb, // autoBreak TRUE, // external @@ -2367,7 +2335,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ); } // *** write exceptions - if (excpString()) + if (!excpString().isEmpty()) { ol.writeString(" "); ol.docify(excpString()); @@ -2418,23 +2386,26 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.writeLatexSpacing(); ol.startTypewriter(); ol.docify(" ["); - QStrList sl; + StringVector sl; - if (isGettable()) sl.append("get"); - if (isProtectedGettable()) sl.append("protected get"); - if (isSettable()) sl.append("set"); - if (isProtectedSettable()) sl.append("protected set"); + if (isGettable()) sl.push_back("get"); + if (isProtectedGettable()) sl.push_back("protected get"); + if (isSettable()) sl.push_back("set"); + if (isProtectedSettable()) sl.push_back("protected set"); if (extractPrivate) { - if (isPrivateGettable()) sl.append("private get"); - if (isPrivateSettable()) sl.append("private set"); + if (isPrivateGettable()) sl.push_back("private get"); + if (isPrivateSettable()) sl.push_back("private set"); } - const char *s=sl.first(); - while (s) + bool first=true; + for (const auto &s : sl) { - ol.docify(s); - s=sl.next(); - if (s) ol.docify(", "); + if (!first) + { + ol.docify(", "); + first=false; + } + ol.docify(s.c_str()); } ol.docify("]"); ol.endTypewriter(); @@ -2445,16 +2416,19 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, ol.writeLatexSpacing(); ol.startTypewriter(); ol.docify(" ["); - QStrList sl; - if (isAddable()) sl.append("add"); - if (isRemovable()) sl.append("remove"); - if (isRaisable()) sl.append("raise"); - const char *s=sl.first(); - while (s) + StringVector sl; + if (isAddable()) sl.push_back("add"); + if (isRemovable()) sl.push_back("remove"); + if (isRaisable()) sl.push_back("raise"); + bool first=true; + for (const auto &s : sl) { - ol.docify(s); - s=sl.next(); - if (s) ol.docify(", "); + if (!first) + { + ol.docify(", "); + first=false; + } + ol.docify(s.c_str()); } ol.docify("]"); ol.endTypewriter(); @@ -2466,7 +2440,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, } //printf("endMember %s annoClassDef=%p annEnumType=%p\n", - // name().data(),annoClassDef,annEnumType); + // qPrint(name()),annoClassDef,annEnumType); ol.endMemberItem(); if (endAnonScopeNeeded) { @@ -2481,7 +2455,7 @@ void MemberDefImpl::writeDeclaration(OutputList &ol, { DocRoot *rootNode = validatingParseDoc(briefFile(),briefLine(), getOuterScope()?getOuterScope():d,this,briefDescription(),TRUE,FALSE, - 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); if (rootNode && !rootNode->isEmpty()) { @@ -2593,12 +2567,13 @@ bool MemberDefImpl::isDetailedSectionVisible(bool inGroup,bool inFile) const !isReference(); bool result = visible || simpleFilter; //printf("%s::isDetailedSectionVisible: %d groupFilter=%d fileFilter=%d\n", - // name().data(),result,groupFilter,fileFilter); + // qPrint(name()),result,groupFilter,fileFilter); return result; } -void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const +StringVector MemberDefImpl::getLabels(const Definition *container) const { + StringVector sl; static bool inlineInfo = Config_getBool(INLINE_INFO); Specifier lvirt=virtualness(); @@ -2622,82 +2597,82 @@ void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const static bool extractPrivate = Config_getBool(EXTRACT_PRIVATE); if (optVhdl) { - sl.append(theTranslator->trVhdlType(getMemberSpecifiers(),TRUE)); + sl.push_back(theTranslator->trVhdlType(getMemberSpecifiers(),TRUE).str()); } else { - if (isFriend()) sl.append("friend"); - else if (isRelated()) sl.append("related"); + if (isFriend()) sl.push_back("friend"); + else if (isRelated()) sl.push_back("related"); else { - if (isExternal()) sl.append("extern"); - if (inlineInfo && isInline()) sl.append("inline"); - if (isExplicit()) sl.append("explicit"); - if (isMutable()) sl.append("mutable"); - if (isStatic()) sl.append("static"); - if (isGettable()) sl.append("get"); - if (isProtectedGettable()) sl.append("protected get"); - if (isSettable()) sl.append("set"); - if (isProtectedSettable()) sl.append("protected set"); + if (isExternal()) sl.push_back("extern"); + if (inlineInfo && isInline()) sl.push_back("inline"); + if (isExplicit()) sl.push_back("explicit"); + if (isMutable()) sl.push_back("mutable"); + if (isStatic()) sl.push_back("static"); + if (isGettable()) sl.push_back("get"); + if (isProtectedGettable()) sl.push_back("protected get"); + if (isSettable()) sl.push_back("set"); + if (isProtectedSettable()) sl.push_back("protected set"); if (extractPrivate) { - if (isPrivateGettable()) sl.append("private get"); - if (isPrivateSettable()) sl.append("private set"); + if (isPrivateGettable()) sl.push_back("private get"); + if (isPrivateSettable()) sl.push_back("private set"); } - if (isConstExpr()) sl.append("constexpr"); - if (isAddable()) sl.append("add"); - if (!isUNOProperty() && isRemovable()) sl.append("remove"); - if (isRaisable()) sl.append("raise"); - if (isReadable()) sl.append("read"); - if (isWritable()) sl.append("write"); - if (isFinal()) sl.append("final"); - if (isAbstract()) sl.append("abstract"); - if (isOverride()) sl.append("override"); - if (isInitonly()) sl.append("initonly"); - if (isSealed()) sl.append("sealed"); - if (isNew()) sl.append("new"); - if (isOptional()) sl.append("optional"); - if (isRequired()) sl.append("required"); - - if (isNonAtomic()) sl.append("nonatomic"); - else if (isObjCProperty()) sl.append("atomic"); + if (isConstExpr()) sl.push_back("constexpr"); + if (isAddable()) sl.push_back("add"); + if (!isUNOProperty() && isRemovable()) sl.push_back("remove"); + if (isRaisable()) sl.push_back("raise"); + if (isReadable()) sl.push_back("read"); + if (isWritable()) sl.push_back("write"); + if (isFinal()) sl.push_back("final"); + if (isAbstract()) sl.push_back("abstract"); + if (isOverride()) sl.push_back("override"); + if (isInitonly()) sl.push_back("initonly"); + if (isSealed()) sl.push_back("sealed"); + if (isNew()) sl.push_back("new"); + if (isOptional()) sl.push_back("optional"); + if (isRequired()) sl.push_back("required"); + + if (isNonAtomic()) sl.push_back("nonatomic"); + else if (isObjCProperty()) sl.push_back("atomic"); // mutual exclusive Objective 2.0 property attributes - if (isAssign()) sl.append("assign"); - else if (isCopy()) sl.append("copy"); - else if (isRetain()) sl.append("retain"); - else if (isWeak()) sl.append("weak"); - else if (isStrong()) sl.append("strong"); - else if (isUnretained()) sl.append("unsafe_unretained"); + if (isAssign()) sl.push_back("assign"); + else if (isCopy()) sl.push_back("copy"); + else if (isRetain()) sl.push_back("retain"); + else if (isWeak()) sl.push_back("weak"); + else if (isStrong()) sl.push_back("strong"); + else if (isUnretained()) sl.push_back("unsafe_unretained"); if (!isObjCMethod()) { - if (protection()==Protected) sl.append("protected"); - else if (protection()==Private) sl.append("private"); - else if (protection()==Package) sl.append("package"); - - if (lvirt==Virtual) sl.append("virtual"); - else if (lvirt==Pure) sl.append("pure virtual"); - if (isSignal()) sl.append("signal"); - if (isSlot()) sl.append("slot"); - if (isDefault()) sl.append("default"); - if (isDelete()) sl.append("delete"); - if (isNoExcept()) sl.append("noexcept"); - if (isAttribute()) sl.append("attribute"); - if (isUNOProperty()) sl.append("property"); - if (isReadonly()) sl.append("readonly"); - if (isBound()) sl.append("bound"); - if (isUNOProperty() && isRemovable()) sl.append("removable"); - if (isConstrained()) sl.append("constrained"); - if (isTransient()) sl.append("transient"); - if (isMaybeVoid()) sl.append("maybevoid"); - if (isMaybeDefault()) sl.append("maybedefault"); - if (isMaybeAmbiguous()) sl.append("maybeambiguous"); - if (isPublished()) sl.append("published"); // enum + if (protection()==Protected) sl.push_back("protected"); + else if (protection()==Private) sl.push_back("private"); + else if (protection()==Package) sl.push_back("package"); + + if (lvirt==Virtual) sl.push_back("virtual"); + else if (lvirt==Pure) sl.push_back("pure virtual"); + if (isSignal()) sl.push_back("signal"); + if (isSlot()) sl.push_back("slot"); + if (isDefault()) sl.push_back("default"); + if (isDelete()) sl.push_back("delete"); + if (isNoExcept()) sl.push_back("noexcept"); + if (isAttribute()) sl.push_back("attribute"); + if (isUNOProperty()) sl.push_back("property"); + if (isReadonly()) sl.push_back("readonly"); + if (isBound()) sl.push_back("bound"); + if (isUNOProperty() && isRemovable()) sl.push_back("removable"); + if (isConstrained()) sl.push_back("constrained"); + if (isTransient()) sl.push_back("transient"); + if (isMaybeVoid()) sl.push_back("maybevoid"); + if (isMaybeDefault()) sl.push_back("maybedefault"); + if (isMaybeAmbiguous()) sl.push_back("maybeambiguous"); + if (isPublished()) sl.push_back("published"); // enum } if (isObjCProperty() && isImplementation()) { - sl.append("implementation"); + sl.push_back("implementation"); } } if (getClassDef() && @@ -2706,14 +2681,15 @@ void MemberDefImpl::getLabels(QStrList &sl,const Definition *container) const !isRelated() ) { - sl.append("inherited"); + sl.push_back("inherited"); } } } else if (isObjCMethod() && isImplementation()) { - sl.append("implementation"); + sl.push_back("implementation"); } + return sl; } void MemberDefImpl::_writeCallGraph(OutputList &ol) const @@ -2767,7 +2743,7 @@ void MemberDefImpl::_writeCallerGraph(OutputList &ol) const void MemberDefImpl::_writeReimplements(OutputList &ol) const { - MemberDef *bmd=reimplements(); + const MemberDef *bmd=reimplements(); const ClassDef *bcd=0; if (bmd && (bcd=bmd->getClassDef())) { @@ -2805,7 +2781,7 @@ void MemberDefImpl::_writeReimplements(OutputList &ol) const else { ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(), - 0,bcd->displayName()); + QCString(),bcd->displayName()); if (bcd->isLinkableInProject()/* && !Config_getBool(PDF_HYPERLINKS)*/ ) { writePageRef(ol,bcd->getOutputFileBase(),bcd->anchor()); @@ -2826,76 +2802,70 @@ void MemberDefImpl::_writeReimplements(OutputList &ol) const void MemberDefImpl::_writeReimplementedBy(OutputList &ol) const { - MemberList *bml=reimplementedBy(); - if (bml) + const MemberList &bml=reimplementedBy(); + size_t count=0; + for (const auto &bmd : bml) { - MemberListIterator mli(*bml); - MemberDef *bmd=0; - uint count=0; - const ClassDef *bcd=0; - for (mli.toFirst();(bmd=mli.current()) && (bcd=bmd->getClassDef());++mli) + const ClassDef *bcd=bmd->getClassDef(); + // count the members that directly inherit from md and for + // which the member and class are visible in the docs. + if ( bcd && bmd->isLinkable() && bcd->isLinkable() ) { - // count the members that directly inherit from md and for - // which the member and class are visible in the docs. - if ( bmd->isLinkable() && bcd->isLinkable() ) - { - count++; - } + count++; } - if (count>0) + } + if (count>0) + { + auto replaceFunc = [&bml,&ol](size_t entryIndex) { - mli.toFirst(); - // write the list of classes that overwrite this member - ol.startParagraph(); - - QCString reimplInLine; - if (m_impl->virt==Pure || (getClassDef() && getClassDef()->compoundType()==ClassDef::Interface)) - { - reimplInLine = theTranslator->trImplementedInList(count); - } - else - { - reimplInLine = theTranslator->trReimplementedInList(count); - } - static QRegExp marker("@[0-9]+"); - int index=0,newIndex,matchLen; - // now replace all markers in reimplInLine with links to the classes - while ((newIndex=marker.match(reimplInLine,index,&matchLen))!=-1) + size_t cnt=0; + auto it = bml.begin(); + // find the entryIndex-th documented entry in the inheritance list. + const MemberDef *bmd = 0; + const ClassDef *bcd = 0; + while (it!=bml.end()) { - ol.parseText(reimplInLine.mid(index,newIndex-index)); - bool ok; - uint entryIndex = reimplInLine.mid(newIndex+1,matchLen-1).toUInt(&ok); - //bmd=bml->at(entryIndex); - - count=0; - // find the entryIndex-th documented entry in the inheritance list. - for (mli.toLast();(bmd=mli.current()) && (bcd=bmd->getClassDef());--mli) + bmd = *it; + bcd = bmd->getClassDef(); + if ( bmd->isLinkable() && bcd->isLinkable()) { - if ( bmd->isLinkable() && bcd->isLinkable()) - { - if (count==entryIndex) break; - count++; - } + if (cnt==entryIndex) break; + cnt++; } + ++it; + } - if (ok && bcd && bmd) // write link for marker - { - //ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(), - // bmd->anchor(),bcd->name()); - ol.writeObjectLink(bmd->getReference(),bmd->getOutputFileBase(), - bmd->anchor(),bcd->displayName()); + if (bcd && bmd) // write link for marker + { + //ol.writeObjectLink(bcd->getReference(),bcd->getOutputFileBase(), + // bmd->anchor(),bcd->name()); + ol.writeObjectLink(bmd->getReference(),bmd->getOutputFileBase(), + bmd->anchor(),bcd->displayName()); - if (bmd->isLinkableInProject() ) - { - writePageRef(ol,bmd->getOutputFileBase(),bmd->anchor()); - } + if (bmd->isLinkableInProject() ) + { + writePageRef(ol,bmd->getOutputFileBase(),bmd->anchor()); } - ++mli; - index=newIndex+matchLen; } - ol.parseText(reimplInLine.right(reimplInLine.length()-index)); - ol.endParagraph(); + }; + + QCString reimplInLine; + if (m_impl->virt==Pure || (getClassDef() && getClassDef()->compoundType()==ClassDef::Interface)) + { + reimplInLine = theTranslator->trImplementedInList((int)count); } + else + { + reimplInLine = theTranslator->trReimplementedInList((int)count); + } + + // write the list of classes that overwrite this member + ol.startParagraph(); + writeMarkerList(ol, + reimplInLine.str(), + count, + replaceFunc); + ol.endParagraph(); } } @@ -2904,11 +2874,11 @@ void MemberDefImpl::_writeCategoryRelation(OutputList &ol) const if (getClassDef()) // this should be a member of a class/category { //printf("%s: category %s relation %s class=%s categoryOf=%s\n", - // name().data(), - // m_impl->category ? m_impl->category->name().data() : "<none>", - // m_impl->categoryRelation ? m_impl->categoryRelation->name().data() : "<none>", - // m_impl->classDef->name().data(), - // m_impl->classDef->categoryOf() ? m_impl->classDef->categoryOf()->name().data() : "<none>" + // qPrint(name()), + // m_impl->category ? qPrint(m_impl->category->name()) : "<none>", + // m_impl->categoryRelation ? qPrint(m_impl->categoryRelation->name()) : "<none>", + // qPrint(m_impl->classDef->name()), + // m_impl->classDef->categoryOf() ? qPrint(m_impl->classDef->categoryOf()->name()) : "<none>" // ); QCString text; QCString ref; @@ -2935,7 +2905,7 @@ void MemberDefImpl::_writeCategoryRelation(OutputList &ol) const i=text.find("@0"); if (i!=-1) { - MemberDef *md = m_impl->categoryRelation; + const MemberDef *md = m_impl->categoryRelation; ref = md->getReference(); file = md->getOutputFileBase(); anc = md->anchor(); @@ -2981,65 +2951,59 @@ void MemberDefImpl::_writeEnumValues(OutputList &ol,const Definition *container, if (isEnumerate()) { bool first=TRUE; - const MemberList *fmdl=enumFieldList(); - //printf("** %s: enum values=%d\n",name().data(),fmdl!=0 ? fmdl->count() : 0); - if (fmdl) + //printf("** %s: enum values=%zu\n",qPrint(name()),enumFieldList().size()); + for (const auto &fmd : enumFieldList()) { - MemberListIterator it(*fmdl); - MemberDef *fmd; - for (;(fmd=it.current());++it) + //printf("Enum %p: isLinkable()=%d\n",fmd,fmd->isLinkable()); + if (fmd->isLinkable()) { - //printf("Enum %p: isLinkable()=%d\n",fmd,fmd->isLinkable()); - if (fmd->isLinkable()) + if (first) { - if (first) - { - ol.startDescTable(theTranslator->trEnumerationValues()); - } + ol.startDescTable(theTranslator->trEnumerationValues()); + } - ol.startDescTableRow(); - ol.addIndexItem(fmd->name(),ciname); - ol.addIndexItem(ciname,fmd->name()); + ol.startDescTableRow(); + ol.addIndexItem(fmd->name(),ciname); + ol.addIndexItem(ciname,fmd->name()); - Doxygen::indexList->addIndexItem(container,fmd); + Doxygen::indexList->addIndexItem(container,fmd); - ol.startDescTableTitle(); - ol.startDoxyAnchor(cfname,cname,fmd->anchor(),fmd->name(),fmd->argsString()); - first=FALSE; - ol.docify(fmd->name()); - ol.disableAllBut(OutputGenerator::Man); - ol.writeString(" "); - ol.enableAll(); - ol.endDoxyAnchor(cfname,fmd->anchor()); - ol.endDescTableTitle(); - ol.startDescTableData(); + ol.startDescTableTitle(); + ol.startDoxyAnchor(cfname,cname,fmd->anchor(),fmd->name(),fmd->argsString()); + first=FALSE; + ol.docify(fmd->name()); + ol.disableAllBut(OutputGenerator::Man); + ol.writeString(" "); + ol.enableAll(); + ol.endDoxyAnchor(cfname,fmd->anchor()); + ol.endDescTableTitle(); + ol.startDescTableData(); - bool hasBrief = !fmd->briefDescription().isEmpty(); - bool hasDetails = !fmd->documentation().isEmpty(); + bool hasBrief = !fmd->briefDescription().isEmpty(); + bool hasDetails = !fmd->documentation().isEmpty(); - if (hasBrief) - { - ol.generateDoc(fmd->briefFile(),fmd->briefLine(), - getOuterScope()?getOuterScope():container, - fmd,fmd->briefDescription(),TRUE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); - } - // FIXME:PARA - //if (!fmd->briefDescription().isEmpty() && - // !fmd->documentation().isEmpty()) - //{ - // ol.newParagraph(); - //} - if (hasDetails) - { - ol.generateDoc(fmd->docFile(),fmd->docLine(), - getOuterScope()?getOuterScope():container, - fmd,fmd->documentation()+"\n",TRUE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); - } - ol.endDescTableData(); - ol.endDescTableRow(); + if (hasBrief) + { + ol.generateDoc(fmd->briefFile(),fmd->briefLine(), + getOuterScope()?getOuterScope():container, + fmd,fmd->briefDescription(),TRUE,FALSE, + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + } + // FIXME:PARA + //if (!fmd->briefDescription().isEmpty() && + // !fmd->documentation().isEmpty()) + //{ + // ol.newParagraph(); + //} + if (hasDetails) + { + ol.generateDoc(fmd->docFile(),fmd->docLine(), + getOuterScope()?getOuterScope():container, + fmd,fmd->documentation()+"\n",TRUE,FALSE, + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } + ol.endDescTableData(); + ol.endDescTableRow(); } } if (!first) @@ -3049,6 +3013,9 @@ void MemberDefImpl::_writeEnumValues(OutputList &ol,const Definition *container, } } +// match from the start of the scope until the last marker +static const reg::Ex reAnonymous(R"([\w:@]*@\d+)"); + QCString MemberDefImpl::displayDefinition() const { QCString ldef = definition(); @@ -3079,21 +3046,14 @@ QCString MemberDefImpl::displayDefinition() const ldef=ldef.mid(2); } } - static QRegExp r("@[0-9]+"); - int l,i=r.match(ldef,0,&l); - if (i!=-1) // replace anonymous parts with { ... } + + std::string sdef = ldef.str(); + reg::Match match; + if (reg::search(sdef,match,reAnonymous)) { - int si=ldef.find(' '),pi,ei=i+l; - if (si==-1) si=0; - while ((pi=r.match(ldef,i+l,&l))!=-1) - { - i=pi; - ei=i+l; - } - int ni=ldef.find("::",si); - if (ni>=ei) ei=ni+2; - ldef = ldef.left(si) + " { ... } " + ldef.right(ldef.length()-ei); + ldef = match.prefix().str() + " { ... } " + match.suffix().str(); } + const ClassDef *cd=getClassDef(); if (cd && cd->isObjectiveC()) { @@ -3113,9 +3073,9 @@ QCString MemberDefImpl::displayDefinition() const { ldef=ldef.left(dp+1); } - l=ldef.length(); - //printf("start >%s<\n",ldef.data()); - i=l-1; + int l=ldef.length(); + //printf("start >%s<\n",qPrint(ldef)); + int i=l-1; while (i>=0 && (isId(ldef.at(i)) || ldef.at(i)==':')) i--; while (i>=0 && isspace((uchar)ldef.at(i))) i--; if (i>0) @@ -3124,7 +3084,7 @@ QCString MemberDefImpl::displayDefinition() const QCString tmp("("+ldef.left(i+1)+")"+ldef.mid(i+1)); ldef=tmp; } - //printf("end >%s< i=%d\n",ldef.data(),i); + //printf("end >%s< i=%d\n",qPrint(ldef),i); if (isStatic()) ldef.prepend("+ "); else ldef.prepend("- "); } SrcLangExt lang = getLanguage(); @@ -3179,7 +3139,7 @@ void MemberDefImpl::_writeGroupInclude(OutputList &ol,bool inGroup) const void MemberDefImpl::writeDocumentation(const MemberList *ml, int memCount,int memTotal, OutputList &ol, - const char *scName, + const QCString &scName, const Definition *container, bool inGroup, bool showEnumValues, @@ -3190,13 +3150,13 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, bool hasParameterList = FALSE; //printf("MemberDefImpl::writeDocumentation(): name='%s' hasDocs='%d' containerType=%d inGroup=%d sectionLinkable=%d\n", - // name().data(),hasDocs,container->definitionType(),inGroup,isDetailedSectionLinkable()); + // qPrint(name()),hasDocs,container->definitionType(),inGroup,isDetailedSectionLinkable()); //if ( !hasDocs ) return; //if (isEnumValue() && !showEnumValues) return; SrcLangExt lang = getLanguage(); - //printf("member=%s lang=%d\n",name().data(),lang); + //printf("member=%s lang=%d\n",qPrint(name()),lang); bool optVhdl = lang==SrcLangExt_VHDL; QCString sep = getLanguageSpecificSeparator(lang,TRUE); @@ -3231,7 +3191,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, QCString ldef = definition(); QCString title = name(); - //printf("member '%s' def='%s'\n",name().data(),ldef.data()); + //printf("member '%s' def='%s'\n",qPrint(name()),qPrint(ldef)); if (isEnumerate()) { if (title.at(0)=='@') @@ -3244,6 +3204,8 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, } else { + if (isEnumStruct()) ldef.prepend("struct "); + else if (isStrong()) ldef.prepend("class "); ldef.prepend("enum "); if (isSliceLocal()) { @@ -3262,9 +3224,6 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { title += "()"; } - int i=0,l; - static QRegExp r("@[0-9]+"); - if (lang == SrcLangExt_Slice) { // Remove the container scope from the member name. @@ -3281,49 +3240,51 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.pushGeneratorState(); bool htmlEndLabelTable=FALSE; - QStrList sl; - getLabels(sl,scopedContainer); + StringVector sl = getLabels(scopedContainer); - if ((isVariable() || isTypedef()) && (i=r.match(ldef,0,&l))!=-1) + static const reg::Ex r(R"(@\d+)"); + reg::Match match; + std::string sdef = ldef.str(); + if ((isVariable() || isTypedef()) && reg::search(sdef,match,r)) { // find enum type and insert it in the definition - MemberListIterator vmli(*ml); - MemberDef *vmd; - bool found=FALSE; - for ( ; (vmd=vmli.current()) && !found ; ++vmli) + bool found=false; + for (const auto &vmd : *ml) { - if (vmd->isEnumerate() && ldef.mid(i,l)==vmd->name()) + if (vmd->isEnumerate() && match.str()==vmd->name()) { ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs); ol.startMemberDoc(ciname,name(),memAnchor,name(),memCount,memTotal,showInline); - linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,ldef.left(i)); + std::string prefix = match.prefix().str(); + std::string suffix = match.suffix().str(); + linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,prefix.c_str()); vmd->writeEnumDeclaration(ol,getClassDef(),getNamespaceDef(),getFileDef(),getGroupDef()); - linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,ldef.right(ldef.length()-i-l)); + linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,suffix.c_str()); - found=TRUE; + found=true; + break; } } if (!found) // anonymous compound { - //printf("Anonymous compound '%s'\n",cname.data()); + //printf("Anonymous compound '%s'\n",qPrint(cname)); ol.startDoxyAnchor(cfname,cname,memAnchor,doxyName,doxyArgs); ol.startMemberDoc(ciname,name(),memAnchor,"",memCount,memTotal,showInline); // search for the last anonymous compound name in the definition - int si=ldef.find(' '),pi,ei=i+l; - if (si==-1) si=0; - while ((pi=r.match(ldef,i+l,&l))!=-1) + + ol.startMemberDocName(isObjCMethod()); + if (reg::search(sdef,match,reAnonymous)) { - i=pi; - ei=i+l; + std::string prefix = match.prefix().str(); + std::string suffix = match.suffix().str(); + ol.docify(prefix.c_str()); + ol.docify(" { ... } "); + linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,suffix.c_str()); + } + else + { + linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,ldef); } - // first si characters of ldef contain compound type name - ol.startMemberDocName(isObjCMethod()); - ol.docify(ldef.left(si)); - ol.docify(" { ... } "); - // last ei characters of ldef contain pointer/reference specifiers - int ni=ldef.find("::",si); - if (ni>=ei) ei=ni+2; - linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,ldef.right(ldef.length()-ei)); } } else // not an enum value or anonymous compound @@ -3352,7 +3313,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { if (!first) ol.docify(" "); ol.startMemberDocPrefixItem(); - writeTemplatePrefix(ol,tal); + _writeTemplatePrefix(ol,scopedContainer,tal); ol.endMemberDocPrefixItem(); } } @@ -3368,7 +3329,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { if (!first) ol.docify(" "); ol.startMemberDocPrefixItem(); - writeTemplatePrefix(ol,tal); + _writeTemplatePrefix(ol,scopedContainer,tal,false); ol.endMemberDocPrefixItem(); } } @@ -3376,13 +3337,13 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, if (m_impl->tArgList.hasParameters() && lang==SrcLangExt_Cpp) // function template prefix { ol.startMemberDocPrefixItem(); - writeTemplatePrefix(ol,m_impl->tArgList); + _writeTemplatePrefix(ol,scopedContainer,m_impl->tArgList); ol.endMemberDocPrefixItem(); } } } - if (sl.count()>0) + if (!sl.empty()) { ol.pushGeneratorState(); ol.disableAll(); @@ -3416,8 +3377,8 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ldef=ldef.left(dp+1); } int dl=ldef.length(); - //printf("start >%s<\n",ldef.data()); - i=dl-1; + //printf("start >%s<\n",qPrint(ldef)); + int i=dl-1; while (i>=0 && (isId(ldef.at(i)) || ldef.at(i)==':')) i--; while (i>=0 && isspace((uchar)ldef.at(i))) i--; if (i>0) @@ -3426,7 +3387,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, QCString tmp("("+ldef.left(i+1)+")"+ldef.mid(i+1)); ldef=tmp; } - //printf("end >%s< i=%d\n",ldef.data(),i); + //printf("end >%s< i=%d\n",qPrint(ldef),i); if (isStatic()) ldef.prepend("+ "); else ldef.prepend("- "); } @@ -3477,7 +3438,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, linkifyText(TextGeneratorOLImpl(ol),scopedContainer,getBodyDef(),this,m_impl->initializer); } } - if (excpString()) // add exception list + if (!excpString().isEmpty()) // add exception list { writeExceptionList(ol,cd,this); hasParameterList=true; // call endParameterList below @@ -3486,15 +3447,14 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.pushGeneratorState(); ol.disable(OutputGenerator::Html); - if (sl.count()>0) + if (!sl.empty()) { ol.startLabels(); - const char *s=sl.first(); - while (s) + size_t count=0; + for (const auto &s : sl) { - const char *ns = sl.next(); - ol.writeLabel(s,ns==0); - s=ns; + count++; + ol.writeLabel(s.c_str(),count==sl.size()); } ol.endLabels(); } @@ -3520,12 +3480,11 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.writeString(" </td>\n"); ol.writeString(" <td class=\"mlabels-right\">\n"); ol.startLabels(); - const char *s=sl.first(); - while (s) + size_t count=0; + for (const auto &s : sl) { - const char *ns = sl.next(); - ol.writeLabel(s,ns==0); - s=ns; + count++; + ol.writeLabel(s.c_str(),count==sl.size()); } ol.endLabels(); ol.writeString(" </td>\n"); @@ -3548,17 +3507,24 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, // ) ) { - //printf("md=%s initLines=%d init='%s'\n",name().data(),initLines,init.data()); + //printf("md=%s initLines=%d init='%s'\n",qPrint(name()),initLines,qPrint(init)); ol.startBold(); if (m_impl->mtype==MemberType_Define) ol.parseText(theTranslator->trDefineValue()); else ol.parseText(theTranslator->trInitialValue()); ol.endBold(); - auto intf = Doxygen::parserManager->getCodeParser(getDefFileExtension()); + QCString langCorrected = getDefFileExtension(); + SrcLangExt srcLangExt = getLanguageFromFileName(getDefFileExtension()); + if (srcLangExt == SrcLangExt_Lex) + { + langCorrected = ".doxygen_lex_c"; + srcLangExt = SrcLangExt_Cpp; + } + auto intf = Doxygen::parserManager->getCodeParser(langCorrected); intf->resetCodeParserState(); ol.startCodeFragment("DoxyCode"); - intf->parseCode(ol,scopeName,m_impl->initializer,lang,FALSE,0,const_cast<FileDef*>(getFileDef()), + intf->parseCode(ol,scopeName,m_impl->initializer,srcLangExt,FALSE,QCString(),const_cast<FileDef*>(getFileDef()), -1,-1,TRUE,this,FALSE,this); ol.endCodeFragment("DoxyCode"); } @@ -3584,7 +3550,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.generateDoc(briefFile(),briefLine(), scopedContainer,this, brief,FALSE,FALSE, - 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); ol.endParagraph(); } @@ -3601,7 +3567,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, else { ol.generateDoc(docFile(),docLine(),scopedContainer,this,detailed+"\n",TRUE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } if (!inbodyDocumentation().isEmpty()) @@ -3609,7 +3575,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, ol.generateDoc(inbodyFile(),inbodyLine(), scopedContainer,this, inbodyDocumentation()+"\n",TRUE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } } else if (!brief.isEmpty() && (Config_getBool(REPEAT_BRIEF) || @@ -3618,7 +3584,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, if (!inbodyDocumentation().isEmpty()) { ol.generateDoc(inbodyFile(),inbodyLine(),scopedContainer,this,inbodyDocumentation()+"\n",TRUE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } } @@ -3646,7 +3612,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, paramDocs, // docStr TRUE, // indexWords FALSE, // isExample - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT) + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT) ); } @@ -3685,69 +3651,23 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, } // strip scope and field name from the type -// example: "struct N::S.v.c" will become "struct v" +// example: "struct N<K::J>::S.v.c" will become "struct v" static QCString simplifyTypeForTable(const QCString &s) { QCString ts=removeAnonymousScopes(s); if (ts.right(2)=="::") ts = ts.left(ts.length()-2); - static QRegExp re("[A-Z_a-z0-9]+::"); - int i,l; - while ((i=re.match(ts,0,&l))!=-1) + static const reg::Ex re1(R"(\a\w*::(\a\w*))"); // non-template version + static const reg::Ex re2(R"(\a\w*<[^>]*>::(\a\w*))"); // template version + reg::Match match; + std::string t = ts.str(); + if (reg::search(t,match,re1) || reg::search(t,match,re2)) { - ts=ts.left(i)+ts.mid(i+l); + ts = match[1].str(); // take the identifier after the last :: } - i=ts.findRev('.'); - if (i!=-1) ts = ts.left(i); - i=ts.findRev('.'); - if (i!=-1) ts = ts.right(ts.length()-i-1); - //printf("simplifyTypeForTable(%s)->%s\n",s.data(),ts.data()); + //printf("simplifyTypeForTable(%s)->%s\n",qPrint(s),qPrint(ts)); return ts; } -#if 0 -/** Returns the type definition corresponding to a member's return type. - * @param[in] scope The scope in which to search for the class definition. - * @param[in] type The string representing the member's return type. - * @param[in] lang The programming language in which the class is defined. - * @param[out] start The string position where the class definition name was found. - * @param[out] length The length of the class definition's name. - */ -static Definition *getClassFromType(Definition *scope,const QCString &type,SrcLangExt lang,int &start,int &length) -{ - int pos=0; - int i; - QCString name; - QCString templSpec; - while ((i=extractClassNameFromType(type,pos,name,templSpec,lang))!=-1) - { - ClassDef *cd=0; - MemberDef *md=0; - int l = name.length()+templSpec.length(); - if (!templSpec.isEmpty()) - { - cd = getResolvedClass(scope,0,name+templSpec,&md); - } - cd = getResolvedClass(scope,0,name); - if (cd) - { - start=i; - length=l; - printf("getClassFromType: type=%s name=%s start=%d length=%d\n",type.data(),name.data(),start,length); - return cd; - } - else if (md) - { - start=i; - length=l; - printf("getClassFromType: type=%s name=%s start=%d length=%d\n",type.data(),name.data(),start,length); - return md; - } - pos=i+l; - } - return 0; -} -#endif - QCString MemberDefImpl::fieldType() const { QCString type = m_impl->accessorType; @@ -3775,7 +3695,7 @@ void MemberDefImpl::writeMemberDocSimple(OutputList &ol, const Definition *conta } ClassDef *cd = m_impl->accessorClass; - //printf("===> %s::anonymous: %s\n",name().data(),cd?cd->name().data():"<none>"); + //printf("===> %s::anonymous: %s\n",qPrint(name()),cd?qPrint(cd->name()):"<none>"); if (container && container->definitionType()==Definition::TypeClass && !(toClassDef(container))->isJavaEnum()) @@ -3820,7 +3740,7 @@ void MemberDefImpl::writeMemberDocSimple(OutputList &ol, const Definition *conta ol.startInlineMemberName(); ol.docify(doxyName); - if (isVariable() && argsString() && !isObjCMethod()) + if (isVariable() && !argsString().isEmpty() && !isObjCMethod()) { linkifyText(TextGeneratorOLImpl(ol),getOuterScope(),getBodyDef(),this,argsString()); } @@ -3841,7 +3761,7 @@ void MemberDefImpl::writeMemberDocSimple(OutputList &ol, const Definition *conta ol.generateDoc(briefFile(),briefLine(), getOuterScope()?getOuterScope():container,this, brief,FALSE,FALSE, - 0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } /* write detailed description */ @@ -3850,7 +3770,7 @@ void MemberDefImpl::writeMemberDocSimple(OutputList &ol, const Definition *conta ol.generateDoc(docFile(),docLine(), getOuterScope()?getOuterScope():container,this, detailed+"\n",FALSE,FALSE, - 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); + QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); } @@ -3907,7 +3827,7 @@ void MemberDefImpl::warnIfUndocumented() const static bool extractAll = Config_getBool(EXTRACT_ALL); //printf("%s:warnIfUndoc: hasUserDocs=%d isFriendClass=%d protection=%d isRef=%d isDel=%d\n", - // name().data(), + // qPrint(name()), // hasUserDocumentation(),isFriendClass(),protectionLevelVisible(m_impl->prot),isReference(),isDeleted()); if ((!hasUserDocumentation() && !extractAll) && !isFriendClass() && @@ -3924,7 +3844,7 @@ void MemberDefImpl::warnIfUndocumented() const warnIfUndocumentedParams(); } } -static QCString stripTrailingReturn(const QCString trailRet) +static QCString stripTrailingReturn(const QCString &trailRet) { QCString ret = trailRet; @@ -3958,7 +3878,7 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn if (!m_impl->hasDocumentedParams && hasParamCommand) { - //printf("%s:hasDocumentedParams=TRUE;\n",name().data()); + //printf("%s:hasDocumentedParams=TRUE;\n",qPrint(name())); m_impl->hasDocumentedParams = TRUE; } else if (!m_impl->hasDocumentedParams) @@ -3981,7 +3901,7 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn allDoc = !a.docs.isEmpty(); } //printf("a->type=%s a->name=%s doc=%s\n", - // a->type.data(),a->name.data(),a->docs.data()); + // qPrint(a->type),qPrint(a->name),qPrint(a->docs)); } if (!allDoc && declAl.empty()) // try declaration arguments as well { @@ -3995,19 +3915,19 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn { allDoc = !a.docs.isEmpty(); } - //printf("a->name=%s doc=%s\n",a->name.data(),a->docs.data()); + //printf("a->name=%s doc=%s\n",qPrint(a->name),qPrint(a->docs)); } } } if (allDoc) { - //printf("%s:hasDocumentedParams=TRUE;\n",name().data()); + //printf("%s:hasDocumentedParams=TRUE;\n",qPrint(name())); m_impl->hasDocumentedParams = TRUE; } } //printf("Member %s hasDocumentedReturnType=%d hasReturnCommand=%d\n", - // name().data(),m_impl->hasDocumentedReturnType,hasReturnCommand); + // qPrint(name()),m_impl->hasDocumentedReturnType,hasReturnCommand); if (!m_impl->hasDocumentedReturnType && // docs not yet found hasReturnCommand) { @@ -4024,7 +3944,7 @@ void MemberDefImpl::detectUndocumentedParams(bool hasParamCommand,bool hasReturn ) { warn_doc_error(getDefFileName(),getDefLine(),"documented empty return type of %s", - qualifiedName().data()); + qPrint(qualifiedName())); } else if ( // see if return needs to documented m_impl->hasDocumentedReturnType || @@ -4159,20 +4079,24 @@ void MemberDefImpl::setAnchor() buf[19]='\0'; memAnchor.prepend(buf); } + if (!m_impl->requiresClause.isEmpty()) + { + memAnchor+=" "+m_impl->requiresClause; + } // convert to md5 hash uchar md5_sig[16]; - QCString sigStr(33); + char sigStr[33]; MD5Buffer((const unsigned char *)memAnchor.data(),memAnchor.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.rawData(),33); - m_impl->anc = "a"+sigStr; + MD5SigToString(md5_sig,sigStr); + m_impl->anc = QCString("a")+sigStr; } void MemberDefImpl::setGroupDef(const GroupDef *gd,Grouping::GroupPri_t pri, const QCString &fileName,int startLine, bool hasDocs,MemberDef *member) { - //printf("%s MemberDefImpl::setGroupDef(%s)\n",name().data(),gd->name().data()); + //printf("%s MemberDefImpl::setGroupDef(%s)\n",qPrint(name()),qPrint(gd->name())); m_impl->group=gd; m_impl->grouppri=pri; m_impl->groupFileName=fileName; @@ -4182,7 +4106,7 @@ void MemberDefImpl::setGroupDef(const GroupDef *gd,Grouping::GroupPri_t pri, m_isLinkableCached = 0; } -void MemberDefImpl::setEnumScope(MemberDef *md,bool livesInsideEnum) +void MemberDefImpl::setEnumScope(const MemberDef *md,bool livesInsideEnum) { m_impl->enumScope=md; m_impl->livesInsideEnum=livesInsideEnum; @@ -4214,7 +4138,7 @@ void MemberDefImpl::setNamespace(const NamespaceDef *nd) MemberDefMutable *MemberDefImpl::createTemplateInstanceMember( const ArgumentList &formalArgs,const std::unique_ptr<ArgumentList> &actualArgs) const { - //printf(" Member %s %s %s\n",typeString(),name().data(),argsString()); + //printf(" Member %s %s %s\n",typeString(),qPrint(name()),argsString()); std::unique_ptr<ArgumentList> actualArgList = std::make_unique<ArgumentList>(m_impl->defArgList); if (!m_impl->defArgList.empty()) { @@ -4256,7 +4180,7 @@ MemberDefMutable *MemberDefImpl::createTemplateInstanceMember( bool MemberDefImpl::hasOneLineInitializer() const { //printf("%s: init=%s, initLines=%d maxInitLines=%d userInitLines=%d\n", - // name().data(),m_impl->initializer.data(),m_impl->initLines, + // qPrint(name()),qPrint(m_impl->initializer),m_impl->initLines, // m_impl->maxInitLines,m_impl->userInitLines); return !m_impl->initializer.isEmpty() && m_impl->initLines==0 && // one line initializer ((m_impl->maxInitLines>0 && m_impl->userInitLines==-1) || m_impl->userInitLines>0); // enabled by default or explicitly @@ -4272,7 +4196,7 @@ bool MemberDefImpl::hasMultiLineInitializer() const ); } -void MemberDefImpl::setInitializer(const char *initializer) +void MemberDefImpl::setInitializer(const QCString &initializer) { m_impl->initializer=initializer; int l=m_impl->initializer.length(); @@ -4280,7 +4204,7 @@ void MemberDefImpl::setInitializer(const char *initializer) while (p>=0 && isspace((uchar)m_impl->initializer.at(p))) p--; m_impl->initializer=m_impl->initializer.left(p+1); m_impl->initLines=m_impl->initializer.contains('\n'); - //printf("%s::setInitializer(%s)\n",name().data(),m_impl->initializer.data()); + //printf("%s::setInitializer(%s)\n",qPrint(name()),qPrint(m_impl->initializer)); } void MemberDefImpl::addListReference(Definition *) @@ -4347,7 +4271,7 @@ const MemberList *MemberDefImpl::getSectionList(const Definition *container) con void MemberDefImpl::setSectionList(const Definition *container,const MemberList *sl) { - //printf("MemberDefImpl::setSectionList(%s,%p) name=%s\n",d->name().data(),sl,name().data()); + //printf("MemberDefImpl::setSectionList(%s,%p) name=%s\n",qPrint(d->name()),sl,qPrint(name())); m_impl->sectionMap.insert(std::make_pair(container,sl)); } @@ -4362,7 +4286,7 @@ Specifier MemberDefImpl::virtualness(int count) const return Normal; } Specifier v = m_impl->virt; - MemberDef *rmd = reimplements(); + const MemberDef *rmd = reimplements(); while (rmd && v==Normal) { v = rmd->virtualness(count+1)==Normal ? Normal : Virtual; @@ -4371,7 +4295,7 @@ Specifier MemberDefImpl::virtualness(int count) const return v; } -void MemberDefImpl::writeTagFile(FTextStream &tagFile) const +void MemberDefImpl::writeTagFile(TextStream &tagFile) const { if (!isLinkableInProject()) return; tagFile << " <member kind=\""; @@ -4411,45 +4335,39 @@ void MemberDefImpl::writeTagFile(FTextStream &tagFile) const { tagFile << "\" static=\"yes"; } - tagFile << "\">" << endl; + tagFile << "\">\n"; if (typeString()!=QCString("@")) { - tagFile << " <type>" << convertToXML(typeString()) << "</type>" << endl; + tagFile << " <type>" << convertToXML(typeString()) << "</type>\n"; } - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <anchorfile>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>" << endl; - tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>" << endl; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <anchorfile>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>\n"; + tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>\n"; QCString idStr = id(); if (!idStr.isEmpty()) { - tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>" << endl; + tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>\n"; } - tagFile << " <arglist>" << convertToXML(argsString()) << "</arglist>" << endl; + tagFile << " <arglist>" << convertToXML(argsString()) << "</arglist>\n"; if (isStrong()) { - MemberList *fmdl=m_impl->enumFields; - if (fmdl) + for (const auto &fmd : m_impl->enumFields) { - MemberListIterator mli(*fmdl); - MemberDef *fmd; - for (mli.toFirst();(fmd=mli.current());++mli) + if (!fmd->isReference()) { - if (!fmd->isReference()) + tagFile << " <enumvalue file=\"" << convertToXML(getOutputFileBase()+Doxygen::htmlFileExtension); + tagFile << "\" anchor=\"" << convertToXML(fmd->anchor()); + idStr = fmd->id(); + if (!idStr.isEmpty()) { - tagFile << " <enumvalue file=\"" << convertToXML(getOutputFileBase()+Doxygen::htmlFileExtension); - tagFile << "\" anchor=\"" << convertToXML(fmd->anchor()); - idStr = fmd->id(); - if (!idStr.isEmpty()) - { - tagFile << "\" clangid=\"" << convertToXML(idStr); - } - tagFile << "\">" << convertToXML(fmd->name()) << "</enumvalue>" << endl; + tagFile << "\" clangid=\"" << convertToXML(idStr); } + tagFile << "\">" << convertToXML(fmd->name()) << "</enumvalue>\n"; } } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </member>" << endl; + tagFile << " </member>\n"; } void MemberDefImpl::_computeIsConstructor() @@ -4543,16 +4461,10 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, { int enumMemCount=0; - MemberList *fmdl=m_impl->enumFields; uint numVisibleEnumValues=0; - if (fmdl) + for (const auto &fmd : m_impl->enumFields) { - MemberListIterator mli(*fmdl); - MemberDef *fmd; - for (mli.toFirst();(fmd=mli.current());++mli) - { - if (fmd->isBriefSectionVisible()) numVisibleEnumValues++; - } + if (fmd->isBriefSectionVisible()) numVisibleEnumValues++; } if (numVisibleEnumValues==0 && !isBriefSectionVisible()) { @@ -4590,11 +4502,12 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, if (numVisibleEnumValues>0 && enumValuesPerLine>0) { typeDecl.docify("{ "); - if (fmdl) + + auto it = m_impl->enumFields.begin(); + if (it!=m_impl->enumFields.end()) { - MemberListIterator mli(*fmdl); - MemberDefMutable *fmd=toMemberDefMutable(mli.current()); - bool fmdVisible = fmd ? fmd->isBriefSectionVisible() : TRUE; + const MemberDef *fmd=*it; + bool fmdVisible = fmd->isBriefSectionVisible(); bool first=true; while (fmd) { @@ -4620,11 +4533,11 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, typeDecl.popGeneratorState(); } - if (fmd->hasDocumentation()) // enum value has docs + MemberDefMutable *fmdm = toMemberDefMutable(fmd); + if (fmdm && fmd->hasDocumentation()) // enum value has docs { - //fmd->_writeTagData(compoundType); - fmd->addToSearchIndex(); - fmd->writeLink(typeDecl,cd,nd,fd,gd); + fmdm->addToSearchIndex(); + fmdm->writeLink(typeDecl,cd,nd,fd,gd); } else // no docs for this enum value { @@ -4642,8 +4555,15 @@ void MemberDefImpl::writeEnumDeclaration(OutputList &typeDecl, } bool prevVisible = fmdVisible; - ++mli; - fmd=toMemberDefMutable(mli.current()); + ++it; + if (it!=m_impl->enumFields.end()) + { + fmd=*it; + } + else + { + fmd=0; + } if (prevVisible) { typeDecl.disable(OutputGenerator::Man); @@ -4679,12 +4599,12 @@ void MemberDefImpl::setTypeConstraints(const ArgumentList &al) m_impl->typeConstraints = al; } -void MemberDefImpl::setType(const char *t) +void MemberDefImpl::setType(const QCString &t) { m_impl->type = t; } -void MemberDefImpl::setAccessorType(ClassDef *cd,const char *t) +void MemberDefImpl::setAccessorType(ClassDef *cd,const QCString &t) { m_impl->accessorClass = cd; m_impl->accessorType = t; @@ -4736,8 +4656,8 @@ bool MemberDefImpl::protectionVisible() const #endif #if 0 -void MemberDefImpl::setInbodyDocumentation(const char *docs, - const char *docFile,int docLine) +void MemberDefImpl::setInbodyDocumentation(const QCString &docs, + const QCString &docFile,int docLine) { m_impl->inbodyDocs = docs; m_impl->inbodyDocs = m_impl->inbodyDocs.stripWhiteSpace(); @@ -4786,7 +4706,7 @@ void MemberDefImpl::setTagInfo(const TagInfo *ti) { if (ti) { - //printf("%s: Setting tag name=%s anchor=%s\n",name().data(),ti->tagName.data(),ti->anchor.data()); + //printf("%s: Setting tag name=%s anchor=%s\n",qPrint(name()),qPrint(ti->tagName),qPrint(ti->anchor)); m_impl->anc=ti->anchor; setReference(ti->tagName); m_impl->explicitOutputFileBase = stripExtension(ti->fileName); @@ -4810,37 +4730,37 @@ QCString MemberDefImpl::objCMethodName(bool localLink,bool showStatic) const return qm; } -const char *MemberDefImpl::declaration() const +QCString MemberDefImpl::declaration() const { return m_impl->decl; } -const char *MemberDefImpl::definition() const +QCString MemberDefImpl::definition() const { return m_impl->def; } -const char *MemberDefImpl::extraTypeChars() const +QCString MemberDefImpl::extraTypeChars() const { return m_impl->extraTypeChars; } -const char *MemberDefImpl::typeString() const +QCString MemberDefImpl::typeString() const { return m_impl->type; } -const char *MemberDefImpl::argsString() const +QCString MemberDefImpl::argsString() const { return m_impl->args; } -const char *MemberDefImpl::excpString() const +QCString MemberDefImpl::excpString() const { return m_impl->exception; } -const char *MemberDefImpl::bitfieldString() const +QCString MemberDefImpl::bitfieldString() const { return m_impl->bitfields; } @@ -4875,12 +4795,12 @@ const NamespaceDef* MemberDefImpl::getNamespaceDef() const return m_impl->nspace; } -const char *MemberDefImpl::getReadAccessor() const +QCString MemberDefImpl::getReadAccessor() const { return m_impl->read; } -const char *MemberDefImpl::getWriteAccessor() const +QCString MemberDefImpl::getWriteAccessor() const { return m_impl->write; } @@ -4895,7 +4815,7 @@ Grouping::GroupPri_t MemberDefImpl::getGroupPri() const return m_impl->grouppri; } -const char *MemberDefImpl::getGroupFileName() const +QCString MemberDefImpl::getGroupFileName() const { return m_impl->groupFileName; } @@ -5150,6 +5070,11 @@ bool MemberDefImpl::isStrong() const return (m_impl->memSpec&Entry::Strong)!=0; } +bool MemberDefImpl::isEnumStruct() const +{ + return (m_impl->memSpec&Entry::EnumStruct)!=0; +} + bool MemberDefImpl::isStrongEnumValue() const { return m_impl->mtype==MemberType_EnumValue && @@ -5297,7 +5222,7 @@ bool MemberDefImpl::isConstExpr() const return (m_impl->memSpec&Entry::ConstExpr)!=0; } -const MemberList *MemberDefImpl::enumFieldList() const +const MemberList &MemberDefImpl::enumFieldList() const { return m_impl->enumFields; } @@ -5430,7 +5355,7 @@ bool MemberDefImpl::hasReferencesRelation() const return m_impl->hasReferencesRelation; } -MemberDef *MemberDefImpl::templateMaster() const +const MemberDef *MemberDefImpl::templateMaster() const { return m_impl->templateMaster; } @@ -5452,7 +5377,7 @@ QCString MemberDefImpl::getCachedTypedefTemplSpec() const QCString MemberDefImpl::getCachedResolvedTypedef() const { - //printf("MemberDefImpl::getCachedResolvedTypedef()=%s m_impl=%p\n",m_impl->cachedResolvedType.data(),m_impl); + //printf("MemberDefImpl::getCachedResolvedTypedef()=%s m_impl=%p\n",qPrint(m_impl->cachedResolvedType),m_impl); return m_impl->cachedResolvedType; } @@ -5466,7 +5391,7 @@ MemberDef *MemberDefImpl::memberDeclaration() const return m_impl->memDec; } -MemberDef *MemberDefImpl::inheritsDocsFrom() const +const MemberDef *MemberDefImpl::inheritsDocsFrom() const { return m_impl->docProvider; } @@ -5500,7 +5425,7 @@ void MemberDefImpl::setMemberType(MemberType t) m_isLinkableCached = 0; } -void MemberDefImpl::setDefinition(const char *d) +void MemberDefImpl::setDefinition(const QCString &d) { m_impl->def=d; } @@ -5529,7 +5454,7 @@ void MemberDefImpl::mergeMemberSpecifiers(uint64 s) m_impl->memSpec|=s; } -void MemberDefImpl::setBitfields(const char *s) +void MemberDefImpl::setBitfields(const QCString &s) { m_impl->bitfields = QCString(s).simplifyWhiteSpace(); } @@ -5542,12 +5467,12 @@ void MemberDefImpl::setMaxInitLines(int lines) } } -void MemberDefImpl::setReadAccessor(const char *r) +void MemberDefImpl::setReadAccessor(const QCString &r) { m_impl->read=r; } -void MemberDefImpl::setWriteAccessor(const char *w) +void MemberDefImpl::setWriteAccessor(const QCString &w) { m_impl->write=w; } @@ -5569,12 +5494,12 @@ void MemberDefImpl::makeForeign() m_isLinkableCached = 0; } -void MemberDefImpl::setInheritsDocsFrom(MemberDef *md) +void MemberDefImpl::setInheritsDocsFrom(const MemberDef *md) { m_impl->docProvider = md; } -void MemberDefImpl::setArgsString(const char *as) +void MemberDefImpl::setArgsString(const QCString &as) { m_impl->args = as; } @@ -5584,7 +5509,7 @@ void MemberDefImpl::setRelatedAlso(ClassDef *cd) m_impl->relatedAlso=cd; } -void MemberDefImpl::setEnumClassScope(ClassDef *cd) +void MemberDefImpl::setEnumClassScope(const ClassDef *cd) { m_impl->classDef = cd; m_isLinkableCached = 0; @@ -5660,7 +5585,7 @@ MemberDef *MemberDefImpl::fromAnonymousMember() const return m_impl->annMemb; } -void MemberDefImpl::setTemplateMaster(MemberDef *mt) +void MemberDefImpl::setTemplateMaster(const MemberDef *mt) { m_impl->templateMaster=mt; m_isLinkableCached = 0; @@ -5701,12 +5626,12 @@ void MemberDefImpl::setCategory(ClassDef *def) m_impl->category = def; } -MemberDef *MemberDefImpl::categoryRelation() const +const MemberDef *MemberDefImpl::categoryRelation() const { return m_impl->categoryRelation; } -void MemberDefImpl::setCategoryRelation(MemberDef *md) +void MemberDefImpl::setCategoryRelation(const MemberDef *md) { m_impl->categoryRelation = md; } @@ -5721,6 +5646,15 @@ QCString MemberDefImpl::enumBaseType() const return m_impl->enumBaseType; } +void MemberDefImpl::setRequiresClause(const QCString &req) +{ + m_impl->requiresClause = req; +} + +QCString MemberDefImpl::requiresClause() const +{ + return m_impl->requiresClause; +} void MemberDefImpl::cacheTypedefVal(const ClassDef*val, const QCString & templSpec, const QCString &resolvedType) { @@ -5728,10 +5662,10 @@ void MemberDefImpl::cacheTypedefVal(const ClassDef*val, const QCString & templSp m_impl->cachedTypedefValue=val; m_impl->cachedTypedefTemplSpec=templSpec; m_impl->cachedResolvedType=resolvedType; - //printf("MemberDefImpl::cacheTypedefVal=%s m_impl=%p\n",m_impl->cachedResolvedType.data(),m_impl); + //printf("MemberDefImpl::cacheTypedefVal=%s m_impl=%p\n",qPrint(m_impl->cachedResolvedType),m_impl); } -void MemberDefImpl::copyArgumentNames(MemberDef *bmd) +void MemberDefImpl::copyArgumentNames(const MemberDef *bmd) { { const ArgumentList &srcAl = bmd->argumentList(); @@ -5857,15 +5791,15 @@ static void transferArgumentDocumentation(ArgumentList &decAl,ArgumentList &defA void combineDeclarationAndDefinition(MemberDefMutable *mdec,MemberDefMutable *mdef) { - //printf("mdec=%s isPrototype()=%d\n",mdec->name().data(),mdec->isPrototype()); + //printf("mdec=%s isPrototype()=%d\n",qPrint(mdec->name()),mdec->isPrototype()); if ( (mdef->isFunction() && !mdef->isStatic() && !mdef->isPrototype()) || (mdef->isVariable() && !mdef->isExternal() && !mdef->isStatic()) ) { //printf("mdef=(%p,%s) mdec=(%p,%s)\n", - // mdef, mdef ? mdef->name().data() : "", - // mdec, mdec ? mdec->name().data() : ""); + // mdef, mdef ? qPrint(mdef->name()) : "", + // mdec, mdec ? qPrint(mdec->name()) : ""); ArgumentList &mdefAl = const_cast<ArgumentList&>(mdef->argumentList()); ArgumentList &mdecAl = const_cast<ArgumentList&>(mdec->argumentList()); @@ -5877,8 +5811,8 @@ void combineDeclarationAndDefinition(MemberDefMutable *mdec,MemberDefMutable *md { //printf("Found member %s: definition in %s (doc='%s') and declaration in %s (doc='%s')\n", // mn->memberName(), - // mdef->getFileDef()->name().data(),mdef->documentation().data(), - // mdec->getFileDef()->name().data(),mdec->documentation().data() + // qPrint(mdef->getFileDef()->name()),qPrint(mdef->documentation()), + // qPrint(mdec->getFileDef()->name()),qPrint(mdec->documentation()) // ); if (Config_getBool(RESOLVE_UNNAMED_PARAMS)) @@ -6063,7 +5997,7 @@ bool MemberDefImpl::isReference() const void addDocCrossReference(MemberDefMutable *src,MemberDefMutable *dst) { if (src==0 || dst==0) return; - //printf("--> addDocCrossReference src=%s,dst=%s\n",src->name().data(),dst->name().data()); + //printf("--> addDocCrossReference src=%s,dst=%s\n",qPrint(src->name()),qPrint(dst->name())); if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types if ((dst->hasReferencedByRelation() || dst->hasCallerGraph()) && src->showInCallGraph() |