My Project
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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
35
void
initSearchIndexer
();
37
void
finializeSearchIndexer
();
38
39
//------- server side search index ----------------------
40
41
struct
URL
42
{
43
URL
(
const
char
*n,
const
char
*u) :
name
(n),
url
(u) {}
44
QCString
name
;
45
QCString
url
;
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
:
65
QCString
m_word
;
66
QIntDict<URLInfo>
m_urls
;
67
};
68
69
class
SearchIndexIntf
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
:
80
Kind
m_kind
;
81
};
82
83
class
SearchIndex
:
public
SearchIndexIntf
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
;
93
QVector< QList<IndexWord> >
m_index
;
94
QDict<int>
m_url2IdMap
;
95
QIntDict<URL>
m_urls
;
96
int
m_urlIndex
;
97
};
98
99
100
class
SearchIndexExternal
:
public
SearchIndexIntf
101
{
102
struct
Private
;
103
public
:
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);
109
private
:
110
Private
*
p
;
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
:
139
QCString
m_id
;
140
QCString
m_name
;
141
};
142
143
class
SearchIndexList
:
public
SDict
< SearchDefinitionList >
144
{
145
public
:
146
typedef
Definition
ElementType
;
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
;
153
uint
m_letter
;
154
};
155
156
struct
SearchIndexInfo
157
{
158
LetterToIndexMap<SearchIndexList>
symbolList
;
159
QCString
name
;
160
QCString
text
;
161
};
162
163
void
createJavascriptSearchIndex
();
164
void
writeJavascriptSearchIndex
();
165
const
SearchIndexInfo
*
getSearchIndices
();
166
167
#endif