File indexing completed on 2024-04-14 15:52:44

0001 /*
0002     This file is part of the Okteta Core library, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2003, 2007 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef OKTETA_FILEBYTEARRAYMODEL_HPP
0010 #define OKTETA_FILEBYTEARRAYMODEL_HPP
0011 
0012 // lib
0013 #include "abstractbytearraymodel.hpp"
0014 
0015 namespace Okteta {
0016 
0017 class FileByteArrayModelPrivate;
0018 
0019 /**
0020  * @author Friedrich W. H. Kossebau
0021  */
0022 
0023 class OKTETACORE_EXPORT FileByteArrayModel : public AbstractByteArrayModel
0024 {
0025     friend class FileByteArrayModelPrivate;
0026 
0027     Q_OBJECT
0028 
0029 public:
0030     /** default is only 50*4k = 200k memory image */
0031     explicit FileByteArrayModel(int pageNumber = 50, int pageSize = 4096, QObject* parent = nullptr);
0032     ~FileByteArrayModel() override;
0033 
0034 public: // AbstractByteArrayModel API
0035     Byte byte(Address offset) const override;
0036     Size size() const override;
0037     bool isReadOnly() const override;
0038     bool isModified() const override;
0039 
0040     Size insert(Address offset, const Byte* insertData, int insertLength) override;
0041     Size remove(const AddressRange& removeRange) override;
0042     Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) override;
0043     bool swap(Address firstStart, const AddressRange& secondRange) override;
0044     Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override;
0045     void setByte(Address offset, Byte byte) override;
0046 
0047     void setModified(bool modified = true) override;
0048 
0049 public:
0050     void setReadOnly(bool readOnly = true) override;
0051     bool isOpen() const;
0052     bool open(const QString& filename);
0053     bool close();
0054 
0055 private:
0056     Q_DECLARE_PRIVATE(FileByteArrayModel)
0057 };
0058 
0059 }
0060 
0061 #endif