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 872 of file dirdef.cpp.

873 {
874  // for each input file
876  FileName *fn;
877  for (fnli.toFirst();(fn=fnli.current());++fnli)
878  {
879  FileNameIterator fni(*fn);
880  FileDef *fd;
881  for (;(fd=fni.current());++fni)
882  {
883  //printf("buildDirectories %s\n",fd->name().data());
884  if (fd->getReference().isEmpty() && !fd->isDocumentationFile())
885  {
886  DirDef *dir;
887  if ((dir=Doxygen::directories->find(fd->getPath()))==0) // new directory
888  {
890  }
891  if (dir) dir->addFile(fd);
892  }
893  else
894  {
895  // do something for file imported via tag files.
896  }
897  }
898  }
899 
900  //DirDef *root = new DirDef("root:");
901  // compute relations between directories => introduce container dirs.
902  DirDef *dir;
904  for (sdi.toFirst();(dir=sdi.current());++sdi)
905  {
906  //printf("New dir %s\n",dir->displayName().data());
907  QCString name = dir->name();
908  int i=name.findRev('/',name.length()-2);
909  if (i>0)
910  {
911  DirDef *parent = Doxygen::directories->find(name.left(i+1));
912  //if (parent==0) parent=root;
913  if (parent)
914  {
915  parent->addSubDir(dir);
916  //printf("DirDef::addSubdir(): Adding subdir\n%s to\n%s\n",
917  // dir->displayName().data(), parent->displayName().data());
918  }
919  }
920  }
922 }
static QCString name
Definition: declinfo.cpp:673
void addFile(FileDef *fd)
Definition: dirdef.cpp:75
void addSubDir(DirDef *subdir)
Definition: dirdef.cpp:68
virtual QCString getReference() const
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
static FileNameList * inputNameList
Definition: doxygen.h:109
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
QAsciiDict< Entry > fn
const QCString & name() const
Definition: definition.h:114
static DirSDict * directories
Definition: doxygen.h:139
static DirDef * mergeDirectoryInTree(const QCString &path)
Definition: dirdef.cpp:684
Definition: dirdef.h:44
static void computeCommonDirPrefix()
Definition: dirdef.cpp:794
QCString getPath() const
Definition: filedef.h:110
bool isDocumentationFile() const
Definition: filedef.cpp:1728
friend class Iterator
Definition: sortdict.h:289
T * find(const char *key)
Definition: sortdict.h:232
def parent(G, child, parent_type)
Definition: graph.py:67
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 794 of file dirdef.cpp.

795 {
796  QCString path;
797  DirDef *dir;
799  if (Doxygen::directories->count()>0) // we have at least one dir
800  {
801  // start will full path of first dir
802  sdi.toFirst();
803  dir=sdi.current();
804  path=dir->name();
805  int i=path.findRev('/',path.length()-2);
806  path=path.left(i+1);
807  bool done=FALSE;
808  if (i==-1)
809  {
810  path="";
811  }
812  else
813  {
814  while (!done)
815  {
816  int l = path.length();
817  int count=0;
818  for (sdi.toFirst();(dir=sdi.current());++sdi)
819  {
820  QCString dirName = dir->name();
821  if (dirName.length()>path.length())
822  {
823  if (qstrncmp(dirName,path,l)!=0) // dirName does not start with path
824  {
825  int i=path.findRev('/',l-2);
826  if (i==-1) // no unique prefix -> stop
827  {
828  path="";
829  done=TRUE;
830  }
831  else // restart with shorter path
832  {
833  path=path.left(i+1);
834  break;
835  }
836  }
837  }
838  else // dir is shorter than path -> take path of dir as new start
839  {
840  path=dir->name();
841  l=path.length();
842  int i=path.findRev('/',l-2);
843  if (i==-1) // no unique prefix -> stop
844  {
845  path="";
846  done=TRUE;
847  }
848  else // restart with shorter path
849  {
850  path=path.left(i+1);
851  }
852  break;
853  }
854  count++;
855  }
856  if (count==Doxygen::directories->count())
857  // path matches for all directories -> found the common prefix
858  {
859  done=TRUE;
860  }
861  }
862  }
863  }
864  for (sdi.toFirst();(dir=sdi.current());++sdi)
865  {
866  QCString diskName = dir->name().right(dir->name().length()-path.length());
867  dir->setDiskName(diskName);
868  //printf("set disk name: %s -> %s\n",dir->name().data(),diskName.data());
869  }
870 }
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
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
static QStrList * l
Definition: config.cpp:1044
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
const QCString & name() const
Definition: definition.h:114
QCString right(uint len) const
Definition: qcstring.cpp:231
static DirSDict * directories
Definition: doxygen.h:139
Definition: dirdef.h:44
void setDiskName(const QCString &name)
Definition: dirdef.h:78
friend class Iterator
Definition: sortdict.h:289
const bool TRUE
Definition: qglobal.h:371
void computeDirDependencies ( )

Definition at line 924 of file dirdef.cpp.

