Classes | Functions
filedef.cpp File Reference
#include "memberlist.h"
#include "classlist.h"
#include "filedef.h"
#include "doxygen.h"
#include "memberdef.h"
#include "classdef.h"
#include "namespacedef.h"
#include "util.h"
#include "language.h"
#include "outputlist.h"
#include "dot.h"
#include "message.h"
#include "docparser.h"
#include "searchindex.h"
#include "htags.h"
#include "parserintf.h"
#include "portable.h"
#include "vhdldocgen.h"
#include "debug.h"
#include "layout.h"
#include "entry.h"
#include "groupdef.h"
#include "filename.h"
#include "membergroup.h"
#include "dirdef.h"
#include "config.h"
#include "clangparser.h"
#include "settings.h"

Go to the source code of this file.

Classes

class  DevNullCodeDocInterface
 

Functions

static int findMatchingPart (const QCString &path, const QCString dir)
 
static DirectoryfindDirNode (Directory *root, const QCString &name)
 
static void mergeFileDef (Directory *root, FileDef *fd)
 
static void addDirsAsGroups (Directory *root, GroupDef *parent, int level)
 
void generateFileTree ()
 
static void getAllIncludeFilesRecursively (QDict< void > *filesVisited, const FileDef *fd, QStrList &incFiles)
 

Function Documentation

static void addDirsAsGroups ( Directory root,
GroupDef parent,
int  level 
)
static

Definition at line 1633 of file filedef.cpp.

1634 {
1635  GroupDef *gd=0;
1636  if (root->kind()==DirEntry::Dir)
1637  {
1638  gd = new GroupDef("[generated]",
1639  1,
1640  root->path(), // name
1641  root->name() // title
1642  );
1643  if (parent)
1644  {
1645  parent->addGroup(gd);
1646  gd->makePartOfGroup(parent);
1647  }
1648  else
1649  {
1650  Doxygen::groupSDict->append(root->path(),gd);
1651  }
1652  }
1653  QListIterator<DirEntry> dli(root->children());
1654  DirEntry *de;
1655  for (dli.toFirst();(de=dli.current());++dli)
1656  {
1657  if (de->kind()==DirEntry::Dir)
1658  {
1659  addDirsAsGroups((Directory *)de,gd,level+1);
1660  }
1661  }
1662 }
static GroupSDict * groupSDict
Definition: doxygen.h:119
void append(const char *key, const T *d)
Definition: sortdict.h:135
void addGroup(const GroupDef *def)
Definition: groupdef.cpp:532
void makePartOfGroup(GroupDef *gd)
QCString name() const
Definition: filedef.h:292
type * current() const
Definition: qlist.h:146
static void addDirsAsGroups(Directory *root, GroupDef *parent, int level)
Definition: filedef.cpp:1633
EntryKind kind() const
Definition: filedef.h:287
QList< DirEntry > & children()
Definition: filedef.h:314
QCString path() const
Definition: filedef.h:293
static Directory* findDirNode ( Directory root,
const QCString name 
)
static

Definition at line 1467 of file filedef.cpp.

1468 {
1469  QListIterator<DirEntry> dli(root->children());
1470  DirEntry *de;
1471  for (dli.toFirst();(de=dli.current());++dli)
1472  {
1473  if (de->kind()==DirEntry::Dir)
1474  {
1475  Directory *dir = (Directory *)de;
1476  QCString dirName=dir->name();
1477  int sp=findMatchingPart(name,dirName);
1478  //printf("findMatchingPart(%s,%s)=%d\n",name.data(),dirName.data(),sp);
1479  if (sp>0) // match found
1480  {
1481  if ((uint)sp==dirName.length()) // whole directory matches
1482  {
1483  // recurse into the directory
1484  return findDirNode(dir,name.mid(dirName.length()+1));
1485  }
1486  else // partial match => we need to split the path into three parts
1487  {
1488  QCString baseName =dirName.left(sp);
1489  QCString oldBranchName=dirName.mid(sp+1);
1490  QCString newBranchName=name.mid(sp+1);
1491  // strip file name from path
1492  int newIndex=newBranchName.findRev('/');
1493  if (newIndex>0) newBranchName=newBranchName.left(newIndex);
1494 
1495  //printf("Splitting off part in new branch \n"
1496  // "base=%s old=%s new=%s\n",
1497  // baseName.data(),
1498  // oldBranchName.data(),
1499  // newBranchName.data()
1500  // );
1501  Directory *base = new Directory(root,baseName);
1502  Directory *newBranch = new Directory(base,newBranchName);
1503  dir->reParent(base);
1504  dir->rename(oldBranchName);
1505  base->addChild(dir);
1506  base->addChild(newBranch);
1507  dir->setLast(FALSE);
1508  // remove DirEntry container from list (without deleting it)
1509  root->children().setAutoDelete(FALSE);
1510  root->children().removeRef(dir);
1511  root->children().setAutoDelete(TRUE);
1512  // add new branch to the root
1513  if (!root->children().isEmpty())
1514  {
1515  root->children().getLast()->setLast(FALSE);
1516  }
1517  root->addChild(base);
1518  return newBranch;
1519  }
1520  }
1521  }
1522  }
1523  int si=name.findRev('/');
1524  if (si==-1) // no subdir
1525  {
1526  return root; // put the file under the root node.
1527  }
1528  else // need to create a subdir
1529  {
1530  QCString baseName = name.left(si);
1531  //printf("new subdir %s\n",baseName.data());
1532  Directory *newBranch = new Directory(root,baseName);
1533  if (!root->children().isEmpty())
1534  {
1535  root->children().getLast()->setLast(FALSE);
1536  }
1537  root->addChild(newBranch);
1538  return newBranch;
1539  }
1540 }
uint length() const
Definition: qcstring.h:195
const bool FALSE
Definition: qglobal.h:370
QCString left(uint len) const
Definition: qcstring.cpp:213
string dir
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
static int findMatchingPart(const QCString &path, const QCString dir)
Definition: filedef.cpp:1444
type * getLast() const
Definition: qlist.h:96
static Directory * findDirNode(Directory *root, const QCString &name)
Definition: filedef.cpp:1467
bool isEmpty() const
Definition: qlist.h:67
void setLast(bool b)
Definition: filedef.h:290
QCString name() const
Definition: filedef.h:292
type * current() const
Definition: qlist.h:146
void rename(const QCString &name)
Definition: filedef.h:315
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
void addChild(DirEntry *d)
Definition: filedef.h:313
bool removeRef(const type *d)
Definition: qlist.h:78
static QCString baseName
Definition: scanner.cpp:10890
QList< DirEntry > & children()
Definition: filedef.h:314
unsigned uint
Definition: qglobal.h:351
void setAutoDelete(bool enable)
Definition: qlist.h:99
void reParent(Directory *parent)
Definition: filedef.h:316
const bool TRUE
Definition: qglobal.h:371
static int findMatchingPart ( const QCString path,
const QCString  dir 
)
static

