Imported Upstream version 1.8.8
[platform/upstream/doxygen.git] / src / classlist.cpp
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2014 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 "classlist.h"
19 #include "config.h"
20 #include "util.h"
21 #include "outputlist.h"
22 #include "language.h"
23 #include "doxygen.h"
24 #include "vhdldocgen.h"
25 #include "defargs.h"
26 #include "arguments.h"
27 #include "groupdef.h"
28
29 ClassList::ClassList() : QList<ClassDef>()
30 {
31 }
32
33 ClassList::~ClassList()
34 {
35 }
36
37 static int compItems(const ClassDef *c1,const ClassDef *c2)
38 {
39   static bool b = Config_getBool("SORT_BY_SCOPE_NAME");
40   if (b)
41   {
42      return qstricmp(c1->name(), c2->name());
43   }
44   else
45   {
46      return qstricmp(c1->className(), c2->className());
47   }
48 }
49
50 int ClassList::compareValues(const ClassDef *item1, const ClassDef *item2) const
51 {
52   return compItems(item1,item2);
53 }
54
55 int ClassSDict::compareValues(const ClassDef *item1, const ClassDef *item2) const
56 {
57   return compItems(item1,item2);
58 }
59
60 ClassListIterator::ClassListIterator(const ClassList &cllist) :
61   QListIterator<ClassDef>(cllist)
62 {
63 }
64
65 bool ClassSDict::declVisible(const ClassDef::CompoundType *filter) const
66 {
67   static bool hideUndocClasses = Config_getBool("HIDE_UNDOC_CLASSES");
68   static bool extractLocalClasses = Config_getBool("EXTRACT_LOCAL_CLASSES");
69   if (count()>0)
70   {
71     ClassSDict::Iterator sdi(*this);
72     ClassDef *cd=0;
73     for (sdi.toFirst();(cd=sdi.current());++sdi)
74     {
75       if (cd->name().find('@')==-1 &&
76           (filter==0 || *filter==cd->compoundType())
77          )
78       {
79         bool isLink = cd->isLinkable();
80         if (isLink ||
81              (!hideUndocClasses &&
82               (!cd->isLocal() || extractLocalClasses)
83              )
84            )
85         {
86           return TRUE;
87         }
88       }
89     }
90   }
91   return FALSE;
92 }
93
94 void ClassSDict::writeDeclaration(OutputList &ol,const ClassDef::CompoundType *filter,
95                                   const char *header,bool localNames)
96 {
97   static bool extractPrivate = Config_getBool("EXTRACT_PRIVATE");
98   if (count()>0)
99   {
100     ClassSDict::Iterator sdi(*this);
101     ClassDef *cd=0;
102     bool found=FALSE;
103     for (sdi.toFirst();(cd=sdi.current());++sdi)
104     {
105       //printf("  ClassSDict::writeDeclaration for %s\n",cd->name().data());
106       if (cd->name().find('@')==-1 &&
107           !cd->isExtension() &&
108           (cd->protection()!=Private || extractPrivate) &&
109           (filter==0 || *filter==cd->compoundType())
110          )
111       {
112         cd->writeDeclarationLink(ol,found,header,localNames);
113       }
114     }
115     if (found) ol.endMemberList();
116   }
117 }
118
119 void ClassSDict::writeDocumentation(OutputList &ol,Definition * container)
120 {
121   static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
122
123   static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES");
124   static bool inlineSimpleClasses = Config_getBool("INLINE_SIMPLE_STRUCTS");
125   if (!inlineGroupedClasses && !inlineSimpleClasses) return;
126
127   if (count()>0)
128   {
129     bool found=FALSE;
130
131     ClassSDict::Iterator sdi(*this);
132     ClassDef *cd=0;
133     for (sdi.toFirst();(cd=sdi.current());++sdi)
134     {
135       //printf("%s:writeDocumentation() %p linkable=%d embedded=%d container=%p partOfGroups=%d\n",
136       //  cd->name().data(),cd->getOuterScope(),cd->isLinkableInProject(),cd->isEmbeddedInOuterScope(),
137       //  container,cd->partOfGroups() ? cd->partOfGroups()->count() : 0);
138
139       if (cd->name().find('@')==-1 &&
140           cd->isLinkableInProject() &&
141           cd->isEmbeddedInOuterScope() &&
142           (container==0 || cd->partOfGroups()==0) // if container==0 -> show as part of the group docs, otherwise only show if not part of a group
143          )
144       {
145         //printf("  showing class %s\n",cd->name().data());
146         if (!found)
147         {
148           ol.writeRuler();
149           ol.startGroupHeader();
150           ol.parseText(fortranOpt?theTranslator->trTypeDocumentation():
151               theTranslator->trClassDocumentation());
152           ol.endGroupHeader();
153           found=TRUE;
154         }
155         cd->writeInlineDocumentation(ol);
156       }
157     }
158   }
159 }
160
161 //-------------------------------------------
162
163 void GenericsSDict::insert(const QCString &key,ClassDef *cd)
164 {
165   int i=key.find('<');
166   if (i==-1) return;
167   ArgumentList argList;
168   stringToArgumentList(key.mid(i),&argList);
169   int c = argList.count();
170   if (c==0) return;
171   GenericsCollection *collection = m_dict.find(key.left(i));
172   if (collection==0) // new name
173   {
174     collection = new GenericsCollection;
175     m_dict.append(key.left(i),collection);
176   }
177   if (collection->find(c)==0) // should always be 0!
178   {
179     collection->insert(c,cd);
180   }
181 }
182
183 ClassDef *GenericsSDict::find(const QCString &key)
184 {
185   int i=key.find('<');
186   if (i==-1)
187   {
188     GenericsCollection *collection = m_dict.find(key);
189     if (collection && collection->count()==1)
190     {
191       QIntDictIterator<ClassDef> it(*collection);
192       return it.current();
193     }
194   }
195   else
196   {
197     GenericsCollection *collection = m_dict.find(key.left(i));
198     if (collection)
199     {
200       ArgumentList argList;
201       stringToArgumentList(key.mid(i),&argList);
202       int c = argList.count();
203       return collection->find(c);
204     }
205   }
206   return 0;
207 }
208
209
210
211