⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memberdef.cpp

📁 doxygen(一个自动从源代码生成文档的工具)的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/****************************************************************************** * *  * * Copyright (C) 1997-2001 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby  * granted. No representations are made about the suitability of this software  * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */#include <stdio.h>#include <qregexp.h>#include "memberdef.h"#include "membername.h"#include "doxygen.h"#include "util.h"#include "code.h"#include "message.h"#include "htmlhelp.h"#include "language.h"#include "outputlist.h"#include "example.h"#include "membergroup.h"#include "doc.h"#include "groupdef.h"#include "defargs.h"//#include "xml.h"//-----------------------------------------------------------------------------static QCString addTemplateNames(const QCString &s,const QCString &n,const QCString &t){  QCString result;  QCString clRealName=n;  int p=0,i;  if ((i=clRealName.find('<'))!=-1)  {    clRealName=clRealName.left(i); // strip template specialization  }  if ((i=clRealName.findRev("::"))!=-1)  {    clRealName=clRealName.right(clRealName.length()-i-2);  }  while ((i=s.find(clRealName,p))!=-1)  {    result+=s.mid(p,i-p);    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());      result+=clRealName+t;     }    else     { // template names already present      //printf("Adding %s\n",clRealName.data());      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());  return result;}static void writeDefArgumentList(OutputList &ol,ClassDef *cd,                                 const QCString &scopeName,MemberDef *md){  ArgumentList *argList=md->argumentList();  if (argList==0) return; // member has no function like argument list  if (!md->isDefine()) ol.docify(" ");  ol.pushGeneratorState();  ol.disableAllBut(OutputGenerator::Html);  ol.endMemberDocName();  ol.startParameterList();   ol.enableAll();  ol.disable(OutputGenerator::Html);  ol.docify("("); // start argument list  ol.endMemberDocName();  ol.popGeneratorState();  //printf("===> name=%s isDefine=%d\n",md->name().data(),md->isDefine());  Argument *a=argList->first();  QCString cName;  //if (md->scopeDefTemplateArguments())  //{  //  cName=tempArgListToString(md->scopeDefTemplateArguments());  //}  if (cd)  {    cName=cd->name();    int il=cName.find('<');    int ir=cName.findRev('>');    if (il!=-1 && ir!=-1 && ir>il)    {      cName=cName.mid(il,ir-il+1);      //printf("1. cName=%s\n",cName.data());    }    else if (cd->templateArguments())    {      cName=tempArgListToString(cd->templateArguments());       //printf("2. cName=%s\n",cName.data());    }    else // no template specifier    {      cName.resize(0);    }  }  //printf("~~~ %s cName=%s\n",md->name().data(),cName.data());  //if (!md->isDefine()) ol.startParameter(TRUE); else ol.docify(" ");  bool first=TRUE;  while (a)  {    if (md->isDefine() || first) ol.startParameterType(first);    QRegExp re(")(");    int vp;    if (!a->attrib.isEmpty()) // argument has an IDL attribute    {      ol.docify(a->attrib+" ");    }    if ((vp=a->type.find(re))!=-1) // argument type is a function pointer    {      QCString n=a->type.left(vp);      if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);      linkifyText(TextGeneratorOLImpl(ol),scopeName,md->name(),n);    }    else // non-function pointer type    {      QCString n=a->type;      if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);      linkifyText(TextGeneratorOLImpl(ol),scopeName,md->name(),n);    }    if (!md->isDefine())    {      ol.endParameterType();      ol.startParameterName(argList->count()<2);    }    if (!a->name.isEmpty()) // argument has a name    {       ol.docify(" ");      ol.disable(OutputGenerator::Man);      ol.startEmphasis();      ol.enable(OutputGenerator::Man);      ol.docify(a->name);      ol.disable(OutputGenerator::Man);      ol.endEmphasis();      ol.enable(OutputGenerator::Man);    }    if (!a->array.isEmpty())    {      ol.docify(a->array);    }    if (vp!=-1) // write the part of the argument type                 // that comes after the name    {      linkifyText(TextGeneratorOLImpl(ol),scopeName,                  md->name(),a->type.right(a->type.length()-vp));    }    if (!a->defval.isEmpty()) // write the default value    {      QCString n=a->defval;      if (!cName.isEmpty()) n=addTemplateNames(n,cd->name(),cName);      ol.docify(" = ");      linkifyText(TextGeneratorOLImpl(ol),scopeName,md->name(),n);     }    a=argList->next();    if (a)     {      ol.docify(", "); // there are more arguments      if (!md->isDefine())       {        ol.endParameterName(FALSE,FALSE);        ol.startParameterType(FALSE);      }    }    first=FALSE;  }  ol.pushGeneratorState();  ol.disable(OutputGenerator::Html);  //if (!first) ol.writeString("&nbsp;");  ol.docify(")"); // end argument list  ol.enableAll();  ol.disableAllBut(OutputGenerator::Html);  if (!md->isDefine())   {    if (first) ol.startParameterName(argList->count()<2);    ol.endParameterName(TRUE,argList->count()<2);  }  else   {    ol.endParameterType();    ol.startParameterName(TRUE);    ol.endParameterName(TRUE,TRUE);  }  ol.popGeneratorState();  if (argList->constSpecifier)  {    ol.docify(" const");  }  if (argList->volatileSpecifier)  {    ol.docify(" volatile");  }}static void writeTemplatePrefix(OutputList &ol,ArgumentList *al){  ol.docify("template<");  Argument *a=al->first();  while (a)  {    ol.docify(a->type);    ol.docify(" ");    ol.docify(a->name);    if (a->defval.length()!=0)    {      ol.docify(" = ");      ol.docify(a->defval);    }     a=al->next();    if (a) ol.docify(", ");  }  ol.docify("> ");}//-----------------------------------------------------------------------------/*! Creates a new member definition. * * \param df File containing the definition of this member. * \param dl Line at which the member definition was found. * \param t  A string representing the type of the member. * \param na A string representing the name of the member. * \param a  A string representing the arguments of the member. * \param e  A string representing the throw clause of the members. * \param p  The protection context of the member, possible values are: *           \c Public, \c Protected, \c Private. * \param v  The degree of `virtualness' of the member, possible values are: *           \c Normal, \c Virtual, \c Pure. * \param s  A boolean that is true iff the member is static. * \param r  A boolean that is true iff the member is only related. * \param mt The kind of member. See #MemberDef::MemberType for a list of  *           all types. * \param tal The template arguments of this member. * \param al  The arguments of this member. This is a structured form of  *            the string past as argument \a a. */MemberDef::MemberDef(const char *df,int dl,                     const char *t,const char *na,const char *a,const char *e,                     Protection p,Specifier v,bool s,bool r,MemberType mt,                     const ArgumentList *tal,const ArgumentList *al                    ) : Definition(df,dl,na){  //printf("++++++ MemberDef(%s file=%s,line=%d static=%d) ++++++ \n",na,df,dl,s);  classDef=0;  fileDef=0;  redefines=0;  redefinedBy=0;  nspace=0;  memDef=0;  memDec=0;  group=0;  grpId=-1;  exampleSDict=0;  enumFields=0;  enumScope=0;  enumDeclList=0;  //scopeTAL=0;  //membTAL=0;  m_defTmpArgLists=0;  initLines=0;  type=t;  if (mt==Typedef && type.left(8)=="typedef ") type=type.mid(8);  if (type.left(7)=="struct ") type=type.right(type.length()-7);  if (type.left(6)=="class " ) type=type.right(type.length()-6);  if (type.left(6)=="union " ) type=type.right(type.length()-6);  type=removeRedundantWhiteSpace(type);  args=a;  args=removeRedundantWhiteSpace(args);  if (type.isEmpty()) decl=name()+args; else decl=type+" "+name()+args;  //declLine=0;  memberGroup=0;  virt=v;  prot=p;  related=r;  stat=s;  mtype=mt;  exception=e;  proto=FALSE;  annScope=FALSE;  memSpec=FALSE;  annMemb=0;  annUsed=FALSE;  annShown=FALSE;  annEnumType=0;  indDepth=0;  section=0;  bodyMemb=0;  explExt=FALSE;  cachedAnonymousType=0;  maxInitLines=Config_getInt("MAX_INITIALIZER_LINES");  userInitLines=-1;  docEnumValues=FALSE;  // copy function template arguments (if any)  if (tal)  {    tArgList = new ArgumentList;    tArgList->setAutoDelete(TRUE);    ArgumentListIterator ali(*tal);    Argument *a;    for (;(a=ali.current());++ali)    {      tArgList->append(new Argument(*a));    }  }  else  {    tArgList=0;  }  // copy function arguments (if any)  if (al)  {    argList = new ArgumentList;    argList->setAutoDelete(TRUE);    ArgumentListIterator ali(*al);    Argument *a;    for (;(a=ali.current());++ali)    {      argList->append(new Argument(*a));    }    argList->constSpecifier    = al->constSpecifier;    argList->volatileSpecifier = al->volatileSpecifier;    argList->pureSpecifier     = al->pureSpecifier;  }  else  {    argList=0;  }  m_templateMaster=0;}/*! Destroys the member definition. */MemberDef::~MemberDef(){  delete redefinedBy;  delete exampleSDict;  delete enumFields;  delete argList;  delete tArgList;  delete m_defTmpArgLists;}void MemberDef::setReimplements(MemberDef *md)   {   if (m_templateMaster)   {    m_templateMaster->setReimplements(md);  }  else  {    redefines=md;   }}void MemberDef::insertReimplementedBy(MemberDef *md){  if (m_templateMaster)  {    m_templateMaster->insertReimplementedBy(md);  }  else  {    if (redefinedBy==0) redefinedBy = new MemberList;    redefinedBy->inSort(md);  }}void MemberDef::insertEnumField(MemberDef *md){  if (enumFields==0) enumFields=new MemberList;  enumFields->append(md);}bool MemberDef::addExample(const char *anchor,const char *nameStr,                           const char *file){  //printf("%s::addExample(%s,%s,%s)\n",name.data(),anchor,nameStr,file);  if (exampleSDict==0) exampleSDict = new ExampleSDict;  if (exampleSDict->find(nameStr)==0)   {    //printf("Add reference to example %s to member %s\n",nameStr,name.data());    Example *e=new Example;    e->anchor=anchor;    e->name=nameStr;    e->file=file;    exampleSDict->inSort(nameStr,e);    return TRUE;  }  return FALSE; }bool MemberDef::hasExamples(){  if (exampleSDict==0)     return FALSE;  else    return exampleSDict->count()>0;}QCString MemberDef::getOutputFileBase() const{  if (m_templateMaster)  {    return m_templateMaster->getOutputFileBase();  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -