|
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 "qreader_p.h" |
|
19 #include "qclucene_global_p.h" |
|
20 |
|
21 #include <CLucene.h> |
|
22 #include <CLucene/util/Reader.h> |
|
23 |
|
24 QT_BEGIN_NAMESPACE |
|
25 |
|
26 QCLuceneReaderPrivate::QCLuceneReaderPrivate() |
|
27 : QSharedData() |
|
28 { |
|
29 reader = 0; |
|
30 deleteCLuceneReader = true; |
|
31 } |
|
32 |
|
33 QCLuceneReaderPrivate::QCLuceneReaderPrivate(const QCLuceneReaderPrivate &other) |
|
34 : QSharedData() |
|
35 { |
|
36 reader = _CL_POINTER(other.reader); |
|
37 deleteCLuceneReader = other.deleteCLuceneReader; |
|
38 } |
|
39 |
|
40 QCLuceneReaderPrivate::~QCLuceneReaderPrivate() |
|
41 { |
|
42 if (deleteCLuceneReader) |
|
43 _CLDECDELETE(reader); |
|
44 } |
|
45 |
|
46 QCLuceneReader::QCLuceneReader() |
|
47 : d(new QCLuceneReaderPrivate()) |
|
48 { |
|
49 // nothing todo |
|
50 } |
|
51 |
|
52 QCLuceneReader::~QCLuceneReader() |
|
53 { |
|
54 // nothing todo |
|
55 } |
|
56 |
|
57 |
|
58 QCLuceneStringReader::QCLuceneStringReader(const QString &value) |
|
59 : QCLuceneReader() |
|
60 , string(QStringToTChar(value)) |
|
61 { |
|
62 d->reader = new lucene::util::StringReader(string); |
|
63 } |
|
64 |
|
65 QCLuceneStringReader::QCLuceneStringReader(const QString &value, qint32 length) |
|
66 : QCLuceneReader() |
|
67 , string(QStringToTChar(value)) |
|
68 { |
|
69 d->reader = new lucene::util::StringReader(string, int32_t(length)); |
|
70 } |
|
71 |
|
72 QCLuceneStringReader::QCLuceneStringReader(const QString &value, qint32 length, |
|
73 bool copyData) |
|
74 : QCLuceneReader() |
|
75 , string(QStringToTChar(value)) |
|
76 { |
|
77 d->reader = new lucene::util::StringReader(string, int32_t(length), copyData); |
|
78 } |
|
79 |
|
80 QCLuceneStringReader::~QCLuceneStringReader() |
|
81 { |
|
82 delete [] string; |
|
83 } |
|
84 |
|
85 |
|
86 QCLuceneFileReader::QCLuceneFileReader(const QString &path, const QString &encoding, |
|
87 qint32 cacheLength, qint32 cacheBuffer) |
|
88 : QCLuceneReader() |
|
89 { |
|
90 const QByteArray tmpPath = path.toLocal8Bit(); |
|
91 const QByteArray tmpEncoding = encoding.toAscii(); |
|
92 d->reader = new lucene::util::FileReader(tmpPath.constData(), |
|
93 tmpEncoding.constData(), int32_t(cacheLength), int32_t(cacheBuffer)); |
|
94 } |
|
95 |
|
96 QCLuceneFileReader::~QCLuceneFileReader() |
|
97 { |
|
98 // nothing todo |
|
99 } |
|
100 |
|
101 QT_END_NAMESPACE |