My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
dirdef.cpp File Reference
#include "md5.h"
#include "dirdef.h"
#include "filename.h"
#include "doxygen.h"
#include "util.h"
#include "outputlist.h"
#include "language.h"
#include "message.h"
#include "dot.h"
#include "layout.h"
#include "ftextstream.h"
#include "config.h"
#include "docparser.h"

Go to the source code of this file.

Functions

static QCString encodeDirName (const QCString &anchor)
 
static void writePartialDirPath (OutputList &ol, const DirDef *root, const DirDef *target)
 
static void writePartialFilePath (OutputList &ol, const DirDef *root, const FileDef *fd)
 
static void computeCommonDirPrefix ()
 
void buildDirectories ()
 
void computeDirDependencies ()
 
void generateDirDocs (OutputList &ol)
 

Variables

static int g_dirCount =0
 

Function Documentation

void buildDirectories ( )

Definition at line 917 of file dirdef.cpp.

References DirDef::addFile(), DirDef::addSubDir(), computeCommonDirPrefix(), Doxygen::directories, SDict< T >::find(), FileDef::getPath(), Definition::getReference(), Doxygen::inputNameList, FileDef::isDocumentationFile(), SDict< DirDef >::Iterator, DirDef::mergeDirectoryInTree(), Definition::name(), DirDef::sort(), and SDict< T >::sort().

Referenced by parseInput().

{
// for each input file
FileName *fn;
for (fnli.toFirst();(fn=fnli.current());++fnli)
{
FileNameIterator fni(*fn);
FileDef *fd;
for (;(fd=fni.current());++fni)
{
//printf("buildDirectories %s\n",fd->name().data());
if (fd->getReference().isEmpty() && !fd->isDocumentationFile())
{
DirDef *dir;
if ((dir=Doxygen::directories->find(fd->getPath()))==0) // new directory
{
}
if (dir) dir->addFile(fd);
}
else
{
// do something for file imported via tag files.
}
}
}
//DirDef *root = new DirDef("root:");
// compute relations between directories => introduce container dirs.
DirDef *dir;
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
QCString name = dir->name();
int i=name.findRev('/',name.length()-2);
if (i>0)
{
DirDef *parent = Doxygen::directories->find(name.left(i+1));
//if (parent==0) parent=root;
if (parent)
{
parent->addSubDir(dir);
//printf("DirDef::addSubdir(): Adding subdir\n%s to\n%s\n",
// dir->displayName().data(), parent->displayName().data());
}
}
}
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
dir->sort();
}
}
static void computeCommonDirPrefix ( )
static

In order to create stable, but unique directory names, we compute the common part of the path shared by all directories.

Definition at line 839 of file dirdef.cpp.

References Doxygen::directories, SDict< DirDef >::Iterator, Definition::name(), and DirDef::setDiskName().

Referenced by buildDirectories().

{
QCString path;
DirDef *dir;
if (Doxygen::directories->count()>0) // we have at least one dir
{
// start will full path of first dir
sdi.toFirst();
dir=sdi.current();
path=dir->name();
int i=path.findRev('/',path.length()-2);
path=path.left(i+1);
bool done=FALSE;
if (i==-1)
{
path="";
}
else
{
while (!done)
{
int l = path.length();
int count=0;
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
QCString dirName = dir->name();
if (dirName.length()>path.length())
{
if (qstrncmp(dirName,path,l)!=0) // dirName does not start with path
{
int i=path.findRev('/',l-2);
if (i==-1) // no unique prefix -> stop
{
path="";
done=TRUE;
}
else // restart with shorter path
{
path=path.left(i+1);
break;
}
}
}
else // dir is shorter than path -> take path of dir as new start
{
path=dir->name();
l=path.length();
int i=path.findRev('/',l-2);
if (i==-1) // no unique prefix -> stop
{
path="";
done=TRUE;
}
else // restart with shorter path
{
path=path.left(i+1);
}
break;
}
count++;
}
if (count==Doxygen::directories->count())
// path matches for all directories -> found the common prefix
{
done=TRUE;
}
}
}
}
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
QCString diskName = dir->name().right(dir->name().length()-path.length());
dir->setDiskName(diskName);
//printf("set disk name: %s -> %s\n",dir->name().data(),diskName.data());
}
}
void computeDirDependencies ( )

Definition at line 973 of file dirdef.cpp.

References DirDef::computeDependencies(), Doxygen::directories, SDict< DirDef >::Iterator, and DirDef::setLevel().

Referenced by parseInput().

{
DirDef *dir;
// compute nesting level for each directory
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
dir->setLevel();
}
// compute uses dependencies between directories
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
//printf("computeDependencies for %s: #dirs=%d\n",dir->name().data(),Doxygen::directories.count());
}
}
static QCString encodeDirName ( const QCString &  anchor)
static

Definition at line 87 of file dirdef.cpp.

Referenced by DirDef::getOutputFileBase().

{
// convert to md5 hash
uchar md5_sig[16];
QCString sigStr(33);
MD5Buffer((const unsigned char *)anchor.data(),anchor.length(),md5_sig);
MD5SigToString(md5_sig,sigStr.rawData(),33);
return sigStr;
// old algorithm
// QCString result;
// int l = anchor.length(),i;
// for (i=0;i<l;i++)
// {
// char c = anchor.at(i);
// if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'))
// {
// result+=c;
// }
// else
// {
// static char hexStr[]="0123456789ABCDEF";
// char escChar[]={ '_', 0, 0, 0 };
// escChar[1]=hexStr[c>>4];
// escChar[2]=hexStr[c&0xf];
// result+=escChar;
// }
// }
// return result;
}
void generateDirDocs ( OutputList ol)

Definition at line 991 of file dirdef.cpp.

References Config_getBool, Doxygen::directories, Doxygen::dirRelations, SDict< DirDef >::Iterator, DirDef::writeDocumentation(), and DirRelation::writeDocumentation().

Referenced by generateOutput().

{
DirDef *dir;
for (sdi.toFirst();(dir=sdi.current());++sdi)
{
}
if (Config_getBool(DIRECTORY_GRAPH))
{
for (rdi.toFirst();(dr=rdi.current());++rdi)
{
}
}
}
static void writePartialDirPath ( OutputList ol,
const DirDef root,
const DirDef target 
)
static

Definition at line 748 of file dirdef.cpp.

References DirDef::getOutputFileBase(), Definition::getReference(), DirDef::parent(), DirDef::shortName(), OutputList::writeObjectLink(), and OutputList::writeString().

Referenced by writePartialFilePath().

{
if (target->parent()!=root)
{
writePartialDirPath(ol,root,target->parent());
ol.writeString("&#160;/&#160;");
}
ol.writeObjectLink(target->getReference(),target->getOutputFileBase(),0,target->shortName());
}
static void writePartialFilePath ( OutputList ol,
const DirDef root,
const FileDef fd 
)
static

Variable Documentation

int g_dirCount =0
static

Definition at line 19 of file dirdef.cpp.

Referenced by DirDef::DirDef().