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 | #include "qfield_p.h"
|
---|
19 | #include "qreader_p.h"
|
---|
20 | #include "qclucene_global_p.h"
|
---|
21 |
|
---|
22 | #include <CLucene.h>
|
---|
23 | #include <CLucene/document/Field.h>
|
---|
24 |
|
---|
25 | QT_BEGIN_NAMESPACE
|
---|
26 |
|
---|
27 | QCLuceneFieldPrivate::QCLuceneFieldPrivate()
|
---|
28 | : QSharedData()
|
---|
29 | {
|
---|
30 | field = 0;
|
---|
31 | deleteCLuceneField = true;
|
---|
32 | }
|
---|
33 |
|
---|
34 | QCLuceneFieldPrivate::QCLuceneFieldPrivate(const QCLuceneFieldPrivate &other)
|
---|
35 | : QSharedData()
|
---|
36 | {
|
---|
37 | field = _CL_POINTER(other.field);
|
---|
38 | deleteCLuceneField = other.deleteCLuceneField;
|
---|
39 | }
|
---|
40 |
|
---|
41 | QCLuceneFieldPrivate::~QCLuceneFieldPrivate()
|
---|
42 | {
|
---|
43 | if (deleteCLuceneField)
|
---|
44 | _CLDECDELETE(field);
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | QCLuceneField::QCLuceneField()
|
---|
49 | : d(new QCLuceneFieldPrivate())
|
---|
50 | , reader(0)
|
---|
51 | {
|
---|
52 | // nothing todo
|
---|
53 | }
|
---|
54 |
|
---|
55 | QCLuceneField::QCLuceneField(const QString &name, const QString &value, int configs)
|
---|
56 | : d(new QCLuceneFieldPrivate())
|
---|
57 | , reader(0)
|
---|
58 | {
|
---|
59 | TCHAR* fieldName = QStringToTChar(name);
|
---|
60 | TCHAR* fieldValue = QStringToTChar(value);
|
---|
61 |
|
---|
62 | d->field = new lucene::document::Field(fieldName, fieldValue, configs);
|
---|
63 |
|
---|
64 | delete [] fieldName;
|
---|
65 | delete [] fieldValue;
|
---|
66 | }
|
---|
67 |
|
---|
68 | QCLuceneField::QCLuceneField(const QString &name, QCLuceneReader *reader,
|
---|
69 | int configs)
|
---|
70 | : d(new QCLuceneFieldPrivate())
|
---|
71 | , reader(reader)
|
---|
72 | {
|
---|
73 | TCHAR* fieldName = QStringToTChar(name);
|
---|
74 |
|
---|
75 | reader->d->deleteCLuceneReader = false; // clucene takes ownership
|
---|
76 | d->field = new lucene::document::Field(fieldName, reader->d->reader, configs);
|
---|
77 |
|
---|
78 | delete [] fieldName;
|
---|
79 | }
|
---|
80 |
|
---|
81 | QCLuceneField::~QCLuceneField()
|
---|
82 | {
|
---|
83 | delete reader;
|
---|
84 | }
|
---|
85 |
|
---|
86 | QString QCLuceneField::name() const
|
---|
87 | {
|
---|
88 | return TCharToQString(d->field->name());
|
---|
89 | }
|
---|
90 |
|
---|
91 | QString QCLuceneField::stringValue() const
|
---|
92 | {
|
---|
93 | return TCharToQString((const TCHAR*)d->field->stringValue());
|
---|
94 | }
|
---|
95 |
|
---|
96 | QCLuceneReader* QCLuceneField::readerValue() const
|
---|
97 | {
|
---|
98 | return reader;
|
---|
99 | }
|
---|
100 |
|
---|
101 | bool QCLuceneField::isStored() const
|
---|
102 | {
|
---|
103 | return d->field->isStored();
|
---|
104 | }
|
---|
105 |
|
---|
106 | bool QCLuceneField::isIndexed() const
|
---|
107 | {
|
---|
108 | return d->field->isIndexed();
|
---|
109 | }
|
---|
110 |
|
---|
111 | bool QCLuceneField::isTokenized() const
|
---|
112 | {
|
---|
113 | return d->field->isTokenized();
|
---|
114 | }
|
---|
115 |
|
---|
116 | bool QCLuceneField::isCompressed() const
|
---|
117 | {
|
---|
118 | return d->field->isCompressed();
|
---|
119 | }
|
---|
120 |
|
---|
121 | void QCLuceneField::setConfig(int termVector)
|
---|
122 | {
|
---|
123 | d->field->setConfig(termVector);
|
---|
124 | }
|
---|
125 |
|
---|
126 | bool QCLuceneField::isTermVectorStored() const
|
---|
127 | {
|
---|
128 | return d->field->isTermVectorStored();
|
---|
129 | }
|
---|
130 |
|
---|
131 | bool QCLuceneField::isStoreOffsetWithTermVector() const
|
---|
132 | {
|
---|
133 | return d->field->isStoreOffsetWithTermVector();
|
---|
134 | }
|
---|
135 |
|
---|
136 | bool QCLuceneField::isStorePositionWithTermVector() const
|
---|
137 | {
|
---|
138 | return d->field->isStorePositionWithTermVector();
|
---|
139 | }
|
---|
140 |
|
---|
141 | qreal QCLuceneField::getBoost() const
|
---|
142 | {
|
---|
143 | return qreal(d->field->getBoost());
|
---|
144 | }
|
---|
145 |
|
---|
146 | void QCLuceneField::setBoost(qreal value)
|
---|
147 | {
|
---|
148 | d->field->setBoost(qreal(value));
|
---|
149 | }
|
---|
150 |
|
---|
151 | bool QCLuceneField::isBinary() const
|
---|
152 | {
|
---|
153 | return d->field->isBinary();
|
---|
154 | }
|
---|
155 |
|
---|
156 | bool QCLuceneField::getOmitNorms() const
|
---|
157 | {
|
---|
158 | return d->field->getOmitNorms();
|
---|
159 | }
|
---|
160 |
|
---|
161 | void QCLuceneField::setOmitNorms(bool omitNorms)
|
---|
162 | {
|
---|
163 | d->field->setOmitNorms(omitNorms);
|
---|
164 | }
|
---|
165 |
|
---|
166 | QString QCLuceneField::toString() const
|
---|
167 | {
|
---|
168 | return TCharToQString(d->field->toString());
|
---|
169 | }
|
---|
170 |
|
---|
171 | QT_END_NAMESPACE
|
---|