My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 1639 of file filedef.cpp.

References GroupDef::addGroup(), SDict< T >::append(), Directory::children(), DirEntry::Dir, Doxygen::groupSDict, DirEntry::kind(), Definition::makePartOfGroup(), DirEntry::name(), and DirEntry::path().

Referenced by generateFileTree().

{
GroupDef *gd=0;
if (root->kind()==DirEntry::Dir)
{
gd = new GroupDef("[generated]",
1,
root->path(), // name
root->name() // title
);
if (parent)
{
parent->addGroup(gd);
gd->makePartOfGroup(parent);
}
else
{
}
}
QListIterator<DirEntry> dli(root->children());
DirEntry *de;
for (dli.toFirst();(de=dli.current());++dli)
{
if (de->kind()==DirEntry::Dir)
{
addDirsAsGroups((Directory *)de,gd,level+1);
}
}
}
static Directory* findDirNode ( Directory root,
const QCString &  name 
)
static

Definition at line 1473 of file filedef.cpp.

References Directory::addChild(), Directory::children(), DirEntry::Dir, findMatchingPart(), DirEntry::name(), Directory::rename(), Directory::reParent(), and DirEntry::setLast().

Referenced by mergeFileDef().

{
QListIterator<DirEntry> dli(root->children());
DirEntry *de;
for (dli.toFirst();(de=dli.current());++dli)
{
if (de->kind()==DirEntry::Dir)
{
Directory *dir = (Directory *)de;
QCString dirName=dir->name();
int sp=findMatchingPart(name,dirName);
//printf("findMatchingPart(%s,%s)=%d\n",name.data(),dirName.data(),sp);
if (sp>0) // match found
{
if ((uint)sp==dirName.length()) // whole directory matches
{
// recurse into the directory
return findDirNode(dir,name.mid(dirName.length()+1));
}
else // partial match => we need to split the path into three parts
{
QCString baseName =dirName.left(sp);
QCString oldBranchName=dirName.mid(sp+1);
QCString newBranchName=name.mid(sp+1);
// strip file name from path
int newIndex=newBranchName.findRev('/');
if (newIndex>0) newBranchName=newBranchName.left(newIndex);
//printf("Splitting off part in new branch \n"
// "base=%s old=%s new=%s\n",
// baseName.data(),
// oldBranchName.data(),
// newBranchName.data()
// );
Directory *base = new Directory(root,baseName);
Directory *newBranch = new Directory(base,newBranchName);
dir->reParent(base);
dir->rename(oldBranchName);
base->addChild(dir);
base->addChild(newBranch);
dir->setLast(FALSE);
// remove DirEntry container from list (without deleting it)
root->children().setAutoDelete(FALSE);
root->children().removeRef(dir);
root->children().setAutoDelete(TRUE);
// add new branch to the root
if (!root->children().isEmpty())
{
root->children().getLast()->setLast(FALSE);
}
root->addChild(base);
return newBranch;
}
}
}
}
int si=name.findRev('/');
if (si==-1) // no subdir
{
return root; // put the file under the root node.
}
else // need to create a subdir
{
QCString baseName = name.left(si);
//printf("new subdir %s\n",baseName.data());
Directory *newBranch = new Directory(root,baseName);
if (!root->children().isEmpty())
{
root->children().getLast()->setLast(FALSE);
}
root->addChild(newBranch);
return newBranch;
}
}
static int findMatchingPart ( const QCString &  path,
const QCString  dir 
)
static

Definition at line 1450 of file filedef.cpp.

Referenced by findDirNode().

{
int si1;
int pos1=0,pos2=0;
while ((si1=path.find('/',pos1))!=-1)
{
int si2=dir.find('/',pos2);
//printf(" found slash at pos %d in path %d: %s<->%s\n",si1,si2,
// path.mid(pos1,si1-pos2).data(),dir.mid(pos2).data());
if (si2==-1 && path.mid(pos1,si1-pos2)==dir.mid(pos2)) // match at end
{
return dir.length();
}
if (si1!=si2 || path.mid(pos1,si1-pos2)!=dir.mid(pos2,si2-pos2)) // no match in middle
{
return QMAX(pos1-1,0);
}
pos1=si1+1;
pos2=si2+1;
}
return 0;
}
void generateFileTree ( )

Definition at line 1670 of file filedef.cpp.

References addDirsAsGroups(), Doxygen::inputNameList, mergeFileDef(), and DirEntry::setLast().

{
Directory *root=new Directory(0,"root");
root->setLast(TRUE);
FileName *fn;
for (fnli.toFirst();(fn=fnli.current());++fnli)
{
FileNameIterator fni(*fn);
FileDef *fd;
for (;(fd=fni.current());++fni)
{
mergeFileDef(root,fd);
}
}
//t << "<div class=\"directory\">\n";
//writeDirTreeNode(t,root,0);
//t << "</div>\n";
addDirsAsGroups(root,0,0);
delete root;
}
static void getAllIncludeFilesRecursively ( QDict< void > *  filesVisited,
const FileDef fd,
QStrList &  incFiles 
)
static

Definition at line 1894 of file filedef.cpp.

References FileDef::includeFileList().

{
if (fd->includeFileList())
{
QListIterator<IncludeInfo> iii(*fd->includeFileList());
for (iii.toFirst();(ii=iii.current());++iii)
{
if (ii->fileDef && !ii->fileDef->isReference() &&
!filesVisited->find(ii->fileDef->absFilePath()))
{
//printf("FileDef::addIncludeDependency(%s)\n",ii->fileDef->absFilePath().data());
incFiles.append(ii->fileDef->absFilePath());
filesVisited->insert(ii->fileDef->absFilePath(),(void*)0x8);
getAllIncludeFilesRecursively(filesVisited,ii->fileDef,incFiles);
}
}
}
}
static void mergeFileDef ( Directory root,
FileDef fd 
)
static

Definition at line 1548 of file filedef.cpp.

References FileDef::absFilePath(), Directory::addChild(), Directory::children(), and findDirNode().

Referenced by generateFileTree().

{
QCString filePath = fd->absFilePath();
//printf("merging %s\n",filePath.data());
Directory *dirNode = findDirNode(root,filePath);
if (!dirNode->children().isEmpty())
{
dirNode->children().getLast()->setLast(FALSE);
}
DirEntry *e=new DirEntry(dirNode,fd);
dirNode->addChild(e);
}