File indexing completed on 2025-01-19 05:11:32
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "pair.h" 0010 #include "types.h" 0011 0012 #include "libkommitdiff_export.h" 0013 0014 namespace Diff 0015 { 0016 0017 using Solution = QList<Pair2>; 0018 using Solution3 = QList<Pair3>; 0019 0020 QDebug &operator<<(QDebug &stream, const Diff::Solution &sln); 0021 0022 struct Range { 0023 int begin; 0024 int size; 0025 0026 Range(); 0027 Range(int begin, int size); 0028 }; 0029 0030 class LIBKOMMITDIFF_EXPORT SolutionIterator 0031 { 0032 const Solution &_solution; 0033 int _firstIndex{0}; 0034 int _secondIndex{0}; 0035 Solution::ConstIterator i; 0036 bool _ended{true}; 0037 int _firstSize{}; 0038 int _secondSize{}; 0039 0040 public: 0041 struct Result { 0042 int oldStart; 0043 int oldSize; 0044 int newStart; 0045 int newSize; 0046 bool success; 0047 SegmentType type; 0048 0049 Result(); 0050 Result(int oldStart, int oldSize, int newStart, int newSize, bool success, SegmentType type); 0051 }; 0052 0053 SolutionIterator(const Solution &solution, int firstSize, int secondSize); 0054 void begin(); 0055 Result pick(); 0056 }; 0057 0058 class LIBKOMMITDIFF_EXPORT SolutionIterator3 0059 { 0060 const Solution3 &_solution; 0061 int _firstIndex{0}; 0062 int _secondIndex{0}; 0063 int _thirdIndex{0}; 0064 Solution3::ConstIterator i; 0065 0066 public: 0067 struct Result { 0068 Range base; 0069 Range local; 0070 Range remote; 0071 bool success; 0072 SegmentType type; 0073 0074 Result(); 0075 Result(Range base, Range local, Range remote, SegmentType type); 0076 }; 0077 0078 SolutionIterator3(const Solution3 &solution); 0079 void begin(); 0080 Result pick(); 0081 }; 0082 0083 QDebug operator<<(QDebug d, const SolutionIterator::Result &r); 0084 }