Doxygen
definition.cpp 文件参考
#include <algorithm>
#include <iterator>
#include <unordered_map>
#include <string>
#include <ctype.h>
#include "md5.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "regex.h"
#include "config.h"
#include "definitionimpl.h"
#include "doxygen.h"
#include "language.h"
#include "message.h"
#include "portable.h"
#include "outputlist.h"
#include "code.h"
#include "util.h"
#include "groupdef.h"
#include "pagedef.h"
#include "section.h"
#include "htags.h"
#include "parserintf.h"
#include "debug.h"
#include "vhdldocgen.h"
#include "memberlist.h"
#include "namespacedef.h"
#include "filedef.h"
#include "dirdef.h"
#include "bufstr.h"
#include "reflist.h"
#include "utf8.h"
+ definition.cpp 的引用(Include)关系图:

浏览源代码.

class  DefinitionImpl::IMPL
 Private data associated with a Symbol DefinitionImpl object. 更多...
 
struct  FilterCacheItem
 
class  FilterCache
 

函数

static bool matchExcludedSymbols (const QCString &name)
 
static void addToMap (const QCString &name, Definition *d)
 
static void removeFromMap (const QCString &name, Definition *d)
 
bool readCodeFragment (const QCString &fileName, int &startLine, int &endLine, QCString &result)
 Reads a fragment from file fileName starting with line startLine and ending with line endLine. 更多...
 
static MemberVector refMapToVector (const std::unordered_map< std::string, const MemberDef * > &map)
 
static bool stripWord (QCString &s, QCString w)
 
static QCString abbreviate (const QCString &s, const QCString &name)
 
DefinitiontoDefinition (DefinitionMutable *dm)
 
DefinitionMutabletoDefinitionMutable (Definition *d)
 
DefinitionMutabletoDefinitionMutable (const Definition *d)
 

变量

static FilterCache g_filterCache
 

函数说明

◆ abbreviate()

static QCString abbreviate ( const QCString s,
const QCString name 
)
static

在文件 definition.cpp1592 行定义.

1593 {
1594  QCString scopelessName=name;
1595  int i=scopelessName.findRev("::");
1596  if (i!=-1) scopelessName=scopelessName.mid(i+2);
1597  QCString result=s;
1598  result=result.stripWhiteSpace();
1599  // strip trailing .
1600  if (!result.isEmpty() && result.at(result.length()-1)=='.')
1601  result=result.left(result.length()-1);
1602 
1603  // strip any predefined prefix
1604  const StringVector &briefDescAbbrev = Config_getList(ABBREVIATE_BRIEF);
1605  for (const auto &p : briefDescAbbrev)
1606  {
1607  QCString str = substitute(p.c_str(),"$name",scopelessName); // replace $name with entity name
1608  str += " ";
1609  stripWord(result,str);
1610  }
1611 
1612  // capitalize first word
1613  if (!result.isEmpty())
1614  {
1615  char c=result[0];
1616  if (c>='a' && c<='z') c+='A'-'a';
1617  result[0]=c;
1618  }
1619  return result;
1620 }

引用了 QCString::at(), Config_getList, QCString::findRev(), QCString::isEmpty(), QCString::left(), QCString::length(), QCString::mid(), DefinitionImpl::name(), QCString::stripWhiteSpace(), stripWord() , 以及 substitute().

被这些函数引用 DefinitionImpl::briefDescription(), DefinitionMixin< DirDef >::briefDescription() , 以及 DefinitionAliasMixin< ConceptDef >::briefDescription().

◆ addToMap()

static void addToMap ( const QCString name,
Definition d 
)
static

在文件 definition.cpp203 行定义.

204 {
205  bool vhdlOpt = Config_getBool(OPTIMIZE_OUTPUT_VHDL);
206  QCString symbolName = name;
207  int index=computeQualifiedIndex(symbolName);
208  if (!vhdlOpt && index!=-1) symbolName=symbolName.mid(index+2);
209  if (!symbolName.isEmpty())
210  {
211  Doxygen::symbolMap->add(symbolName,d);
212 
213  d->_setSymbolName(symbolName);
214  }
215 }

引用了 Definition::_setSymbolName(), SymbolMap< T >::add(), computeQualifiedIndex(), Config_getBool, QCString::isEmpty(), QCString::mid(), DefinitionImpl::name(), Doxygen::symbolMap , 以及 DefinitionImpl::symbolName().

被这些函数引用 DefinitionImpl::DefinitionImpl() , 以及 DefinitionAliasImpl::init().

◆ matchExcludedSymbols()

static bool matchExcludedSymbols ( const QCString name)
static

在文件 definition.cpp148 行定义.

