~ubuntu-branches/ubuntu/trusty/baloo/trusty-updates

« back to all changes in this revision

Viewing changes to .pc/upstream_git/0045-ContactIndexer-Port-to-the-Baloo-Xapian-library.patch/src/xapian/xapiandatabase.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-04-10 21:32:59 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140410213259-b3hkzveqwe4hd3ax
Tags: 4:4.13.0-0ubuntu1
New upstream KDE Software Compilation release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2014  Vishesh Handa <me@vhanda.in>
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
17
 
 *
18
 
 */
19
 
 
20
 
#ifndef BALOO_XAPIANDATABASE_H
21
 
#define BALOO_XAPIANDATABASE_H
22
 
 
23
 
#include <xapian.h>
24
 
#include "xapian_export.h"
25
 
 
26
 
#include <QString>
27
 
#include <QPair>
28
 
#include <QVector>
29
 
 
30
 
namespace Baloo {
31
 
 
32
 
class XapianDocument;
33
 
 
34
 
class BALOO_XAPIAN_EXPORT XapianDatabase
35
 
{
36
 
public:
37
 
    /**
38
 
     * Create the Xapian db at path \p path. The parameter \p
39
 
     * writeOnly locks the database as long as this object is
40
 
     * valid
41
 
     */
42
 
    XapianDatabase(const QString& path, bool writeOnly = false);
43
 
 
44
 
    void replaceDocument(uint id, const Xapian::Document& doc);
45
 
    void deleteDocument(uint id);
46
 
 
47
 
    /**
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
51
 
     */
52
 
    void commit();
53
 
 
54
 
    XapianDocument document(uint id);
55
 
 
56
 
    /**
57
 
     * A pointer to the actual db. Only use this when doing queries
58
 
     */
59
 
    Xapian::Database* db() {
60
 
        if (m_db) {
61
 
            m_db->reopen();
62
 
        }
63
 
        return m_db;
64
 
    }
65
 
 
66
 
private:
67
 
    Xapian::Database* m_db;
68
 
    Xapian::WritableDatabase m_wDb;
69
 
 
70
 
    typedef QPair<Xapian::docid, Xapian::Document> DocIdPair;
71
 
    QVector<DocIdPair> m_docsToAdd;
72
 
    QVector<uint> m_docsToRemove;
73
 
 
74
 
    std::string m_path;
75
 
    bool m_writeOnly;
76
 
 
77
 
    Xapian::WritableDatabase createWritableDb();
78
 
};
79
 
 
80
 
}
81
 
 
82
 
#endif // BALOO_XAPIANDATABASE_H