Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / index.h
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 #ifndef INDEX_H
19 #define INDEX_H
20
21 #include <qlist.h>
22 #include <qcstring.h>
23
24 class Definition;
25 class MemberDef;
26 class OutputList;
27 class FTextStream;
28
29 /** \brief Abstract interface for index generators. */
30 class IndexIntf
31 {
32   public:
33     virtual ~IndexIntf() {}
34     virtual void initialize() = 0;
35     virtual void finalize() = 0;
36     virtual void incContentsDepth() = 0;
37     virtual void decContentsDepth() = 0;
38     virtual void addContentsItem(bool isDir, const char *name, const char *ref, 
39                                  const char *file, const char *anchor, bool separateIndex,
40                                  bool addToNavIndex,Definition *def) = 0;
41     virtual void addIndexItem(Definition *context,MemberDef *md,
42                               const char *sectionAnchor,const char *title) = 0;
43     virtual void addIndexFile(const char *name) = 0;
44     virtual void addImageFile(const char *name) = 0;
45     virtual void addStyleSheetFile(const char *name) = 0;
46 };
47
48 /** \brief A list of index interfaces.
49  *
50  *  This class itself implements all methods of IndexIntf and
51  *  just forwards the calls to all items in the list.
52  */
53 class IndexList : public IndexIntf
54 {
55   private:
56     QList<IndexIntf> m_intfs;
57
58     // --- foreach implementations for various number of arguments
59
60     void foreach(void (IndexIntf::*methodPtr)())
61     {
62       QListIterator<IndexIntf> li(m_intfs);
63       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)();
64     }
65
66     template<typename A1>
67     void foreach(void (IndexIntf::*methodPtr)(A1),A1 a1)
68     {
69       QListIterator<IndexIntf> li(m_intfs);
70       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1);
71     }
72
73     template<typename A1,typename A2,typename A3>
74     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3),A1 a1,A2 a2,A3 a3)
75     {
76       QListIterator<IndexIntf> li(m_intfs);
77       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3);
78     }
79
80     template<typename A1,typename A2,typename A3,typename A4>
81     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3,A4),A1 a1,A2 a2,A3 a3,A4 a4)
82     {
83       QListIterator<IndexIntf> li(m_intfs);
84       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3,a4);
85     }
86
87     template<typename A1,typename A2,typename A3,typename A4,typename A5>
88     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3,A4,A5),A1 a1,A2 a2,A3 a3,A4 a4,A5 a5)
89     {
90       QListIterator<IndexIntf> li(m_intfs);
91       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3,a4,a5);
92     }
93
94     template<typename A1,typename A2,typename A3,typename A4,typename A5,typename A6>
95     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3,A4,A5,A6),A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6)
96     {
97       QListIterator<IndexIntf> li(m_intfs);
98       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3,a4,a5,a6);
99     }
100
101     template<typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8>
102     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3,A4,A5,A6,A7,A8),A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8)
103     {
104       QListIterator<IndexIntf> li(m_intfs);
105       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3,a4,a5,a6,a7,a8);
106     }
107
108     template<typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8,typename A9>
109     void foreach(void (IndexIntf::*methodPtr)(A1,A2,A3,A4,A5,A6,A7,A8,A9),A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9)
110     {
111       QListIterator<IndexIntf> li(m_intfs);
112       for (li.toFirst();li.current();++li) (li.current()->*methodPtr)(a1,a2,a3,a4,a5,a6,a7,a8,a9);
113     }
114
115   public:
116     /** Creates a list of indexes */
117     IndexList() { m_intfs.setAutoDelete(TRUE); m_enabled=TRUE; }
118     /** Add an index generator to the list */
119     void addIndex(IndexIntf *intf) 
120     { m_intfs.append(intf); }
121     void disable()
122     { m_enabled = FALSE; }
123     void enable()
124     { m_enabled = TRUE; }
125     bool isEnabled() const
126     { return m_enabled; }
127
128     // IndexIntf implementation
129     void initialize() 
130     { foreach(&IndexIntf::initialize); }
131     void finalize() 
132     { foreach(&IndexIntf::finalize); }
133     void incContentsDepth()
134     { if (m_enabled) foreach(&IndexIntf::incContentsDepth); }
135     void decContentsDepth()
136     { if (m_enabled) foreach(&IndexIntf::decContentsDepth); }
137     void addContentsItem(bool isDir, const char *name, const char *ref, 
138                          const char *file, const char *anchor,bool separateIndex=FALSE,bool addToNavIndex=FALSE,
139                          Definition *def=0)
140     { if (m_enabled) foreach<bool,const char *,const char *,const char *,const char*,bool,bool,Definition *>
141              (&IndexIntf::addContentsItem,isDir,name,ref,file,anchor,separateIndex,addToNavIndex,def); }
142     void addIndexItem(Definition *context,MemberDef *md,const char *sectionAnchor=0,const char *title=0)
143     { if (m_enabled) foreach<Definition *,MemberDef *,const char *,const char *>
144              (&IndexIntf::addIndexItem,context,md,sectionAnchor,title); }
145     void addIndexFile(const char *name) 
146     { if (m_enabled) foreach<const char *>(&IndexIntf::addIndexFile,name); }
147     void addImageFile(const char *name) 
148     { if (m_enabled) foreach<const char *>(&IndexIntf::addImageFile,name); }
149     void addStyleSheetFile(const char *name) 
150     { if (m_enabled) foreach<const char *>(&IndexIntf::addStyleSheetFile,name); }
151
152   private:
153     bool m_enabled;
154 };
155
156
157 enum IndexSections
158 {
159   isTitlePageStart,
160   isTitlePageAuthor,
161   isMainPage,
162   isModuleIndex,
163   isDirIndex,
164   isNamespaceIndex,
165   isClassHierarchyIndex,
166   isCompoundIndex,
167   isFileIndex,
168   isPageIndex,
169   isModuleDocumentation,
170   isDirDocumentation,
171   isNamespaceDocumentation,
172   isClassDocumentation,
173   isFileDocumentation,
174   isExampleDocumentation,
175   isPageDocumentation,
176   isPageDocumentation2,
177   isEndIndex
178 };
179
180 enum HighlightedItem
181 {
182   HLI_None=0,
183   HLI_Main,
184   HLI_Modules,
185   //HLI_Directories,
186   HLI_Namespaces,
187   HLI_ClassHierarchy,
188   HLI_InterfaceHierarchy,
189   HLI_ExceptionHierarchy,
190   HLI_Classes,
191   HLI_Interfaces,
192   HLI_Structs,
193   HLI_Exceptions,
194   HLI_AnnotatedClasses,
195   HLI_AnnotatedInterfaces,
196   HLI_AnnotatedStructs,
197   HLI_AnnotatedExceptions,
198   HLI_Files,
199   HLI_NamespaceMembers,
200   HLI_Functions,
201   HLI_Globals,
202   HLI_Pages,
203   HLI_Examples,
204   HLI_Search,
205   HLI_UserGroup,
206
207   HLI_ClassVisible,
208   HLI_InterfaceVisible,
209   HLI_StructVisible,
210   HLI_ExceptionVisible,
211   HLI_NamespaceVisible,
212   HLI_FileVisible
213 };
214
215 enum ClassMemberHighlight
216 {
217   CMHL_All = 0,
218   CMHL_Functions,
219   CMHL_Variables,
220   CMHL_Typedefs,
221   CMHL_Enums,
222   CMHL_EnumValues,
223   CMHL_Properties,
224   CMHL_Events,
225   CMHL_Related,
226   CMHL_Total = CMHL_Related+1
227 };
228
229 enum FileMemberHighlight
230 {
231   FMHL_All = 0,
232   FMHL_Functions,
233   FMHL_Variables,
234   FMHL_Typedefs,
235   FMHL_Sequences,
236   FMHL_Dictionaries,
237   FMHL_Enums,
238   FMHL_EnumValues,
239   FMHL_Defines,
240   FMHL_Total = FMHL_Defines+1
241 };
242
243 enum NamespaceMemberHighlight
244 {
245   NMHL_All = 0,
246   NMHL_Functions,
247   NMHL_Variables,
248   NMHL_Typedefs,
249   NMHL_Sequences,
250   NMHL_Dictionaries,
251   NMHL_Enums,
252   NMHL_EnumValues,
253   NMHL_Total = NMHL_EnumValues+1
254 };
255
256 enum ClassHighlight
257 {
258   CHL_All = 0,
259   CHL_Classes,
260   CHL_Structs,
261   CHL_Unions,
262   CHL_Interfaces,
263   CHL_Protocols,
264   CHL_Categories,
265   CHL_Exceptions,
266   CHL_Total = CHL_Exceptions+1
267 };
268
269 void writeGraphInfo(OutputList &ol);
270 void writeIndexHierarchy(OutputList &ol);
271
272 void countDataStructures();
273
274 extern int annotatedClasses;
275 extern int annotatedInterfaces;
276 extern int annotatedStructs;
277 extern int annotatedExceptions;
278 extern int hierarchyClasses;
279 extern int hierarchyInterfaces;
280 extern int hierarchyExceptions;
281 extern int documentedFiles;
282 extern int documentedGroups;
283 extern int documentedNamespaces;
284 extern int indexedPages;
285 extern int documentedClassMembers[CMHL_Total];
286 extern int documentedFileMembers[FMHL_Total];
287 extern int documentedNamespaceMembers[NMHL_Total];
288 extern int documentedDirs;
289 extern int documentedHtmlFiles;
290 extern int documentedPages;
291
292 void startTitle(OutputList &ol,const char *fileName,Definition *def=0);
293 void endTitle(OutputList &ol,const char *fileName,const char *name);
294 void startFile(OutputList &ol,const char *name,const char *manName,
295                const char *title,HighlightedItem hli=HLI_None,
296                bool additionalIndices=FALSE,const char *altSidebarName=0);
297 void endFile(OutputList &ol,bool skipNavIndex=FALSE,bool skipEndContents=FALSE,
298              const QCString &navPath=QCString());
299 void endFileWithNavPath(Definition *d,OutputList &ol);
300
301 void initClassMemberIndices();
302 void initFileMemberIndices();
303 void initNamespaceMemberIndices();
304 void addClassMemberNameToIndex(MemberDef *md);
305 void addFileMemberNameToIndex(MemberDef *md);
306 void addNamespaceMemberNameToIndex(MemberDef *md);
307 QCString fixSpaces(const QCString &s);
308
309 #endif