Skip to main content

The dirdef.cpp File Reference

Included Headers

#include <algorithm> #include "dirdef.h" #include "md5.h" #include "filename.h" #include "doxygen.h" #include "util.h" #include "outputlist.h" #include "language.h" #include "message.h" #include "dot.h" #include "dotdirdeps.h" #include "layout.h" #include "config.h" #include "docparser.h" #include "definitionimpl.h" #include "filedef.h" #include "trace.h"

Classes Index

classDirDefImpl

Functions Index

DirDef *createDirDef (const QCString &path)
static QCStringencodeDirName (const QCString &anchor)
static voidwritePartialDirPath (OutputList &ol, const DirDef *root, const DirDef *target)
static voidwritePartialFilePath (OutputList &ol, const DirDef *root, const FileDef *fd)
static voidcomputeCommonDirPrefix ()

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

voidbuildDirectories ()
voidcomputeDirDependencies ()
voidgenerateDirDocs (OutputList &ol)
boolcompareDirDefs (const DirDef *item1, const DirDef *item2)
DirDef *toDirDef (Definition *d)
const DirDef *toDirDef (const Definition *d)

Functions

buildDirectories()

void buildDirectories ()

Definition at line 1078 of file dirdef.cpp.

1079{
1080 AUTO_TRACE();
1081 // for each input file
1082 for (const auto &fn : *Doxygen::inputNameLinkedMap)
1083 {
1084 for (const auto &fd : *fn)
1085 {
1086 if (fd->getReference().isEmpty())
1087 {
1088 DirDef *dir=Doxygen::dirLinkedMap->find(fd->getPath());
1089 if (dir==nullptr) // new directory
1090 {
1091 dir = DirDefImpl::mergeDirectoryInTree(fd->getPath());
1092 }
1093 if (dir && !fd->isDocumentationFile()) dir->addFile(fd.get());
1094 }
1095 else
1096 {
1097 // do something for file imported via tag files.
1098 }
1099 }
1100 }
1101
1102 // compute relations between directories => introduce container dirs.
1103 for (const auto &dir : *Doxygen::dirLinkedMap)
1104 {
1105 QCString name = dir->name();
1106 int i=name.findRev('/',static_cast<int>(name.length())-2);
1107 if (i>0)
1108 {
1109 DirDef *parent = Doxygen::dirLinkedMap->find(name.left(i+1));
1110 //if (parent==0) parent=root;
1111 if (parent)
1112 {
1113 parent->addSubDir(dir.get());
1114 AUTO_TRACE_ADD("DirDefImpl::addSubdir(): Adding subdir {} to {}",
1115 dir->displayName(), parent->displayName());
1116 }
1117 }
1118 }
1119
1120 // sort the directory contents
1121 for (const auto &dir : *Doxygen::dirLinkedMap)
1122 {
1123 dir->sort();
1124 }
1125
1126 // short the directories themselves
1127 std::stable_sort(Doxygen::dirLinkedMap->begin(),
1129 [](const auto &d1,const auto &d2)
1130 {
1131 QCString s1 = d1->shortName(), s2 = d2->shortName();
1132 int i = qstricmp_sort(s1,s2);
1133 if (i==0) // if sort name are equal, sort on full path
1134 {
1135 QCString n1 = d1->name(), n2 = d2->name();
1136 int n = qstricmp_sort(n1,n2);
1137 return n < 0;
1138 }
1139 return i < 0;
1140 });
1141
1142 // set the directory index identifier
1143 int dirIndex=0;
1144 for (const auto &dir : *Doxygen::dirLinkedMap)
1145 {
1146 dir->setDirIndex(dirIndex++);
1147 }
1148
1150}

References DirDef::addFile, AUTO_TRACE, AUTO_TRACE_ADD, begin, computeCommonDirPrefix, Doxygen::dirLinkedMap, end, QCString::findRev, Doxygen::inputNameLinkedMap, QCString::left, QCString::length, DirDefImpl::mergeDirectoryInTree, parent and qstricmp_sort.

Referenced by parseInput.

compareDirDefs()

bool compareDirDefs (const DirDef * item1, const DirDef * item2)

Definition at line 1191 of file dirdef.cpp.

1191bool compareDirDefs(const DirDef *item1, const DirDef *item2)
1192{
1193 return qstricmp_sort(item1->shortName(),item2->shortName()) < 0;
1194}

