searchindex.h
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 #ifndef _SEARCHINDEX_H
19 #define _SEARCHINDEX_H
20 
21 #include <qintdict.h>
22 #include <qlist.h>
23 #include <qdict.h>
24 #include <qintdict.h>
25 #include <qvector.h>
26 #include "sortdict.h"
27 #include "definition.h"
28 #include "util.h"
29 
30 class FTextStream;
31 class Definition;
32 class MemberDef;
33 
34 /*! Initialize the search indexer */
35 void initSearchIndexer();
36 /*! Cleanup the search indexer */
38 
39 //------- server side search index ----------------------
40 
41 struct URL
42 {
43  URL(const char *n,const char *u) : name(n), url(u) {}
46 };
47 
48 
49 struct URLInfo
50 {
51  URLInfo(int idx,int f) : urlIdx(idx), freq(f) {}
52  int urlIdx;
53  int freq;
54 };
55 
56 class IndexWord
57 {
58  public:
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; }
63 
64  private:
67 };
68 
70 {
71  public:
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; }
79  private:
81 };
82 
84 {
85  public:
86  SearchIndex();
87  void setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile);
88  void addWord(const char *word,bool hiPriority);
89  void write(const char *file);
90  private:
91  void addWord(const char *word,bool hiPrio,bool recurse);
92  QDict<IndexWord> m_words;
94  QDict<int> m_url2IdMap;
97 };
98 
99 
101 {
102  struct Private;
103  public:
106  void setCurrentDoc(Definition *ctx,const char *anchor,bool isSourceFile);
107  void addWord(const char *word,bool hiPriority);
108  void write(const char *file);
109  private:
111 };
112 
113 //------- client side search index ----------------------
114 
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
131 
132 class SearchDefinitionList : public QList<Definition>
133 {
134  public:
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; }
138  private:
141 };
142 
143 class SearchIndexList : public SDict< SearchDefinitionList >
144 {
145  public:
147  SearchIndexList(uint letter);
148  ~SearchIndexList();
149  void append(Definition *d);
150  uint letter() const;
151  private:
152  int compareValues(const SearchDefinitionList *md1, const SearchDefinitionList *md2) const;
154 };
155 
157 {
161 };
162 
166 
167 #endif
QCString word() const
Definition: searchindex.h:62
void writeJavascriptSearchIndex()
void finializeSearchIndexer()
virtual ~SearchIndexIntf()
Definition: searchindex.h:74
QDict< int > m_url2IdMap
Definition: searchindex.h:94
QVector< QList< IndexWord > > m_index
Definition: searchindex.h:93
QIntDict< URLInfo > m_urls
Definition: searchindex.h:66
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
Definition ElementType
Definition: searchindex.h:146
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
Kind kind() const
Definition: searchindex.h:78
QCString id() const
Definition: searchindex.h:136
Definition: sortdict.h:73
void initSearchIndexer()
QIntDict< URL > m_urls
Definition: searchindex.h:95
std::void_t< T > n
int m_urlIndex
Definition: searchindex.h:96
URLInfo(int idx, int f)
Definition: searchindex.h:51
A bunch of utility functions.
URL(const char *n, const char *u)
Definition: searchindex.h:43
SearchIndexIntf(Kind k)
Definition: searchindex.h:73
SearchDefinitionList(const QCString &id, const QCString &name)
Definition: searchindex.h:135
int freq
Definition: searchindex.h:53
const SearchIndexInfo * getSearchIndices()
const QIntDict< URLInfo > & urls() const
Definition: searchindex.h:61
static void setCurrentDoc(const QCString &anchor)
Definition: code.cpp:10966
int urlIdx
Definition: searchindex.h:52
QCString name
Definition: searchindex.h:44
QCString m_word
Definition: searchindex.h:65
QDict< IndexWord > m_words
Definition: searchindex.h:92
LetterToIndexMap< SearchIndexList > symbolList
Definition: searchindex.h:158
void createJavascriptSearchIndex()
unsigned uint
Definition: qglobal.h:351
union ptb::content::word::word word
QCString url
Definition: searchindex.h:45
Definition: qlist.h:54
QCString name() const
Definition: searchindex.h:137