149 {
150  const StringVector &exclSyms = Config_getList(EXCLUDE_SYMBOLS);
151  if (exclSyms.empty()) return FALSE; // nothing specified
152  std::string symName = name.str();
153  for (const auto &pat : exclSyms)
154  {
155  QCString pattern = pat.c_str();
156  bool forceStart=FALSE;
157  bool forceEnd=FALSE;
158  if (pattern.at(0)=='^')
159  pattern=pattern.mid(1),forceStart=TRUE;
160  if (pattern.at(pattern.length()-1)=='$')
161  pattern=pattern.left(pattern.length()-1),forceEnd=TRUE;
162  if (pattern.find('*')!=-1) // wildcard mode
163  {
164  const reg::Ex re(substitute(pattern,"*",".*").str());
166  if (reg::search(symName,match,re)) // wildcard match
167  {
168  size_t ui = match.position();
169  size_t pl = match.length();
170  size_t sl = symName.length();
171  if ((ui==0 || pattern.at(0)=='*' || (!isId(symName.at(ui-1)) && !forceStart)) &&
172  (ui+pl==sl || pattern.at(pattern.length()-1)=='*' || (!isId(symName.at(ui+pl)) && !forceEnd))
173  )
174  {
175  //printf("--> name=%s pattern=%s match at %d\n",qPrint(symName),qPrint(pattern),i);
176  return TRUE;
177  }
178  }
179  }
180  else if (!pattern.isEmpty()) // match words
181  {
182  size_t i = symName.find(pattern.str());
183  if (i!=std::string::npos) // we have a match!
184  {
185  size_t ui=i;
186  size_t pl=pattern.length();
187  size_t sl=symName.length();
188  // check if it is a whole word match
189  if ((ui==0 || (!isId(symName.at(ui-1)) && !forceStart)) &&
190  (ui+pl==sl || (!isId(symName.at(ui+pl)) && !forceEnd))
191  )
192  {
193  //printf("--> name=%s pattern=%s match at %d\n",qPrint(symName),qPrint(pattern),i);
194  return TRUE;
195  }
196  }
197  }
198  }
199  //printf("--> name=%s: no match\n",name);
200  return FALSE;
201 }

引用了 QCString::at(), Config_getList, FALSE, QCString::find(), QCString::isEmpty(), isId(), QCString::left(), QCString::length(), reg::match(), QCString::mid(), DefinitionImpl::name(), reg::search(), QCString::str(), substitute() , 以及 TRUE.

被这些函数引用 DefinitionImpl::DefinitionImpl().

◆ readCodeFragment()

bool readCodeFragment ( const QCString fileName,
int &  startLine,
int &  endLine,
QCString result 
)

Reads a fragment from file fileName starting with line startLine and ending with line endLine.

Reads a fragment of code from file fileName starting at line startLine and ending at line endLine (inclusive). The fragment is stored in result. If FALSE is returned the code fragment could not be found.

The file is scanned for a opening bracket ('{') from startLine onward The line actually containing the bracket is returned via startLine. The file is scanned for a closing bracket ('}') from endLine backward. The line actually containing the bracket is returned via endLine. Note that for VHDL code the bracket search is not done.

在文件 definition.cpp719 行定义.