References qstricmp_sort and DirDef::shortName.

Referenced by DirDefImpl::sort and GroupDefImpl::sortMemberLists.

computeCommonDirPrefix()

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

1002{
1003 AUTO_TRACE();
1004 QCString path;
1005 auto it = Doxygen::dirLinkedMap->begin();
1006 if (!Doxygen::dirLinkedMap->empty()) // we have at least one dir
1007 {
1008 // start will full path of first dir
1009 path=removeLongPathMarker((*it)->name());
1010 int i=path.findRev('/',static_cast<int>(path.length())-2);
1011 path=path.left(i+1);
1012 bool done=FALSE;
1013 if (i==-1)
1014 {
1015 path="";
1016 }
1017 else
1018 {
1019 while (!done)
1020 {
1021 int l = static_cast<int>(path.length());
1022 size_t count=0;
1023 for (const auto &dir : *Doxygen::dirLinkedMap)
1024 {
1025 QCString dirName = removeLongPathMarker(dir->name());
1026 //printf("dirName='%s' (l=%d) path='%s' (l=%d)\n",qPrint(dirName),dirName.length(),qPrint(path),path.length());
1027 if (dirName.length()>path.length())
1028 {
1029 if (dirName.left(l)!=path) // dirName does not start with path
1030 {
1031 i = l>=2 ? path.findRev('/',l-2) : -1;
1032 if (i==-1) // no unique prefix -> stop
1033 {
1034 path="";
1035 done=TRUE;
1036 }
1037 else // restart with shorter path
1038 {
1039 path=path.left(i+1);
1040 break;
1041 }
1042 }
1043 }
1044 else // dir is shorter than path -> take path of dir as new start
1045 {
1046 path=dir->name();
1047 l=static_cast<int>(path.length());
1048 i=path.findRev('/',l-2);
1049 if (i==-1) // no unique prefix -> stop
1050 {
1051 path="";
1052 done=TRUE;
1053 }
1054 else // restart with shorter path
1055 {
1056 path=path.left(i+1);
1057 }
1058 break;
1059 }
1060 count++;
1061 }
1062 if (count==Doxygen::dirLinkedMap->size())
1063 // path matches for all directories -> found the common prefix
1064 {
1065 done=TRUE;
1066 }
1067 }
1068 }
1069 }
1070 for (const auto &dir : *Doxygen::dirLinkedMap)
1071 {
1072 QCString diskName = dir->name().right(dir->name().length()-path.length());
1073 dir->setDiskName(diskName);
1074 AUTO_TRACE_ADD("set disk name: {} -> {}",dir->name(),diskName);
1075 }
1076}

References AUTO_TRACE, AUTO_TRACE_ADD, Doxygen::dirLinkedMap, FALSE, QCString::findRev, QCString::left, QCString::length, removeLongPathMarker, QCString::right and TRUE.

Referenced by buildDirectories.

computeDirDependencies()

void computeDirDependencies ()

Definition at line 1152 of file dirdef.cpp.

1153{
1154 AUTO_TRACE();
1155 // compute nesting level for each directory
1156 for (const auto &dir : *Doxygen::dirLinkedMap)
1157 {
1158 dir->setLevel();
1159 }
1160
1161 // compute uses dependencies between directories
1162 for (const auto &dir : *Doxygen::dirLinkedMap)
1163 {
1164 AUTO_TRACE_ADD("computeDependencies for {}: #dirs={}",dir->name(),Doxygen::dirLinkedMap->size());
1165 dir->computeDependencies();
1166 }
1167}

References AUTO_TRACE, AUTO_TRACE_ADD and Doxygen::dirLinkedMap.

Referenced by parseInput.

createDirDef()

DirDef * createDirDef (const QCString & path)

Definition at line 108 of file dirdef.cpp.

109{
110 return new DirDefImpl(path);
111}

Referenced by DirDefImpl::createNewDir.

encodeDirName()

QCString encodeDirName (const QCString & anchor)
static

Definition at line 189 of file dirdef.cpp.

