1 /******************************************************************************
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
18 #ifndef _SEARCHINDEX_H
19 #define _SEARCHINDEX_H
27 #include "definition.h"
34 /*! Initialize the search indexer */
35 void initSearchIndexer();
36 /*! Cleanup the search indexer */
37 void finializeSearchIndexer();
39 //------- server side search index ----------------------
43 URL(const char *n,const char *u) : name(n), url(u) {}
51 URLInfo(int idx,int f) : urlIdx(idx), freq(f) {}
59 IndexWord(const char *word);
60 void addUrlIndex(int,bool);
61 const QIntDict<URLInfo> &urls() const { return m_urls; }
62 QCString word() const { return m_word; }
66 QIntDict<URLInfo> m_urls;
72 enum Kind { Internal, External };
73 SearchIndexIntf(Kind k) : m_kind(k) {}
74 virtual ~SearchIndexIntf() {}
75 virtual void setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile) = 0;
76 virtual void addWord(const char *word,bool hiPriority) = 0;
77 virtual void write(const char *file) = 0;
78 Kind kind() const { return m_kind; }
83 class SearchIndex : public SearchIndexIntf
87 void setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile);
88 void addWord(const char *word,bool hiPriority);
89 void write(const char *file);
91 void addWord(const char *word,bool hiPrio,bool recurse);
92 QDict<IndexWord> m_words;
93 QVector< QList<IndexWord> > m_index;
94 QDict<int> m_url2IdMap;
100 class SearchIndexExternal : public SearchIndexIntf
104 SearchIndexExternal();
105 ~SearchIndexExternal();
106 void setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile);
107 void addWord(const char *word,bool hiPriority);
108 void write(const char *file);
113 //------- client side search index ----------------------
115 #define SEARCH_INDEX_ALL 0
116 #define SEARCH_INDEX_CLASSES 1
117 #define SEARCH_INDEX_NAMESPACES 2
118 #define SEARCH_INDEX_FILES 3
119 #define SEARCH_INDEX_FUNCTIONS 4
120 #define SEARCH_INDEX_VARIABLES 5
121 #define SEARCH_INDEX_TYPEDEFS 6
122 #define SEARCH_INDEX_ENUMS 7
123 #define SEARCH_INDEX_ENUMVALUES 8
124 #define SEARCH_INDEX_PROPERTIES 9
125 #define SEARCH_INDEX_EVENTS 10
126 #define SEARCH_INDEX_RELATED 11
127 #define SEARCH_INDEX_DEFINES 12
128 #define SEARCH_INDEX_GROUPS 13
129 #define SEARCH_INDEX_PAGES 14
130 #define NUM_SEARCH_INDICES 15
132 class SearchDefinitionList : public QList<Definition>
135 SearchDefinitionList(const QCString &id,const QCString &name) : m_id(id), m_name(name) {}
136 QCString id() const { return m_id; }
137 QCString name() const { return m_name; }
143 class SearchIndexList : public SDict< SearchDefinitionList >
146 typedef Definition ElementType;
147 SearchIndexList(uint letter);
149 void append(Definition *d);
152 int compareValues(const SearchDefinitionList *md1, const SearchDefinitionList *md2) const;
156 struct SearchIndexInfo
158 LetterToIndexMap<SearchIndexList> symbolList;
163 void createJavascriptSearchIndex();
164 void writeJavascriptSearchIndex();
165 const SearchIndexInfo *getSearchIndices();