File indexing completed on 2024-04-21 03:51:40
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_IDFILENAMEDB_H 0009 #define BALOO_IDFILENAMEDB_H 0010 0011 #include "engine_export.h" 0012 #include <lmdb.h> 0013 #include <QByteArray> 0014 #include <QMap> 0015 0016 namespace Baloo { 0017 0018 class BALOO_ENGINE_EXPORT IdFilenameDB 0019 { 0020 public: 0021 IdFilenameDB(MDB_dbi dbi, MDB_txn* txn); 0022 ~IdFilenameDB(); 0023 0024 static MDB_dbi create(MDB_txn* txn); 0025 static MDB_dbi open(MDB_txn* txn); 0026 0027 struct FilePath { 0028 quint64 parentId = 0; 0029 QByteArray name; 0030 0031 bool operator == (const FilePath& fp) const { 0032 return parentId == fp.parentId && name == fp.name; 0033 } 0034 }; 0035 void put(quint64 docId, const FilePath& path); 0036 FilePath get(quint64 docId); 0037 bool get(quint64 docId, FilePath& path); 0038 bool contains(quint64 docId); 0039 void del(quint64 docId); 0040 0041 QMap<quint64, FilePath> toTestMap() const; 0042 private: 0043 MDB_txn* m_txn; 0044 MDB_dbi m_dbi; 0045 }; 0046 0047 } 0048 0049 #endif // BALOO_IDFILENAMEDB_H