925 {
926  DirDef *dir;
928  // compute nesting level for each directory
929  for (sdi.toFirst();(dir=sdi.current());++sdi)
930  {
931  dir->setLevel();
932  }
933  // compute uses dependencies between directories
934  for (sdi.toFirst();(dir=sdi.current());++sdi)
935  {
936  //printf("computeDependencies for %s: #dirs=%d\n",dir->name().data(),Doxygen::directories.count());
937  dir->computeDependencies();
938  }
939 
940 }
void computeDependencies()
Definition: dirdef.cpp:566
string dir
static DirSDict * directories
Definition: doxygen.h:139
Definition: dirdef.h:44
void setLevel()
Definition: dirdef.cpp:492
friend class Iterator
Definition: sortdict.h:289
static QCString encodeDirName ( const QCString anchor)
static

Definition at line 81 of file dirdef.cpp.

82 {
83  // convert to md5 hash
84  uchar md5_sig[16];
85  QCString sigStr(33);
86  MD5Buffer((const unsigned char *)anchor.data(),anchor.length(),md5_sig);
87  MD5SigToString(md5_sig,sigStr.rawData(),33);
88  return sigStr;
89 
90  // old algorithm
91 // QCString result;
92 
93 // int l = anchor.length(),i;
94 // for (i=0;i<l;i++)
95 // {
96 // char c = anchor.at(i);
97 // if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'))
98 // {
99 // result+=c;
100 // }
101 // else
102 // {
103 // static char hexStr[]="0123456789ABCDEF";
104 // char escChar[]={ '_', 0, 0, 0 };
105 // escChar[1]=hexStr[c>>4];
106 // escChar[2]=hexStr[c&0xf];
107 // result+=escChar;
108 // }
109 // }
110 // return result;
111 }
uint length() const
Definition: qcstring.h:195
unsigned char uchar
Definition: nybbler.cc:11
void MD5Buffer(const unsigned char *buf, unsigned int len, unsigned char sig[16])
Definition: md5.c:275
const char * data() const
Definition: qcstring.h:207
void MD5SigToString(unsigned char signature[16], char *str, int len)
Definition: md5.c:285
void generateDirDocs ( OutputList ol)

Definition at line 942 of file dirdef.cpp.

943 {
944  DirDef *dir;
946  for (sdi.toFirst();(dir=sdi.current());++sdi)
947  {
948  dir->writeDocumentation(ol);
949  }
950  if (Config_getBool("DIRECTORY_GRAPH"))
951  {
953  DirRelation *dr;
954  for (rdi.toFirst();(dr=rdi.current());++rdi)
955  {
956  dr->writeDocumentation(ol);
957  }
958  }
959 }
static SDict< DirRelation > dirRelations
Definition: doxygen.h:140
void writeDocumentation(OutputList &ol)
Definition: dirdef.cpp:384
string dir
void writeDocumentation(OutputList &ol)
Definition: dirdef.cpp:732
Definition: sortdict.h:73
static DirSDict * directories
Definition: doxygen.h:139
Definition: dirdef.h:44
#define Config_getBool(val)
Definition: config.cpp:664
friend class Iterator
Definition: sortdict.h:289
static void writePartialDirPath ( OutputList ol,
const DirDef root,
const DirDef target 
)
static

Definition at line 703 of file dirdef.cpp.

704 {
705  if (target->parent()!=root)
706  {
707  writePartialDirPath(ol,root,target->parent());
708  ol.writeString("&#160;/&#160;");
709  }
710  ol.writeObjectLink(target->getReference(),target->getOutputFileBase(),0,target->shortName());
711 }
virtual QCString getReference() const
const QCString & shortName() const
Definition: dirdef.h:57
void writeString(const char *text)
Definition: outputlist.h:119
static void writePartialDirPath(OutputList &ol, const DirDef *root, const DirDef *target)
Definition: dirdef.cpp:703
QCString getOutputFileBase() const
Definition: dirdef.cpp:113
DirDef * parent() const
Definition: dirdef.h:64
void writeObjectLink(const char *ref, const char *file, const char *anchor, const char *name)
Definition: outputlist.h:149
static void writePartialFilePath ( OutputList ol,
const DirDef root,
const FileDef fd 
)
static

Definition at line 713 of file dirdef.cpp.

714 {
715  if (fd->getDirDef() && fd->getDirDef()!=root)
716  {
717  writePartialDirPath(ol,root,fd->getDirDef());
718  ol.writeString("&#160;/&#160;");
719  }
720  if (fd->isLinkable())
721  {
722  ol.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),0,fd->name());
723  }
724  else
725  {
726  ol.startBold();
727  ol.docify(fd->name());
728  ol.endBold();
729  }
730 }
virtual QCString getReference() const
bool isLinkable() const
Definition: filedef.h:117
void writeString(const char *text)
Definition: outputlist.h:119
DirDef * getDirDef() const
Definition: filedef.h:121
void endBold()
Definition: outputlist.h:306
QCString name() const
Definition: filedef.cpp:1193
static void writePartialDirPath(OutputList &ol, const DirDef *root, const DirDef *target)
Definition: dirdef.cpp:703
void startBold()
Definition: outputlist.h:304
QCString getOutputFileBase() const
Definition: filedef.h:83
void docify(const char *s)
Definition: outputlist.h:145
void writeObjectLink(const char *ref, const char *file, const char *anchor, const char *name)
Definition: outputlist.h:149

Variable Documentation

int g_dirCount =0
static

Definition at line 19 of file dirdef.cpp.