1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
---|
5 | **
|
---|
6 | ** This file is part of the QCLucene library and is distributable under
|
---|
7 | ** the terms of the LGPL license as specified in the license.txt file.
|
---|
8 | **
|
---|
9 | ****************************************************************************/
|
---|
10 |
|
---|
11 | #include "qfield_p.h"
|
---|
12 | #include "qreader_p.h"
|
---|
13 | #include "qclucene_global_p.h"
|
---|
14 |
|
---|
15 | #include <CLucene.h>
|
---|
16 | #include <CLucene/document/Field.h>
|
---|
17 |
|
---|
18 | QT_BEGIN_NAMESPACE
|
---|
19 |
|
---|
20 | QCLuceneFieldPrivate::QCLuceneFieldPrivate()
|
---|
21 | : QSharedData()
|
---|
22 | {
|
---|
23 | field = 0;
|
---|
24 | deleteCLuceneField = true;
|
---|
25 | }
|
---|
26 |
|
---|
27 | QCLuceneFieldPrivate::QCLuceneFieldPrivate(const QCLuceneFieldPrivate &other)
|
---|
28 | : QSharedData()
|
---|
29 | {
|
---|
30 | field = _CL_POINTER(other.field);
|
---|
31 | }
|
---|
32 |
|
---|
33 | QCLuceneFieldPrivate::~QCLuceneFieldPrivate()
|
---|
34 | {
|
---|
35 | if (deleteCLuceneField)
|
---|
36 | _CLDECDELETE(field);
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | QCLuceneField::QCLuceneField()
|
---|
41 | : d(new QCLuceneFieldPrivate())
|
---|
42 | , reader(0)
|
---|
43 | {
|
---|
44 | // nothing todo
|
---|
45 | }
|
---|
46 |
|
---|
47 | QCLuceneField::QCLuceneField(const QString &name, const QString &value, int configs)
|
---|
48 | : d(new QCLuceneFieldPrivate())
|
---|
49 | , reader(0)
|
---|
50 | {
|
---|
51 | TCHAR* fieldName = QStringToTChar(name);
|
---|
52 | TCHAR* fieldValue = QStringToTChar(value);
|
---|
53 |
|
---|
54 | d->field = new lucene::document::Field(fieldName, fieldValue, configs);
|
---|
55 |
|
---|
56 | delete [] fieldName;
|
---|
57 | delete [] fieldValue;
|
---|
58 | }
|
---|
59 |
|
---|
60 | QCLuceneField::QCLuceneField(const QString &name, QCLuceneReader *reader,
|
---|
61 | int configs)
|
---|
62 | : d(new QCLuceneFieldPrivate())
|
---|
63 | , reader(reader)
|
---|
64 | {
|
---|
65 | TCHAR* fieldName = QStringToTChar(name);
|
---|
66 |
|
---|
67 | reader->d->deleteCLuceneReader = false; // clucene takes ownership
|
---|
68 | d->field = new lucene::document::Field(fieldName, reader->d->reader, configs);
|
---|
69 |
|
---|
70 | delete [] fieldName;
|
---|
71 | }
|
---|
72 |
|
---|
73 | QCLuceneField::~QCLuceneField()
|
---|
74 | {
|
---|
75 | delete reader;
|
---|
76 | }
|
---|
77 |
|
---|
78 | QString QCLuceneField::name() const
|
---|
79 | {
|
---|
80 | return TCharToQString(d->field->name());
|
---|
81 | }
|
---|
82 |
|
---|
83 | QString QCLuceneField::stringValue() const
|
---|
84 | {
|
---|
85 | return TCharToQString((const TCHAR*)d->field->stringValue());
|
---|
86 | }
|
---|
87 |
|
---|
88 | QCLuceneReader* QCLuceneField::readerValue() const
|
---|
89 | {
|
---|
90 | return reader;
|
---|
91 | }
|
---|
92 |
|
---|
93 | bool QCLuceneField::isStored() const
|
---|
94 | {
|
---|
95 | return d->field->isStored();
|
---|
96 | }
|
---|
97 |
|
---|
98 | bool QCLuceneField::isIndexed() const
|
---|
99 | {
|
---|
100 | return d->field->isIndexed();
|
---|
101 | }
|
---|
102 |
|
---|
103 | bool QCLuceneField::isTokenized() const
|
---|
104 | {
|
---|
105 | return d->field->isTokenized();
|
---|
106 | }
|
---|
107 |
|
---|
108 | bool QCLuceneField::isCompressed() const
|
---|
109 | {
|
---|
110 | return d->field->isCompressed();
|
---|
111 | }
|
---|
112 |
|
---|
113 | void QCLuceneField::setConfig(int termVector)
|
---|
114 | {
|
---|
115 | d->field->setConfig(termVector);
|
---|
116 | }
|
---|
117 |
|
---|
118 | bool QCLuceneField::isTermVectorStored() const
|
---|
119 | {
|
---|
120 | return d->field->isTermVectorStored();
|
---|
121 | }
|
---|
122 |
|
---|
123 | bool QCLuceneField::isStoreOffsetWithTermVector() const
|
---|
124 | {
|
---|
125 | return d->field->isStoreOffsetWithTermVector();
|
---|
126 | }
|
---|
127 |
|
---|
128 | bool QCLuceneField::isStorePositionWithTermVector() const
|
---|
129 | {
|
---|
130 | return d->field->isStorePositionWithTermVector();
|
---|
131 | }
|
---|
132 |
|
---|
133 | qreal QCLuceneField::getBoost() const
|
---|
134 | {
|
---|
135 | return qreal(d->field->getBoost());
|
---|
136 | }
|
---|
137 |
|
---|
138 | void QCLuceneField::setBoost(qreal value)
|
---|
139 | {
|
---|
140 | d->field->setBoost(qreal(value));
|
---|
141 | }
|
---|
142 |
|
---|
143 | bool QCLuceneField::isBinary() const
|
---|
144 | {
|
---|
145 | return d->field->isBinary();
|
---|
146 | }
|
---|
147 |
|
---|
148 | bool QCLuceneField::getOmitNorms() const
|
---|
149 | {
|
---|
150 | return d->field->getOmitNorms();
|
---|
151 | }
|
---|
152 |
|
---|
153 | void QCLuceneField::setOmitNorms(bool omitNorms)
|
---|
154 | {
|
---|
155 | d->field->setOmitNorms(omitNorms);
|
---|
156 | }
|
---|
157 |
|
---|
158 | QString QCLuceneField::toString() const
|
---|
159 | {
|
---|
160 | return TCharToQString(d->field->toString());
|
---|
161 | }
|
---|
162 |
|
---|
163 | QT_END_NAMESPACE
|
---|