author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
3 |
** Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team. |
|
4 |
** All rights reserved. |
|
5 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
6 |
** Portion Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
#include "qterm_p.h" |
|
19 |
#include "qclucene_global_p.h" |
|
20 |
||
21 |
#include <CLucene.h> |
|
22 |
#include <CLucene/index/IndexReader.h> |
|
23 |
||
24 |
QT_BEGIN_NAMESPACE |
|
25 |
||
26 |
QCLuceneTermPrivate::QCLuceneTermPrivate() |
|
27 |
: QSharedData() |
|
28 |
{ |
|
29 |
term = 0; |
|
30 |
deleteCLuceneTerm = true; |
|
31 |
} |
|
32 |
||
33 |
QCLuceneTermPrivate::QCLuceneTermPrivate(const QCLuceneTermPrivate &other) |
|
34 |
: QSharedData() |
|
35 |
{ |
|
36 |
term = _CL_POINTER(other.term); |
|
37 |
deleteCLuceneTerm = other.deleteCLuceneTerm; |
|
38 |
} |
|
39 |
||
40 |
QCLuceneTermPrivate::~QCLuceneTermPrivate() |
|
41 |
{ |
|
42 |
if (deleteCLuceneTerm) |
|
43 |
_CLDECDELETE(term); |
|
44 |
} |
|
45 |
||
46 |
||
47 |
QCLuceneTerm::QCLuceneTerm() |
|
48 |
: d(new QCLuceneTermPrivate()) |
|
49 |
{ |
|
50 |
d->term = new lucene::index::Term(); |
|
51 |
} |
|
52 |
||
53 |
QCLuceneTerm::QCLuceneTerm(const QString &field, const QString &text) |
|
54 |
: d(new QCLuceneTermPrivate()) |
|
55 |
{ |
|
56 |
TCHAR *fieldName = QStringToTChar(field); |
|
57 |
TCHAR *termText = QStringToTChar(text); |
|
58 |
||
59 |
d->term = new lucene::index::Term(fieldName, termText); |
|
60 |
||
61 |
delete [] fieldName; |
|
62 |
delete [] termText; |
|
63 |
} |
|
64 |
||
65 |
QCLuceneTerm::QCLuceneTerm(const QCLuceneTerm &fieldTerm, const QString &text) |
|
66 |
: d(new QCLuceneTermPrivate()) |
|
67 |
{ |
|
68 |
TCHAR *termText = QStringToTChar(text); |
|
69 |
d->term = new lucene::index::Term(fieldTerm.d->term, termText); |
|
70 |
delete [] termText; |
|
71 |
} |
|
72 |
||
73 |
QCLuceneTerm::~QCLuceneTerm() |
|
74 |
{ |
|
75 |
// nothing todo |
|
76 |
} |
|
77 |
||
78 |
QString QCLuceneTerm::field() const |
|
79 |
{ |
|
80 |
return TCharToQString(d->term->field()); |
|
81 |
} |
|
82 |
||
83 |
QString QCLuceneTerm::text() const |
|
84 |
{ |
|
85 |
return TCharToQString(d->term->text()); |
|
86 |
} |
|
87 |
||
88 |
void QCLuceneTerm::set(const QString &field, const QString &text) |
|
89 |
{ |
|
90 |
set(field, text, true); |
|
91 |
} |
|
92 |
||
93 |
void QCLuceneTerm::set(const QCLuceneTerm &fieldTerm, const QString &text) |
|
94 |
{ |
|
95 |
set(fieldTerm.field(), text, false); |
|
96 |
} |
|
97 |
||
98 |
void QCLuceneTerm::set(const QString &field, const QString &text, bool internField) |
|
99 |
{ |
|
100 |
TCHAR *fieldName = QStringToTChar(field); |
|
101 |
TCHAR *termText = QStringToTChar(text); |
|
102 |
||
103 |
d->term->set(fieldName, termText, internField); |
|
104 |
||
105 |
delete [] fieldName; |
|
106 |
delete [] termText; |
|
107 |
} |
|
108 |
||
109 |
bool QCLuceneTerm::equals(const QCLuceneTerm &other) const |
|
110 |
{ |
|
111 |
return d->term->equals(other.d->term); |
|
112 |
} |
|
113 |
||
114 |
qint32 QCLuceneTerm::compareTo(const QCLuceneTerm &other) const |
|
115 |
{ |
|
116 |
return quint32(d->term->compareTo(other.d->term)); |
|
117 |
} |
|
118 |
||
119 |
QString QCLuceneTerm::toString() const |
|
120 |
{ |
|
121 |
return TCharToQString(d->term->toString()); |
|
122 |
} |
|
123 |
||
124 |
quint32 QCLuceneTerm::hashCode() const |
|
125 |
{ |
|
126 |
return quint32(d->term->hashCode()); |
|
127 |
} |
|
128 |
||
129 |
quint32 QCLuceneTerm::textLength() const |
|
130 |
{ |
|
131 |
return quint32(d->term->textLength()); |
|
132 |
} |
|
133 |
||
134 |
QT_END_NAMESPACE |