File indexing completed on 2024-04-21 16:28:31
0001 /* 0002 SPDX-FileCopyrightText: 2001-2004,2009 Otto Bruggeman <bruggie@gmail.com> 0003 SPDX-FileCopyrightText: 2001-2003 John Firebaugh <jfirebaugh@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KOMPAREDIFF2_DIFFHUNK_H 0009 #define KOMPAREDIFF2_DIFFHUNK_H 0010 0011 #include "difference.h" 0012 0013 0014 namespace Diff2 0015 { 0016 0017 class Difference; 0018 0019 /** 0020 * DiffHunk 0021 */ 0022 class DiffHunk 0023 { 0024 public: 0025 enum Type { Normal, AddedByBlend }; 0026 0027 public: 0028 DiffHunk(int sourceLine, int destinationLine, const QString& function = QString(), Type type = Normal); 0029 ~DiffHunk(); 0030 0031 const DifferenceList& differences() const { return m_differences; }; 0032 const QString& function() const { return m_function; }; 0033 0034 int sourceLineNumber() const { return m_sourceLine; }; 0035 int destinationLineNumber() const { return m_destinationLine; }; 0036 0037 int sourceLineCount() const; 0038 int destinationLineCount() const; 0039 0040 Type type() const { return m_type; } 0041 void setType(Type type) { m_type = type; } 0042 0043 void add(Difference* diff); 0044 0045 QString recreateHunk() const; 0046 0047 private: 0048 int m_sourceLine; 0049 int m_destinationLine; 0050 DifferenceList m_differences; 0051 QString m_function; 0052 Type m_type; 0053 }; 0054 0055 using DiffHunkList = QList<DiffHunk*>; 0056 using DiffHunkListIterator = QList<DiffHunk*>::iterator; 0057 using DiffHunkListConstIterator = QList<DiffHunk*>::const_iterator; 0058 0059 } // End of namespace Diff2 0060 0061 #endif