2
* Copyright (C) 2014 Vishesh Handa <me@vhanda.in>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef BALOO_XAPIANDATABASE_H
21
#define BALOO_XAPIANDATABASE_H
24
#include "xapian_export.h"
34
class BALOO_XAPIAN_EXPORT XapianDatabase
38
* Create the Xapian db at path \p path. The parameter \p
39
* writeOnly locks the database as long as this object is
42
XapianDatabase(const QString& path, bool writeOnly = false);
44
void replaceDocument(uint id, const Xapian::Document& doc);
45
void deleteDocument(uint id);
48
* Commit all the pending changes. This may not commit
49
* at this instance as the db might be locked by another process
50
* It emits the committed signal on completion
54
XapianDocument document(uint id);
57
* A pointer to the actual db. Only use this when doing queries
59
Xapian::Database* db() {
67
Xapian::Database* m_db;
68
Xapian::WritableDatabase m_wDb;
70
typedef QPair<Xapian::docid, Xapian::Document> DocIdPair;
71
QVector<DocIdPair> m_docsToAdd;
72
QVector<uint> m_docsToRemove;
77
Xapian::WritableDatabase createWritableDb();
82
#endif // BALOO_XAPIANDATABASE_H