721 {
722  //printf("readCodeFragment(%s,startLine=%d,endLine=%d)\n",fileName,startLine,endLine);
723  static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
724  QCString filter = getFileFilter(fileName,TRUE);
725  bool usePipe = !filter.isEmpty() && filterSourceFiles;
726  int tabSize = Config_getInt(TAB_SIZE);
727  SrcLangExt lang = getLanguageFromFileName(fileName);
728  const int blockSize = 4096;
729  BufStr str(blockSize);
730  g_filterCache.getFileContents(fileName,str);
731 
732  bool found = lang==SrcLangExt_VHDL ||
733  lang==SrcLangExt_Python ||
734  lang==SrcLangExt_Fortran;
735  // for VHDL, Python, and Fortran no bracket search is possible
736  char *p=str.data();
737  if (p)
738  {
739  char c=0;
740  int col=0;
741  int lineNr=1;
742  // skip until the startLine has reached
743  while (lineNr<startLine && *p)
744  {
745  while ((c=*p++)!='\n' && c!=0) /* skip */;
746  lineNr++;
747  if (found && c == '\n') c = '\0';
748  }
749  if (*p)
750  {
751  // skip until the opening bracket or lonely : is found
752  char cn=0;
753  while (lineNr<=endLine && *p && !found)
754  {
755  int pc=0;
756  while ((c=*p++)!='{' && c!=':' && c!=0)
757  {
758  //printf("parsing char '%c'\n",c);
759  if (c=='\n')
760  {
761  lineNr++,col=0;
762  }
763  else if (c=='\t')
764  {
765  col+=tabSize - (col%tabSize);
766  }
767  else if (pc=='/' && c=='/') // skip single line comment
768  {
769  while ((c=*p++)!='\n' && c!=0) pc=c;
770  if (c=='\n') lineNr++,col=0;
771  }
772  else if (pc=='/' && c=='*') // skip C style comment
773  {
774  while (((c=*p++)!='/' || pc!='*') && c!=0)
775  {
776  if (c=='\n') lineNr++,col=0;
777  pc=c;
778  }
779  }
780  else
781  {
782  col++;
783  }
784  pc = c;
785  }
786  if (c==':')
787  {
788  cn=*p++;
789  if (cn!=':') found=TRUE;
790  }
791  else if (c=='{')
792  {
793  found=TRUE;
794  }
795  }
796  //printf(" -> readCodeFragment(%s,%d,%d) lineNr=%d\n",fileName,startLine,endLine,lineNr);
797  if (found)
798  {
799  // For code with more than one line,
800  // fill the line with spaces until we are at the right column
801  // so that the opening brace lines up with the closing brace
802  if (endLine!=startLine)
803  {
804  QCString spaces;
805  spaces.fill(' ',col);
806  result+=spaces;
807  }
808  // copy until end of line
809  if (c) result+=c;
810  startLine=lineNr;
811  if (c==':')
812  {
813  result+=cn;
814  if (cn=='\n') lineNr++;
815  }
816  char lineStr[blockSize];
817  do
818  {
819  //printf("reading line %d in range %d-%d\n",lineNr,startLine,endLine);
820  int size_read;
821  do
822  {
823  // read up to maxLineLength-1 bytes, the last byte being zero
824  int i=0;
825  while ((c=*p++) && i<blockSize-1)
826  {
827  lineStr[i++]=c;
828  if (c=='\n') break; // stop at end of the line
829  }
830  lineStr[i]=0;
831  size_read=i;
832  result+=lineStr; // append line to the output
833  } while (size_read == (blockSize-1)); // append more if line does not fit in buffer
834  lineNr++;
835  } while (lineNr<=endLine && *p);
836 
837  // strip stuff after closing bracket
838  int newLineIndex = result.findRev('\n');
839  int braceIndex = result.findRev('}');
840  if (braceIndex > newLineIndex)
841  {
842  result.truncate((uint)braceIndex+1);
843  }
844  endLine=lineNr-1;
845  }
846  }
847  if (usePipe)
848  {
849  Debug::print(Debug::FilterOutput, 0, "Filter output\n");
850  Debug::print(Debug::FilterOutput,0,"-------------\n%s\n-------------\n",qPrint(result));
851  }
852  }
853  result = transcodeCharacterStringToUTF8(result);
854  if (!result.isEmpty() && result.at(result.length()-1)!='\n') result += "\n";
855  //printf("readCodeFragment(%d-%d)=%s\n",startLine,endLine,qPrint(result));
856  return found;
857 }

引用了 QCString::at(), Config_getBool, Config_getInt, BufStr::data(), QCString::fill(), Debug::FilterOutput, QCString::findRev(), g_filterCache, FilterCache::getFileContents(), getFileFilter(), getLanguageFromFileName(), QCString::isEmpty(), QCString::length(), Debug::print(), qPrint(), SrcLangExt_Fortran, SrcLangExt_Python, SrcLangExt_VHDL, transcodeCharacterStringToUTF8(), TRUE , 以及 QCString::truncate().

被这些函数引用 VhdlDocGen::createFlowChart(), MemberContext::Private::createSourceCode() , 以及 DefinitionImpl::writeInlineCode().

◆ refMapToVector()

static MemberVector refMapToVector ( const std::unordered_map< std::string, const MemberDef * > &  map)
inlinestatic

在文件 definition.cpp1009 行定义.

1010 {
1011  // convert map to a vector of values
1012  MemberVector result;
1013  std::transform(map.begin(),map.end(), // iterate over map
1014  std::back_inserter(result), // add results to vector
1015  [](const auto &item)
1016  { return item.second; } // extract value to add from map Key,Value pair
1017  );
1018  // and sort it
1019  std::sort(result.begin(),result.end(),
1020  [](const auto &m1,const auto &m2) { return genericCompareMembers(m1,m2)<0; });
1021  return result;
1022 }

引用了 MemberVector::begin() , 以及 MemberVector::end().

被这些函数引用 DefinitionImpl::_writeSourceRefList(), DefinitionImpl::getReferencedByMembers() , 以及 DefinitionImpl::getReferencesMembers().

◆ removeFromMap()

static void removeFromMap ( const QCString name,
Definition d 
)
static

在文件 definition.cpp217 行定义.

218 {
219  Doxygen::symbolMap->remove(name,d);
220 }

引用了 DefinitionImpl::name(), SymbolMap< T >::remove() , 以及 Doxygen::symbolMap.