Definition at line 1444 of file filedef.cpp.

1445 {
1446  int si1;
1447  int pos1=0,pos2=0;
1448  while ((si1=path.find('/',pos1))!=-1)
1449  {
1450  int si2=dir.find('/',pos2);
1451  //printf(" found slash at pos %d in path %d: %s<->%s\n",si1,si2,
1452  // path.mid(pos1,si1-pos2).data(),dir.mid(pos2).data());
1453  if (si2==-1 && path.mid(pos1,si1-pos2)==dir.mid(pos2)) // match at end
1454  {
1455  return dir.length();
1456  }
1457  if (si1!=si2 || path.mid(pos1,si1-pos2)!=dir.mid(pos2,si2-pos2)) // no match in middle
1458  {
1459  return QMAX(pos1-1,0);
1460  }
1461  pos1=si1+1;
1462  pos2=si2+1;
1463  }
1464  return 0;
1465 }
uint length() const
Definition: qcstring.h:195
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
#define QMAX(a, b)
Definition: qglobal.h:390
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
void generateFileTree ( )

Definition at line 1664 of file filedef.cpp.

1665 {
1666  Directory *root=new Directory(0,"root");
1667  root->setLast(TRUE);
1669  FileName *fn;
1670  for (fnli.toFirst();(fn=fnli.current());++fnli)
1671  {
1672  FileNameIterator fni(*fn);
1673  FileDef *fd;
1674  for (;(fd=fni.current());++fni)
1675  {
1676  mergeFileDef(root,fd);
1677  }
1678  }
1679  //t << "<div class=\"directory\">\n";
1680  //writeDirTreeNode(t,root,0);
1681  //t << "</div>\n";
1682  addDirsAsGroups(root,0,0);
1683  delete root;
1684 }
static FileNameList * inputNameList
Definition: doxygen.h:109
QAsciiDict< Entry > fn
void setLast(bool b)
Definition: filedef.h:290
static void addDirsAsGroups(Directory *root, GroupDef *parent, int level)
Definition: filedef.cpp:1633
static void mergeFileDef(Directory *root, FileDef *fd)
Definition: filedef.cpp:1542
const bool TRUE
Definition: qglobal.h:371
static void getAllIncludeFilesRecursively ( QDict< void > *  filesVisited,
const FileDef fd,
QStrList incFiles 
)
static

Definition at line 1883 of file filedef.cpp.

1885 {
1886  if (fd->includeFileList())
1887  {
1889  IncludeInfo *ii;
1890  for (iii.toFirst();(ii=iii.current());++iii)
1891  {
1892  if (ii->fileDef && !ii->fileDef->isReference() &&
1893  !filesVisited->find(ii->fileDef->absFilePath()))
1894  {
1895  //printf("FileDef::addIncludeDependency(%s)\n",ii->fileDef->absFilePath().data());
1896  incFiles.append(ii->fileDef->absFilePath());
1897  filesVisited->insert(ii->fileDef->absFilePath(),(void*)0x8);
1898  getAllIncludeFilesRecursively(filesVisited,ii->fileDef,incFiles);
1899  }
1900  }
1901  }
1902 }
QList< IncludeInfo > * includeFileList() const
Definition: filedef.h:124
void append(const type *d)
Definition: qinternallist.h:61
type * current() const
Definition: qlist.h:146
static void getAllIncludeFilesRecursively(QDict< void > *filesVisited, const FileDef *fd, QStrList &incFiles)
Definition: filedef.cpp:1883
static void mergeFileDef ( Directory root,
FileDef fd 
)
static

Definition at line 1542 of file filedef.cpp.

1543 {
1544  QCString filePath = fd->absFilePath();
1545  //printf("merging %s\n",filePath.data());
1546  Directory *dirNode = findDirNode(root,filePath);
1547  if (!dirNode->children().isEmpty())
1548  {
1549  dirNode->children().getLast()->setLast(FALSE);
1550  }
1551  DirEntry *e=new DirEntry(dirNode,fd);
1552  dirNode->addChild(e);
1553 }
const bool FALSE
Definition: qglobal.h:370
type * getLast() const
Definition: qlist.h:96
static Directory * findDirNode(Directory *root, const QCString &name)
Definition: filedef.cpp:1467
const double e
bool isEmpty() const
Definition: qlist.h:67
void setLast(bool b)
Definition: filedef.h:290
QCString absFilePath() const
Definition: filedef.h:96
void addChild(DirEntry *d)
Definition: filedef.h:313
QList< DirEntry > & children()
Definition: filedef.h:314