summaryrefslogtreecommitdiffstats
path: root/src/dirdef.cpp
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2004-08-24 20:00:14 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2004-08-24 20:00:14 (GMT)
commit4b77f4fc83a7954a741c1b35ec50e918a2786559 (patch)
treeacf5ce8ed64ee56e5f7eec664f2f00260d068e9c /src/dirdef.cpp
parentbb18b811e8f1a4a939eadf28d12bc5f99dd74b82 (diff)
downloadDoxygen-4b77f4fc83a7954a741c1b35ec50e918a2786559.zip
Doxygen-4b77f4fc83a7954a741c1b35ec50e918a2786559.tar.gz
Doxygen-4b77f4fc83a7954a741c1b35ec50e918a2786559.tar.bz2
Release-1.3.8-20040824
Diffstat (limited to 'src/dirdef.cpp')
-rw-r--r--src/dirdef.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/dirdef.cpp b/src/dirdef.cpp
new file mode 100644
index 0000000..d7c46b1
--- /dev/null
+++ b/src/dirdef.cpp
@@ -0,0 +1,134 @@
+#include "dirdef.h"
+#include "filename.h"
+#include "doxygen.h"
+#include "util.h"
+
+//----------------------------------------------------------------------
+// method implementation
+
+DirDef::DirDef(const char *path) : Definition(path,1,path),
+ m_parent(0)
+{
+ // get short name (stipping the paths mentioned in STRIP_FROM_PATH)
+ m_dispName = stripFromPath(path);
+ m_subdirs.setAutoDelete(TRUE);
+ m_fileList = new FileList;
+ m_classSDict = new ClassSDict(17);
+}
+
+DirDef::~DirDef()
+{
+}
+
+void DirDef::addSubDir(DirDef *subdir)
+{
+ m_subdirs.append(subdir);
+ subdir->m_parent=this;
+}
+
+void DirDef::addFile(FileDef *fd)
+{
+ m_fileList->append(fd);
+ fd->setDirDef(this);
+}
+
+//----------------------------------------------------------------------
+// helper functions
+
+DirDef *DirDef::createNewDir(const char *path)
+{
+ ASSERT(path!=0);
+ DirDef *dir = Doxygen::directories.find(path);
+ if (dir==0) // new dir
+ {
+ //printf("Adding new dir %s\n",path);
+ dir = new DirDef(path);
+ Doxygen::directories.inSort(path,dir);
+ }
+ return dir;
+}
+
+bool DirDef::matchPath(const QCString &path,QStrList &l)
+{
+ const char *s=l.first();
+ while (s)
+ {
+ QCString prefix = s;
+ if (stricmp(prefix.left(path.length()),path)==0) // case insensitive compare
+ {
+ return TRUE;
+ }
+ s = l.next();
+ }
+ return FALSE;
+}
+
+/*! strip part of \a path if it matches
+ * one of the paths in the Config_getList("STRIP_FROM_PATH") list
+ */
+DirDef *DirDef::mergeDirectoryInTree(const QCString &path)
+{
+ int p=0,i=0;
+ DirDef *dir=0;
+ while ((i=path.find('/',p))!=-1)
+ {
+ QCString part=path.left(i+1);
+ if (!matchPath(part,Config_getList("STRIP_FROM_PATH")))
+ {
+ dir=createNewDir(part);
+ }
+ p=i+1;
+ }
+ return dir;
+}
+
+//----------------------------------------------------------------------
+// external functions
+
+void buildDirectories()
+{
+ // for each input file
+ FileNameListIterator fnli(Doxygen::inputNameList);
+ FileName *fn;
+ for (fnli.toFirst();(fn=fnli.current());++fnli)
+ {
+ FileNameIterator fni(*fn);
+ FileDef *fd;
+ for (;(fd=fni.current());++fni)
+ {
+ if (!fd->getReference().isEmpty())
+ {
+ DirDef *dir;
+ if ((dir=Doxygen::directories.find(fd->getPath()))==0) // new directory
+ {
+ dir = DirDef::mergeDirectoryInTree(fd->getPath());
+ }
+ 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;
+ SDict<DirDef>::Iterator sdi(Doxygen::directories);
+ for (sdi.toFirst();(dir=sdi.current());++sdi)
+ {
+ printf("New dir %s\n",dir->displayName().data());
+ QCString name = dir->name();
+ int i=name.findRev('/',name.length()-2);
+ if (i!=-1)
+ {
+ DirDef *parent = Doxygen::directories.find(name.left(i+1));
+ if (parent==0) parent=root;
+ parent->addSubDir(dir);
+ printf("DirDef::addSubdir(): Adding subdir\n%s to\n%s\n",
+ dir->displayName().data(), parent->displayName().data());
+ }
+ }
+}
+