File indexing completed on 2025-01-26 04:57:22

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "webengineviewer_private_export.h"
0010 #include <QString>
0011 #include <memory>
0012 
0013 namespace WebEngineViewer
0014 {
0015 class LocalDataBaseFilePrivate;
0016 struct Addition;
0017 class WEBENGINEVIEWER_TESTS_EXPORT LocalDataBaseFile
0018 {
0019 public:
0020     /*
0021      * binary file:
0022      * index 0 => quint16 => major version
0023      * index 2 => quint16 => minor version
0024      * index 4 => quint64 => number of element
0025      *
0026      * After : index of item in binary file
0027      *
0028      * value
0029      */
0030     explicit LocalDataBaseFile(const QString &filename);
0031     ~LocalDataBaseFile();
0032 
0033     void close();
0034     [[nodiscard]] bool fileExists() const;
0035 
0036     [[nodiscard]] bool reload();
0037 
0038     [[nodiscard]] bool isValid() const;
0039     [[nodiscard]] quint16 getUint16(int offset) const;
0040     [[nodiscard]] quint32 getUint32(int offset) const;
0041     [[nodiscard]] quint64 getUint64(int offset) const;
0042     const char *getCharStar(int offset) const;
0043 
0044     [[nodiscard]] QByteArray searchHash(const QByteArray &hashToSearch);
0045 
0046     [[nodiscard]] bool shouldCheck() const;
0047     [[nodiscard]] bool checkFileChanged();
0048     [[nodiscard]] QList<WebEngineViewer::Addition> extractAllInfo() const;
0049 
0050 private:
0051     std::unique_ptr<LocalDataBaseFilePrivate> const d;
0052 };
0053 }