📄 memberdef.cpp
字号:
else if (classDef) { return classDef->getOutputFileBase(); } else if (fileDef) { return fileDef->getOutputFileBase(); } else if (nspace) { return nspace->getOutputFileBase(); } warn(m_defFileName,m_defLine, "Warning: Internal inconsistency: member %s does not belong to any" " container!",name().data() ); return "dummy";}//void MemberDef::setScopeDefTemplateArguments(ArgumentList *tal)//{// // copy function arguments (if any)// if (tal)// {// scopeTAL = new ArgumentList;// scopeTAL->setAutoDelete(TRUE);// copyArgumentList(tal,scopeTAL);// }//}////void MemberDef::setMemberDefTemplateArguments(ArgumentList *tal)//{// // copy function arguments (if any)// if (tal)// {// membTAL = new ArgumentList;// membTAL->setAutoDelete(TRUE);// copyArgumentList(tal,membTAL);// }//}void MemberDef::setDefinitionTemplateParameterLists(QList<ArgumentList> *lists){ if (lists) { if (m_defTmpArgLists) delete m_defTmpArgLists; m_defTmpArgLists = copyArgumentLists(lists); }}void MemberDef::writeLink(OutputList &ol,ClassDef *cd,NamespaceDef *nd, FileDef *fd,GroupDef *gd){ Definition *d=0; if (cd) d=cd; else if (nd) d=nd; else if (fd) d=fd; else if (gd) d=gd; if (d==0) { err("Member %s without definition! Please report this bug!\n",name().data()); return; } if (group!=0 && gd==0) // forward link to the group { ol.writeObjectLink(group->getReference(),group->getOutputFileBase(),anchor(),name()); } else // local link { ol.writeObjectLink(d->getReference(),d->getOutputFileBase(),anchor(),name()); }}/*! If this member has an anonymous class/struct/union as its type, then * this method will return the ClassDef that describes this return type. */ClassDef *MemberDef::getClassDefOfAnonymousType() { if (cachedAnonymousType) return cachedAnonymousType; QCString cname; if (getClassDef()!=0) { cname=getClassDef()->name().copy(); } else if (getNamespaceDef()!=0) { cname=getNamespaceDef()->name().copy(); } QCString ltype(type); // strip `static' keyword from ltype if (ltype.left(7)=="static ") ltype=ltype.right(ltype.length()-7); // strip `friend' keyword from ltype if (ltype.left(7)=="friend ") ltype=ltype.right(ltype.length()-7); static QRegExp r("@[0-9]+"); int l,i=r.match(ltype,0,&l); // 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++; while (ir<(int)ltype.length() && (isId(ltype.at(ir)) || ltype.at(ir)==':' || ltype.at(ir)=='@')) ir++; //QCString annName = ltype.mid(i,l); QCString annName = ltype.mid(il,ir-il); // if inside a class or namespace try to prepend the scope name if (!cname.isEmpty() && annName.left(cname.length()+2)!=cname+"::") { QCString ts=stripAnonymousNamespaceScope(cname+"::"+annName); //printf("Member::writeDeclaration: Trying %s\n",ts.data()); annoClassDef=getClass(ts); } // if not found yet, try without scope name if (annoClassDef==0) { QCString ts=stripAnonymousNamespaceScope(annName); //printf("Member::writeDeclaration: Trying %s\n",ts.data()); annoClassDef=getClass(ts); } } cachedAnonymousType = annoClassDef; return annoClassDef;} /*! This methods returns TRUE iff the brief section (also known as * declaration section) is visible in the documentation. */bool MemberDef::isBriefSectionVisible() const{ // only include static members with file/namespace scope if // explicitly enabled in the config file bool visibleIfStatic = !(getClassDef()==0 && isStatic() && !Config_getBool("EXTRACT_STATIC") ); // only include members is the are documented or // HIDE_UNDOC_MEMBERS is NO in the config file bool visibleIfDocumented = (!Config_getBool("HIDE_UNDOC_MEMBERS") || hasDocumentation() || isDocumentedFriendClass() ); // hide members with no detailed description and brief descriptions // explicitly disabled. bool visibleIfEnabled = !(Config_getBool("HIDE_UNDOC_MEMBERS") && documentation().isEmpty() && !Config_getBool("BRIEF_MEMBER_DESC") && !Config_getBool("REPEAT_BRIEF") ); // only include members that are non-private unless EXTRACT_PRIVATE is // set to YES or the member is part of a group bool visibleIfPrivate = (protection()!=Private || Config_getBool("EXTRACT_PRIVATE") || mtype==Friend ); bool visible = visibleIfStatic && visibleIfDocumented && visibleIfEnabled && visibleIfPrivate && !annScope; //printf("MemberDef::isBriefSectionVisible() %d\n",visible); return visible;}void MemberDef::writeDeclaration(OutputList &ol, ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd, bool inGroup ){ //printf("%s MemberDef::writeDeclaration() inGroup=%d\n",name().data(),inGroup); // hide members whose brief section should not be visible if (!isBriefSectionVisible()) return; // write tag file information of this member if (!Config_getString("GENERATE_TAGFILE").isEmpty()) { Doxygen::tagFile << " <member kind=\""; switch (mtype) { case Define: Doxygen::tagFile << "define"; break; case EnumValue: Doxygen::tagFile << "enumvalue"; break; case Property: Doxygen::tagFile << "property"; break; case Variable: Doxygen::tagFile << "variable"; break; case Typedef: Doxygen::tagFile << "typedef"; break; case Enumeration: Doxygen::tagFile << "enumeration"; break; case Function: Doxygen::tagFile << "function"; break; case Signal: Doxygen::tagFile << "signal"; break; case Prototype: Doxygen::tagFile << "prototype"; break; case Friend: Doxygen::tagFile << "friend"; break; case DCOP: Doxygen::tagFile << "dcop"; break; case Slot: Doxygen::tagFile << "slot"; break; } if (prot!=Public) { Doxygen::tagFile << "\" protection=\""; if (prot==Protected) Doxygen::tagFile << "public"; else /* Private */ Doxygen::tagFile << "protected"; } if (virt!=Normal) { Doxygen::tagFile << "\" virtualness=\""; if (virt==Virtual) Doxygen::tagFile << "virtual"; else /* Pure */ Doxygen::tagFile << "pure"; } if (isStatic()) { Doxygen::tagFile << "\" static=\"yes"; } Doxygen::tagFile << "\">" << endl; Doxygen::tagFile << " <type>" << convertToXML(typeString()) << "</type>" << endl; Doxygen::tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; Doxygen::tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>" << endl; Doxygen::tagFile << " <arglist>" << convertToXML(argsString()) << "</arglist>" << endl; writeDocAnchorsToTagFile(); Doxygen::tagFile << " </member>" << endl; } Definition *d=0; ASSERT (cd!=0 || nd!=0 || fd!=0 || gd!=0); // member should belong to something if (cd) d=cd; else if (nd) d=nd; else if (fd) d=fd; else d=gd; QCString cname = d->name(); QCString cfname = d->getOutputFileBase(); HtmlHelp *htmlHelp=0; bool hasHtmlHelp = Config_getBool("GENERATE_HTML") && Config_getBool("GENERATE_HTMLHELP"); if (hasHtmlHelp) htmlHelp = HtmlHelp::getInstance(); // search for the last anonymous scope in the member type ClassDef *annoClassDef=getClassDefOfAnonymousType(); // start a new member declaration ol.startMemberItem((annoClassDef || annMemb || annEnumType) ? 1 : 0); // If there is no detailed description we need to write the anchor here. bool detailsVisible = isDetailedSectionLinkable(); if (!detailsVisible && !annMemb) { QCString doxyName=name().copy(); if (!cname.isEmpty()) doxyName.prepend(cname+"::"); ol.startDoxyAnchor(cfname,cname,anchor(),doxyName); ol.addIndexItem(name(),cname); ol.addIndexItem(cname,name()); if (hasHtmlHelp) { htmlHelp->addIndexItem(cname,name(),cfname,anchor()); } ol.pushGeneratorState(); ol.disable(OutputGenerator::Man); ol.docify("\n"); ol.popGeneratorState(); } //printf("member name=%s indDepth=%d\n",name().data(),indDepth); if (annoClassDef || annMemb) { int j; for (j=0;j<indDepth;j++) { ol.writeNonBreakableSpace(3); } } if (tArgList) { writeTemplatePrefix(ol,tArgList); //ol.lineBreak(); } QCString ltype(type); if (mtype==Typedef) ltype.prepend("typedef "); // strip `static' keyword from ltype if (ltype.left(7)=="static ") ltype=ltype.right(ltype.length()-7); // strip `friend' keyword from ltype if (ltype.left(7)=="friend ") ltype=ltype.right(ltype.length()-7); static QRegExp r("@[0-9]+"); int l,i=r.match(ltype,0,&l); if (i!=-1) // member has an anonymous type { //printf("annoClassDef=%p annMemb=%p scopeName=`%s' anonymous=`%s'\n", // annoClassDef,annMemb,cname.data(),ltype.mid(i,l).data()); if (annoClassDef) // type is an anonymous compound { int ir=i+l; annoClassDef->writeDeclaration(ol,annMemb,inGroup); ol.startMemberItem(2); int j; for (j=0;j<indDepth;j++) { ol.writeNonBreakableSpace(3); } QCString varName=ltype.right(ltype.length()-ir).stripWhiteSpace(); //printf(">>>>>> indDepth=%d ltype=`%s' varName=`%s'\n",indDepth,ltype.data(),varName.data()); ol.docify("}"); if (varName.isEmpty() && (name().isEmpty() || name().at(0)=='@')) { ol.docify(";"); } } else { if (getAnonymousEnumType()) // type is an anonymous enum { linkifyText(TextGeneratorOLImpl(ol),cname,name(),ltype.left(i),TRUE); ol+=*getAnonymousEnumType()->enumDecl(); linkifyText(TextGeneratorOLImpl(ol),cname,name(),ltype.right(ltype.length()-i-l),TRUE); } else { ltype = ltype.left(i) + " { ... } " + ltype.right(ltype.length()-i-l); linkifyText(TextGeneratorOLImpl(ol),cname,name(),ltype,TRUE); } } } else { linkifyText(TextGeneratorOLImpl(ol),cname,name(),ltype,TRUE); } bool htmlOn = ol.isEnabled(OutputGenerator::Html); if (htmlOn && Config_getBool("HTML_ALIGN_MEMBERS") && !ltype.isEmpty()) { ol.disable(OutputGenerator::Html); } if (!ltype.isEmpty()) ol.docify(" "); if (htmlOn) { ol.enable(OutputGenerator::Html); } if (annMemb) { ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); ol.writeNonBreakableSpace(3); ol.popGeneratorState(); } else { ol.insertMemberAlign(); } // write name if (!name().isEmpty() && name().at(0)!='@') { //printf("Member name=`%s gd=%p md->groupDef=%p inGroup=%d isLinkable()=%d\n",name().data(),gd,getGroupDef(),inGroup,isLinkable()); if (isLinkable()) { if (annMemb) { //printf("anchor=%s ann_anchor=%s\n",anchor(),annMemb->anchor()); annMemb->writeLink(ol, annMemb->getClassDef(), annMemb->getNamespaceDef(), annMemb->getFileDef(), annMemb->getGroupDef() ); annMemb->annUsed=annUsed=TRUE; } else { //printf("writeLink %s->%d\n",name.data(),hasDocumentation()); writeLink(ol,cd,nd,fd,gd); } } else if (isDocumentedFriendClass()) // if the member is an undocumented friend declaration for some class, // then maybe we can link to the class { writeLink(ol,getClass(name()),0,0,0); } else // there is a brief member description and brief member // descriptions are enabled or there is no detailed description. { if (annMemb) annMemb->annUsed=annUsed=TRUE; ol.startBold(); ol.docify(name()); ol.endBold(); } } if (argsString()) { if (!isDefine()) ol.writeString(" "); //ol.docify(argsString()); linkifyText(TextGeneratorOLImpl(ol),cname,name(),argsString()); } if (excpString()) { ol.writeString(" "); ol.docify(excpString()); } if (!bitfields.isEmpty()) // add bitfields { linkifyText(TextGeneratorOLImpl(ol),cname,name(),bitfields.simplifyWhiteSpace()); } else if (hasOneLineInitializer() //!init.isEmpty() && initLines==0 && // one line initializer //((maxInitLines>0 && userInitLines==-1) || userInitLines>0) // enabled by default or explicitly ) // add initializer { if (!isDefine()) { ol.writeString(" = "); linkifyText(TextGeneratorOLImpl(ol),cname,name(),init.simplifyWhiteSpace()); } else { ol.writeNonBreakableSpace(3); linkifyText(TextGeneratorOLImpl(ol),cname,name(),init); } } if (!detailsVisible && !annMemb) { ol.endDoxyAnchor(cfname,anchor()); } ol.endMemberItem((annoClassDef!=0 && indDepth==0) || annEnumType); //ol.endMemberItem(gId!=-1,gFile,gHeader,annoClassDef || annMemb); // write brief description
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -