|
1 /****************************************************************************** |
|
2 * |
|
3 * |
|
4 * |
|
5 * Copyright (C) 1997-2008 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 "qtbc.h" |
|
22 #include <qintdict.h> |
|
23 #include <qlist.h> |
|
24 #include <qdict.h> |
|
25 #include <qintdict.h> |
|
26 #include <qvector.h> |
|
27 |
|
28 struct URL |
|
29 { |
|
30 URL(const char *n,const char *u) : name(n), url(u) {} |
|
31 QCString name; |
|
32 QCString url; |
|
33 }; |
|
34 |
|
35 |
|
36 struct URLInfo |
|
37 { |
|
38 URLInfo(int idx,int f) : urlIdx(idx), freq(f) {} |
|
39 int urlIdx; |
|
40 int freq; |
|
41 }; |
|
42 |
|
43 class IndexWord |
|
44 { |
|
45 public: |
|
46 IndexWord(const char *word); |
|
47 void addUrlIndex(int,bool); |
|
48 const QIntDict<URLInfo> &urls() const { return m_urls; } |
|
49 QCString word() const { return m_word; } |
|
50 |
|
51 private: |
|
52 QCString m_word; |
|
53 QIntDict<URLInfo> m_urls; |
|
54 }; |
|
55 |
|
56 class SearchIndex |
|
57 { |
|
58 public: |
|
59 SearchIndex(); |
|
60 void setCurrentDoc(const char *name,const char *baseName,const char *anchor=0); |
|
61 void addWord(const char *word,bool hiPriority,bool recurse=FALSE); |
|
62 void write(const char *file); |
|
63 private: |
|
64 QDict<IndexWord> m_words; |
|
65 QVector< QList<IndexWord> > m_index; |
|
66 QIntDict<URL> m_urls; |
|
67 int m_urlIndex; |
|
68 }; |
|
69 |
|
70 |
|
71 #endif |