File indexing completed on 2024-05-05 05:55:38
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 #include "testpiecetablechange.hpp" 0010 0011 // lib 0012 #include <piecetable/piecetable.hpp> 0013 #include <arraychangemetrics.hpp> 0014 // Qt 0015 #include <QString> 0016 0017 namespace KPieceTable { 0018 0019 TestPieceTableChange::~TestPieceTableChange() = default; 0020 0021 int TestPieceTableChange::type() const { return mTypeId; } 0022 0023 QString TestPieceTableChange::description() const 0024 { 0025 return mDescription; 0026 } 0027 0028 bool TestPieceTableChange::merge(const AbstractPieceTableChange* other) 0029 { 0030 bool result = false; 0031 if (other->type() == mTypeId) { 0032 const auto* otherTestChange = static_cast<const TestPieceTableChange*>(other); 0033 mDescription += otherTestChange->mDescription; 0034 result = true; 0035 } 0036 0037 return result; 0038 } 0039 0040 AddressRange TestPieceTableChange::apply(PieceTable* pieceTable) const 0041 { 0042 pieceTable->replaceOne(mPosition, mStoragePosition, mStorageId); 0043 0044 return AddressRange(mPosition, mPosition); 0045 } 0046 0047 AddressRange TestPieceTableChange::revert(PieceTable* pieceTable) const 0048 { 0049 const Piece replaced = pieceTable->replaceOne(mPosition, mReplacedStoragePosition, mReplacedStorageId); 0050 0051 return AddressRange(mPosition, mPosition); 0052 } 0053 0054 ArrayChangeMetrics TestPieceTableChange::metrics() const 0055 { 0056 return ArrayChangeMetrics::asReplacement(mPosition, 1, 1); 0057 } 0058 0059 int TestPieceTableChange::dataSize() const { return 1; } 0060 0061 }