189static QCString encodeDirName(const QCString &anchor)
190{
191 AUTO_TRACE();
192 // convert to md5 hash
193 uint8_t md5_sig[16];
194 char sigStr[33];
195 MD5Buffer(anchor.data(),static_cast<unsigned int>(anchor.length()),md5_sig);
196 MD5SigToString(md5_sig,sigStr);
197 AUTO_TRACE_EXIT("result={}",sigStr);
198 return sigStr;
199
200 // old algorithm
201// QCString result;
202
203// int l = anchor.length(),i;
204// for (i=0;i<l;i++)
205// {
206// char c = anchor.at(i);
207// if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'))
208// {
209// result+=c;
210// }
211// else
212// {
213// static char hexStr[]="0123456789ABCDEF";
214// char escChar[]={ '_', 0, 0, 0 };
215// escChar[1]=hexStr[c>>4];
216// escChar[2]=hexStr[c&0xf];
217// result+=escChar;
218// }
219// }
220// return result;
221}

References AUTO_TRACE, AUTO_TRACE_EXIT, QCString::data and QCString::length.

Referenced by DirDefImpl::getOutputFileBase.

generateDirDocs()

void generateDirDocs (OutputList & ol)

Definition at line 1169 of file dirdef.cpp.

1170{
1171 AUTO_TRACE();
1172 for (const auto &dir : *Doxygen::dirLinkedMap)
1173 {
1175 if (!dir->hasDocumentation())
1176 {
1178 }
1179 dir->writeDocumentation(ol);
1181 }
1182 //if (Config_getBool(DIRECTORY_GRAPH))
1183 {
1184 for (const auto &dr : Doxygen::dirRelations)
1185 {
1186 dr->writeDocumentation(ol);
1187 }
1188 }
1189}

References AUTO_TRACE, Doxygen::dirLinkedMap, Doxygen::dirRelations, OutputList::disableAllBut, Html, OutputList::popGeneratorState and OutputList::pushGeneratorState.

Referenced by generateOutput.

toDirDef()

DirDef * toDirDef (Definition * d)

Definition at line 1198 of file dirdef.cpp.

1199{
1200 if (d==nullptr) return nullptr;
1201 if (d && typeid(*d)==typeid(DirDefImpl))
1202 {
1203 return static_cast<DirDef*>(d);
1204 }
1205 else
1206 {
1207 return nullptr;
1208 }
1209}

toDirDef()

const DirDef * toDirDef (const Definition * d)

Definition at line 1211 of file dirdef.cpp.

1211const DirDef *toDirDef(const Definition *d)
1212{
1213 if (d==nullptr) return nullptr;
1214 if (d && typeid(*d)==typeid(DirDefImpl))
1215 {
1216 return static_cast<const DirDef*>(d);
1217 }
1218 else
1219 {
1220 return nullptr;
1221 }
1222}

writePartialDirPath()

void writePartialDirPath (OutputList & ol, const DirDef * root, const DirDef * target)
static

Definition at line 913 of file dirdef.cpp.

913static void writePartialDirPath(OutputList &ol,const DirDef *root,const DirDef *target)
914{
915 if (target->parent()!=root)
916 {
917 writePartialDirPath(ol,root,target->parent());
918 ol.writeString("&#160;/&#160;");
919 }
920 ol.writeObjectLink(target->getReference(),target->getOutputFileBase(),QCString(),target->shortName());
921}

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

Referenced by writePartialDirPath and writePartialFilePath.

writePartialFilePath()

void writePartialFilePath (OutputList & ol, const DirDef * root, const FileDef * fd)
static

Definition at line 923 of file dirdef.cpp.

923static void writePartialFilePath(OutputList &ol,const DirDef *root,const FileDef *fd)
924{
925 if (fd->getDirDef() && fd->getDirDef()!=root)
926 {
927 writePartialDirPath(ol,root,fd->getDirDef());
928 ol.writeString("&#160;/&#160;");
929 }
930 if (fd->isLinkable())
931 {
933 }
934 else
935 {
936 ol.startBold();
937 ol.docify(fd->name());
938 ol.endBold();
939 }
940}

References OutputList::docify, OutputList::endBold, FileDef::getDirDef, Definition::getOutputFileBase, Definition::getReference, Definition::isLinkable, Definition::name, OutputList::startBold, OutputList::writeObjectLink, writePartialDirPath and OutputList::writeString.

Referenced by DirRelation::writeDocumentation.


Generated via doxygen2docusaurus by Doxygen 1.14.0.