1 /*
2  *  This file is part of KDiff3.
3  *
4  * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de
5  * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com
6  * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #ifndef MERGER_H
10 #define MERGER_H
11 
12 #include "diff.h"
13 
14 class Merger
15 {
16   public:
17     Merger(const DiffList* pDiffList1, const DiffList* pDiffList2);
18 
19     /** Go one step. */
20     void next();
21 
22     /** Information about what changed. Can be used for coloring.
23        The return value is 0 if nothing changed here,
24        bit 1 is set if a difference from pDiffList1 was detected,
25        bit 2 is set if a difference from pDiffList2 was detected.
26    */
27     ChangeFlags whatChanged();
28 
29     /** End of both diff lists reached. */
30     bool isEndReached();
31 
32   private:
33     class MergeData
34     {
35       private:
36         DiffList::const_iterator it;
37         const DiffList* pDiffList = nullptr;
38         Diff d;
39         int idx;
40 
41       public:
42         MergeData(const DiffList* p, int i);
43         bool eq() const;
44         void update();
45         bool isEnd() const;
46     };
47 
48     MergeData md1;
49     MergeData md2;
50 };
51 
52 #endif
53