filename.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #include "filename.h"
19 #include "util.h"
20 #include "config.h"
21 
22 FileName::FileName(const char *fn,const char *n) : FileList()
23 {
25  fName=fn;
26  name=n;
27 }
28 
30 {
31 }
32 
33 
35 {
36  //QCString commonPrefix;
37  QListIterator<FileDef> it(*this);
38  FileDef *fd;
39  int count=0;
40  for (;(fd=it.current());++it)
41  {
42  if (!fd->isReference()) count++;
43  }
44  if (count==1)
45  {
46  // skip references
47  for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
48  if (fd)
49  {
50  // name if unique, so diskname is simply the name
51  //printf("!!!!!!!! Unique disk name=%s for fd=%s\n",name.data(),fd->diskname.data());
52  fd->m_diskName=name;
53  }
54  }
55  else if (count>1) // multiple occurrences of the same file name
56  {
57  //printf("Multiple occurrences of %s\n",name.data());
58  int i=0,j=0;
59  bool found=FALSE;
60  while (!found) // search for the common prefix of all paths
61  {
62  for (it.toFirst();(fd=it.current()) && fd->isReference();++it) { }
63  if (fd)
64  {
65  char c=fd->m_path.at(i);
66  if (c=='/') j=i; // remember last position of dirname
67  ++it;
68  while ((fd=it.current()) && !found)
69  {
70  if (!fd->isReference())
71  {
72  //printf("i=%d j=%d fd->path=`%s' fd->name=`%s'\n",i,j,fd->path.left(i).data(),fd->name().data());
73  if (i==(int)fd->m_path.length())
74  {
75  //warning("Input file %s found multiple times!\n"
76  // " The generated documentation for this file may not be correct!\n",fd->absFilePath().data());
77  found=TRUE;
78  }
79  else if (fd->m_path[i]!=c)
80  {
81  found=TRUE;
82  }
83  }
84  ++it;
85  }
86  i++;
87  }
88  }
89  for (it.toFirst();(fd=it.current());++it)
90  {
91  //printf("fd->setName(%s)\n",(fd->path.right(fd->path.length()-j-1)+name).data());
92  if (!fd->isReference())
93  {
94  QCString prefix = fd->m_path.right(fd->m_path.length()-j-1);
95  fd->setName(prefix+name);
96  //printf("!!!!!!!! non unique disk name=%s for fd=%s\n",(prefix+name).data(),fd->diskname.data());
97  fd->m_diskName=prefix+name;
98  }
99  }
100  }
101 }
102 
103 int FileName::compareValues(const FileDef *f1, const FileDef *f2) const
104 {
105  return qstricmp(f1->fileName(),f2->fileName());
106 }
107 
109  QListIterator<FileDef>(fname)
110 {
111 }
112 
114 {
115 }
116 
118 {
119 }
120 
122 {
123  FileNameListIterator it(*this);
124  FileName *fn;
125  for (;(fn=it.current());++it)
126  {
127  fn->generateDiskNames();
128  }
129 }
130 
132 {
133  return Config_getBool("FULL_PATH_NAMES") ?
134  qstricmp(f1->fullName(),f2->fullName()) :
135  qstricmp(f1->fileName(),f2->fileName());
136 }
137 
139  QListIterator<FileName>(fnlist)
140 {
141 }
142 
143 static bool getCaseSenseNames()
144 {
145  static bool caseSenseNames = Config_getBool("CASE_SENSE_NAMES");
146  return caseSenseNames;
147 }
148 
150 {
151 }
152 
const char * fullName() const
Definition: filename.h:32
QCString name
Definition: filename.h:37
void generateDiskNames()
Definition: filename.cpp:34
uint length() const
Definition: qcstring.h:195
virtual void setName(const char *name)
Definition: definition.cpp:396
char & at(uint i) const
Definition: qcstring.h:326
void generateDiskNames()
Definition: filename.cpp:121
FileName(const char *fn, const char *name)
Definition: filename.cpp:22
QCString m_path
Definition: filedef.h:220
const bool FALSE
Definition: qglobal.h:370
virtual bool isReference() const
int compareValues(const FileDef *item1, const FileDef *item2) const
Definition: filename.cpp:103
FileNameDict(uint size)
Definition: filename.cpp:149
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
int compareValues(const FileName *item1, const FileName *item2) const
Definition: filename.cpp:131
uint count() const
Definition: qlist.h:66
QAsciiDict< Entry > fn
int qstricmp(const char *str1, const char *str2)
Definition: qcstring.cpp:567
QCString right(uint len) const
Definition: qcstring.cpp:231
std::void_t< T > n
static bool getCaseSenseNames()
Definition: filename.cpp:143
A bunch of utility functions.
type * current() const
Definition: qlist.h:146
#define Config_getBool(val)
Definition: config.cpp:664
FileNameIterator(const FileName &list)
Definition: filename.cpp:108
QCString fileName() const
Definition: filedef.h:81
FileNameListIterator(const FileNameList &list)
Definition: filename.cpp:138
QCString fName
Definition: filename.h:38
const char * fileName() const
Definition: filename.h:31
~FileName()
Definition: filename.cpp:29
unsigned uint
Definition: qglobal.h:351
void setAutoDelete(bool enable)
Definition: qlist.h:99
const bool TRUE
Definition: qglobal.h:371
Definition: qlist.h:54
QCString m_diskName
Definition: filedef.h:222
type * toFirst()
Definition: qlist.h:135