被这些函数引用 DefinitionAliasImpl::deinit() , 以及 DefinitionImpl::~DefinitionImpl().

◆ stripWord()

static bool stripWord ( QCString s,
QCString  w 
)
static

在文件 definition.cpp1579 行定义.

1580 {
1581  bool success=FALSE;
1582  if (s.left(w.length())==w)
1583  {
1584  success=TRUE;
1585  s=s.right(s.length()-w.length());
1586  }
1587  return success;
1588 }

引用了 FALSE, QCString::left(), QCString::length(), QCString::right() , 以及 TRUE.

被这些函数引用 abbreviate().

◆ toDefinition()

Definition* toDefinition ( DefinitionMutable dm)

◆ toDefinitionMutable() [1/2]

DefinitionMutable* toDefinitionMutable ( const Definition d)

在文件 definition.cpp1962 行定义.

1963 {
1964  return toDefinitionMutable(const_cast<Definition*>(d));
1965 }

引用了 toDefinitionMutable().

◆ toDefinitionMutable() [2/2]

DefinitionMutable* toDefinitionMutable ( Definition d)

变量说明

◆ g_filterCache

FilterCache g_filterCache
static

在文件 definition.cpp703 行定义.

被这些函数引用 readCodeFragment().

StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
MemberVector::end
iterator end()
Definition: memberlist.h:44
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
BufStr
Buffer used to store strings
Definition: bufstr.h:29
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
reg::match
bool match(const std::string &str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition: regex.cpp:729
transcodeCharacterStringToUTF8
QCString transcodeCharacterStringToUTF8(const QCString &input)
Definition: util.cpp:1350
SrcLangExt
SrcLangExt
Language as given by extension
Definition: types.h:41
QCString::str
std::string str() const
Definition: qcstring.h:442
QCString::at
char & at(size_t i)
Returns a reference to the character at index i.
Definition: qcstring.h:477
QCString::find
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:38
g_filterCache
static FilterCache g_filterCache
Definition: definition.cpp:703
Doxygen::symbolMap
static SymbolMap< Definition > * symbolMap
Definition: doxygen.h:106
uint
unsigned uint
Definition: qcstring.h:40
toDefinitionMutable
DefinitionMutable * toDefinitionMutable(Definition *d)
Definition: definition.cpp:1956
QCString::stripWhiteSpace
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition: qcstring.h:243
Config_getInt
#define Config_getInt(name)
Definition: config.h:34
isId
bool isId(int c)
Definition: util.h:172
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
Debug::print
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition: debug.cpp:57
SrcLangExt_Python
@ SrcLangExt_Python
Definition: types.h:52
Debug::FilterOutput
@ FilterOutput
Definition: debug.h:38
computeQualifiedIndex
int computeQualifiedIndex(const QCString &name)
Definition: util.cpp:486
reg::Match
Object representing the matching results.
Definition: regex.h:163
getLanguageFromFileName
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition: util.cpp:5574
TRUE
#define TRUE
Definition: qcstring.h:36
MemberVector
A vector of MemberDef object
Definition: memberlist.h:32
SrcLangExt_Fortran
@ SrcLangExt_Fortran
Definition: types.h:53
SymbolMap::add
void add(const QCString &name, Ptr def)
Add a symbol def into the map under key name
Definition: symbolmap.h:52
QCString::fill
bool fill(char c, int len=-1)
Fills a string with a predefined character
Definition: qcstring.h:175
QCString::truncate
bool truncate(size_t pos)
Truncates the string at position pos.
Definition: qcstring.h:167
SymbolMap::remove
void remove(const QCString &name, Ptr def)
Remove a symbol def from the map that was stored under key name
Definition: symbolmap.h:58
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
substitute
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition: qcstring.cpp:465
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
reg::Ex
Class representing a regular expression.
Definition: regex.h:48
Definition::_setSymbolName
virtual void _setSymbolName(const QCString &name)=0
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
FilterCache::getFileContents
bool getFileContents(const QCString &fileName, BufStr &str)
Definition: definition.cpp:589
DefinitionMutable::toDefinition_
virtual Definition * toDefinition_()=0
SrcLangExt_VHDL
@ SrcLangExt_VHDL
Definition: types.h:54
Definition::toDefinitionMutable_
virtual DefinitionMutable * toDefinitionMutable_()=0
MemberVector::begin
iterator begin()
Definition: memberlist.h:43
reg::search
bool search(const std::string &str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition: regex.cpp:718
stripWord
static bool stripWord(QCString &s, QCString w)
Definition: definition.cpp:1579
getFileFilter
QCString getFileFilter(const QCString &name, bool isSourceCode)
Definition: util.cpp:1315
QCString::right
QCString right(size_t len) const
Definition: qcstring.h:217
Config_getList
#define Config_getList(name)
Definition: config.h:37
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108