source: branches/4.5.1/tools/assistant/lib/fulltextsearch/qterm.cpp

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

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 2.8 KB
Line 
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 "qterm_p.h"
12#include "qclucene_global_p.h"
13
14#include <CLucene.h>
15#include <CLucene/index/IndexReader.h>
16
17QT_BEGIN_NAMESPACE
18
19QCLuceneTermPrivate::QCLuceneTermPrivate()
20 : QSharedData()
21{
22 term = 0;
23 deleteCLuceneTerm = true;
24}
25
26QCLuceneTermPrivate::QCLuceneTermPrivate(const QCLuceneTermPrivate &other)
27 : QSharedData()
28{
29 term = _CL_POINTER(other.term);
30}
31
32QCLuceneTermPrivate::~QCLuceneTermPrivate()
33{
34 if (deleteCLuceneTerm)
35 _CLDECDELETE(term);
36}
37
38
39QCLuceneTerm::QCLuceneTerm()
40 : d(new QCLuceneTermPrivate())
41{
42 d->term = new lucene::index::Term();
43}
44
45QCLuceneTerm::QCLuceneTerm(const QString &field, const QString &text)
46 : d(new QCLuceneTermPrivate())
47{
48 TCHAR *fieldName = QStringToTChar(field);
49 TCHAR *termText = QStringToTChar(text);
50
51 d->term = new lucene::index::Term(fieldName, termText);
52
53 delete [] fieldName;
54 delete [] termText;
55}
56
57QCLuceneTerm::QCLuceneTerm(const QCLuceneTerm &fieldTerm, const QString &text)
58 : d(new QCLuceneTermPrivate())
59{
60 TCHAR *termText = QStringToTChar(text);
61 d->term = new lucene::index::Term(fieldTerm.d->term, termText);
62 delete [] termText;
63}
64
65QCLuceneTerm::~QCLuceneTerm()
66{
67 // nothing todo
68}
69
70QString QCLuceneTerm::field() const
71{
72 return TCharToQString(d->term->field());
73}
74
75QString QCLuceneTerm::text() const
76{
77 return TCharToQString(d->term->text());
78}
79
80void QCLuceneTerm::set(const QString &field, const QString &text)
81{
82 set(field, text, true);
83}
84
85void QCLuceneTerm::set(const QCLuceneTerm &fieldTerm, const QString &text)
86{
87 set(fieldTerm.field(), text, false);
88}
89
90void QCLuceneTerm::set(const QString &field, const QString &text, bool internField)
91{
92 TCHAR *fieldName = QStringToTChar(field);
93 TCHAR *termText = QStringToTChar(text);
94
95 d->term->set(fieldName, termText, internField);
96
97 delete [] fieldName;
98 delete [] termText;
99}
100
101bool QCLuceneTerm::equals(const QCLuceneTerm &other) const
102{
103 return d->term->equals(other.d->term);
104}
105
106qint32 QCLuceneTerm::compareTo(const QCLuceneTerm &other) const
107{
108 return quint32(d->term->compareTo(other.d->term));
109}
110
111QString QCLuceneTerm::toString() const
112{
113 return TCharToQString(d->term->toString());
114}
115
116quint32 QCLuceneTerm::hashCode() const
117{
118 return quint32(d->term->hashCode());
119}
120
121quint32 QCLuceneTerm::textLength() const
122{
123 return quint32(d->term->textLength());
124}
125
126QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.