File indexing completed on 2024-04-21 05:52:55
0001 /* 0002 This file is part of the Okteta Core library, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008 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 KPIECETABLE_PIECETABLE_HPP 0010 #define KPIECETABLE_PIECETABLE_HPP 0011 0012 // lib 0013 #include "piecelist.hpp" 0014 // Qt 0015 #include <QLinkedList> 0016 0017 namespace KPieceTable { 0018 0019 class PieceTable 0020 { 0021 public: 0022 explicit PieceTable(Size size = 0); 0023 PieceTable(const PieceTable&) = delete; 0024 0025 ~PieceTable(); 0026 0027 PieceTable& operator=(const PieceTable&) = delete; 0028 0029 public: 0030 void init(Size size); 0031 void insert(Address insertDataOffset, Size insertLength, Address storageOffset); 0032 /// for use to reapply 0033 void insert(Address insertDataOffset, const PieceList& insertPieceList); 0034 PieceList remove(const AddressRange& removeRange); 0035 PieceList replace(const AddressRange& removeRange, 0036 Size insertLength, Address storageOffset); 0037 /// for use to reapply 0038 void replace(const AddressRange& removeRange, const PieceList& insertPieceList); 0039 void swap(Address firstStart, const AddressRange& secondRange); 0040 Piece replaceOne(Address dataOffset, Address storageOffset, int storageId = Piece::ChangeStorage); 0041 0042 // int fill( const char FillChar, unsigned int Pos = 0, int Length = -1 ); TODO: filter change, calculated 0043 0044 public: 0045 bool getStorageData(int* storageId, Address* storageOffset, Address dataOffset) const; 0046 Size size() const; 0047 0048 private: 0049 QLinkedList<Piece> mList; 0050 Size mSize; 0051 }; 0052 0053 inline PieceTable::~PieceTable() = default; 0054 0055 inline Size PieceTable::size() const { return mSize; } 0056 0057 } 0058 0059 #endif