|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team. |
|
4 ** All rights reserved. |
|
5 ** |
|
6 ** Portion Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
7 ** All rights reserved. |
|
8 ** |
|
9 ** This file may be used under the terms of the GNU Lesser General Public |
|
10 ** License version 2.1 as published by the Free Software Foundation and |
|
11 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
12 ** Please review the following information to ensure the GNU Lesser General |
|
13 ** Public License version 2.1 requirements will be met: |
|
14 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
15 ** |
|
16 ****************************************************************************/ |
|
17 |
|
18 #ifndef QQUERY_P_H |
|
19 #define QQUERY_P_H |
|
20 |
|
21 // |
|
22 // W A R N I N G |
|
23 // ------------- |
|
24 // |
|
25 // This file is not part of the Qt API. It exists for the convenience |
|
26 // of the help generator tools. This header file may change from version |
|
27 // to version without notice, or even be removed. |
|
28 // |
|
29 // We mean it. |
|
30 // |
|
31 |
|
32 #include "qterm_p.h" |
|
33 #include "qclucene_global_p.h" |
|
34 |
|
35 #include <QtCore/QList> |
|
36 #include <QtCore/QString> |
|
37 #include <QtCore/QSharedDataPointer> |
|
38 #include <QtCore/QSharedData> |
|
39 |
|
40 CL_NS_DEF(search) |
|
41 class Query; |
|
42 CL_NS_END |
|
43 CL_NS_USE(search) |
|
44 |
|
45 QT_BEGIN_NAMESPACE |
|
46 |
|
47 class QCLuceneHits; |
|
48 class QCLuceneTermQuery; |
|
49 class QCLuceneRangeQuery; |
|
50 class QCLuceneQueryParser; |
|
51 class QCLucenePrefixQuery; |
|
52 class QCLuceneBooleanQuery; |
|
53 class QCLucenePhraseQuery; |
|
54 |
|
55 class QHELP_EXPORT QCLuceneQueryPrivate : public QSharedData |
|
56 { |
|
57 public: |
|
58 QCLuceneQueryPrivate(); |
|
59 QCLuceneQueryPrivate(const QCLuceneQueryPrivate &other); |
|
60 |
|
61 ~QCLuceneQueryPrivate(); |
|
62 |
|
63 Query *query; |
|
64 bool deleteCLuceneQuery; |
|
65 |
|
66 private: |
|
67 QCLuceneQueryPrivate &operator=(const QCLuceneQueryPrivate &other); |
|
68 }; |
|
69 |
|
70 class QHELP_EXPORT QCLuceneQuery |
|
71 { |
|
72 public: |
|
73 virtual ~QCLuceneQuery(); |
|
74 |
|
75 void setBoost(qreal boost); |
|
76 qreal getBoost() const; |
|
77 QString getQueryName() const; |
|
78 bool instanceOf(const QString &other) const; |
|
79 QString toString(const QString &field) const; |
|
80 quint32 hashCode() const; |
|
81 QString toString() const; |
|
82 bool equals(const QCLuceneQuery &other) const; |
|
83 |
|
84 protected: |
|
85 friend class QCLuceneHits; |
|
86 friend class QCLuceneTermQuery; |
|
87 friend class QCLuceneRangeQuery; |
|
88 friend class QCLucenePrefixQuery; |
|
89 friend class QCLuceneQueryParser; |
|
90 friend class QCLuceneBooleanQuery; |
|
91 friend class QCLucenePhraseQuery; |
|
92 QSharedDataPointer<QCLuceneQueryPrivate> d; |
|
93 |
|
94 private: |
|
95 QCLuceneQuery(); |
|
96 }; |
|
97 |
|
98 class QHELP_EXPORT QCLucenePrefixQuery : public QCLuceneQuery |
|
99 { |
|
100 public: |
|
101 QCLucenePrefixQuery(const QCLuceneTerm &prefix); |
|
102 ~QCLucenePrefixQuery(); |
|
103 |
|
104 static QString getClassName(); |
|
105 |
|
106 QCLuceneTerm getPrefix() const; |
|
107 |
|
108 private: |
|
109 QCLuceneTerm prefix; |
|
110 }; |
|
111 |
|
112 class QHELP_EXPORT QCLuceneRangeQuery : public QCLuceneQuery |
|
113 { |
|
114 public: |
|
115 QCLuceneRangeQuery(const QCLuceneTerm &lowerTerm, |
|
116 const QCLuceneTerm &upperTerm, bool inclusive); |
|
117 ~QCLuceneRangeQuery(); |
|
118 |
|
119 static QString getClassName(); |
|
120 |
|
121 QCLuceneTerm getLowerTerm() const; |
|
122 QCLuceneTerm getUpperTerm() const; |
|
123 |
|
124 bool isInclusive() const; |
|
125 QString getField() const; |
|
126 |
|
127 private: |
|
128 QCLuceneTerm lowerTerm; |
|
129 QCLuceneTerm upperTerm; |
|
130 }; |
|
131 |
|
132 class QHELP_EXPORT QCLuceneTermQuery : public QCLuceneQuery |
|
133 { |
|
134 public: |
|
135 QCLuceneTermQuery(const QCLuceneTerm &term); |
|
136 ~QCLuceneTermQuery(); |
|
137 |
|
138 static QString getClassName(); |
|
139 |
|
140 QCLuceneTerm getTerm() const; |
|
141 |
|
142 private: |
|
143 QCLuceneTerm term; |
|
144 }; |
|
145 |
|
146 class QHELP_EXPORT QCLuceneBooleanQuery : public QCLuceneQuery |
|
147 { |
|
148 public: |
|
149 QCLuceneBooleanQuery(); |
|
150 ~QCLuceneBooleanQuery(); |
|
151 |
|
152 static QString getClassName(); |
|
153 |
|
154 quint32 getClauseCount() const; |
|
155 quint32 getMaxClauseCount() const; |
|
156 void setMaxClauseCount(quint32 maxClauseCount); |
|
157 |
|
158 void add(QCLuceneQuery *query, bool required, bool prohibited); |
|
159 void add(QCLuceneQuery *query, bool delQuery, bool required, bool prohibited); |
|
160 |
|
161 private: |
|
162 QList<QCLuceneQuery*> queries; |
|
163 }; |
|
164 |
|
165 class QHELP_EXPORT QCLucenePhraseQuery : public QCLuceneQuery |
|
166 { |
|
167 public: |
|
168 QCLucenePhraseQuery(); |
|
169 ~QCLucenePhraseQuery(); |
|
170 |
|
171 static QString getClassName(); |
|
172 |
|
173 qint32 getSlop() const; |
|
174 void setSlop(const qint32 slop); |
|
175 |
|
176 void addTerm(const QCLuceneTerm &term); |
|
177 void addTerm(const QCLuceneTerm &term, qint32 position); |
|
178 |
|
179 QString getFieldName() const; |
|
180 QList<QCLuceneTerm> getTerms() const; |
|
181 |
|
182 private: |
|
183 QList<QCLuceneTerm> termList; |
|
184 }; |
|
185 |
|
186 QT_END_NAMESPACE |
|
187 |
|
188 #endif // QQUERY_P_H |