source: trunk/tools/assistant/lib/fulltextsearch/qterm.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 3.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team.
4** All rights reserved.
5**
6** Portion Copyright (C) 2011 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#include "qterm_p.h"
19#include "qclucene_global_p.h"
20
21#include <CLucene.h>
22#include <CLucene/index/IndexReader.h>
23
24QT_BEGIN_NAMESPACE
25
26QCLuceneTermPrivate::QCLuceneTermPrivate()
27 : QSharedData()
28{
29 term = 0;
30 deleteCLuceneTerm = true;
31}
32
33QCLuceneTermPrivate::QCLuceneTermPrivate(const QCLuceneTermPrivate &other)
34 : QSharedData()
35{
36 term = _CL_POINTER(other.term);
37 deleteCLuceneTerm = other.deleteCLuceneTerm;
38}
39
40QCLuceneTermPrivate::~QCLuceneTermPrivate()
41{
42 if (deleteCLuceneTerm)
43 _CLDECDELETE(term);
44}
45
46
47QCLuceneTerm::QCLuceneTerm()
48 : d(new QCLuceneTermPrivate())
49{
50 d->term = new lucene::index::Term();
51}
52
53QCLuceneTerm::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
65QCLuceneTerm::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
73QCLuceneTerm::~QCLuceneTerm()
74{
75 // nothing todo
76}
77
78QString QCLuceneTerm::field() const
79{
80 return TCharToQString(d->term->field());
81}
82
83QString QCLuceneTerm::text() const
84{
85 return TCharToQString(d->term->text());
86}
87
88void QCLuceneTerm::set(const QString &field, const QString &text)
89{
90 set(field, text, true);
91}
92
93void QCLuceneTerm::set(const QCLuceneTerm &fieldTerm, const QString &text)
94{
95 set(fieldTerm.field(), text, false);
96}
97
98void 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
109bool QCLuceneTerm::equals(const QCLuceneTerm &other) const
110{
111 return d->term->equals(other.d->term);
112}
113
114qint32 QCLuceneTerm::compareTo(const QCLuceneTerm &other) const
115{
116 return quint32(d->term->compareTo(other.d->term));
117}
118
119QString QCLuceneTerm::toString() const
120{
121 return TCharToQString(d->term->toString());
122}
123
124quint32 QCLuceneTerm::hashCode() const
125{
126 return quint32(d->term->hashCode());
127}
128
129quint32 QCLuceneTerm::textLength() const
130{
131 return quint32(d->term->textLength());
132}
133
134QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.