File indexing completed on 2024-04-21 14:52:29

0001 /*
0002     This file is part of the KDE Baloo project.
0003     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef BALOO_POSITIONDB_H
0009 #define BALOO_POSITIONDB_H
0010 
0011 #include "engine_export.h"
0012 
0013 #include <QByteArray>
0014 #include <QMap>
0015 #include <QVector>
0016 #include <lmdb.h>
0017 
0018 namespace Baloo {
0019 
0020 class PositionInfo;
0021 class VectorPositionInfoIterator;
0022 
0023 class BALOO_ENGINE_EXPORT PositionDB
0024 {
0025 public:
0026     explicit PositionDB(MDB_dbi dbi, MDB_txn* txn);
0027     ~PositionDB();
0028 
0029     static MDB_dbi create(MDB_txn* txn);
0030     static MDB_dbi open(MDB_txn* txn);
0031 
0032     void put(const QByteArray& term, const QVector<PositionInfo>& list);
0033     QVector<PositionInfo> get(const QByteArray& term);
0034     void del(const QByteArray& term);
0035 
0036     VectorPositionInfoIterator* iter(const QByteArray& term);
0037 
0038     QMap<QByteArray, QVector<PositionInfo>> toTestMap() const;
0039 private:
0040     MDB_txn* m_txn;
0041     MDB_dbi m_dbi;
0042 };
0043 
0044 }
0045 
0046 #endif // BALOO_POSITIONDB_H