summaryrefslogtreecommitdiffstats
path: root/src/merger.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 01:27:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-10 01:27:27 +0000
commit76718abdb2138623102398a10f3228e576dd0ae8 (patch)
treeddb098baac9689b9e661a41c2a28a8a23ef246d4 /src/merger.cpp
downloadkdiff3-76718abdb2138623102398a10f3228e576dd0ae8.tar.gz
kdiff3-76718abdb2138623102398a10f3228e576dd0ae8.zip
Added abandoned KDE3 version of kdiff3
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1088041 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/merger.cpp')
-rw-r--r--src/merger.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/merger.cpp b/src/merger.cpp
new file mode 100644
index 0000000..371548c
--- /dev/null
+++ b/src/merger.cpp
@@ -0,0 +1,87 @@
+/***************************************************************************
+ merger.cpp - description
+ -------------------
+ begin : Sun Mar 24 2002
+ copyright : (C) 2002-2007 by Joachim Eibl
+ email : joachim.eibl at gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "merger.h"
+#include <assert.h>
+#include <iostream>
+#include <iomanip>
+
+Merger::Merger( const DiffList* pDiffListAB, const DiffList* pDiffListCA )
+: md1( pDiffListAB, 0 ), md2( pDiffListCA, 1 )
+{
+}
+
+
+Merger::MergeData::MergeData( const DiffList* p, int i )
+: d(0,0,0)
+{
+ idx=i;
+ pDiffList = p;
+ if ( p!=0 )
+ {
+ it=p->begin();
+ update();
+ }
+}
+
+bool Merger::MergeData::eq()
+{
+ return pDiffList==0 || d.nofEquals > 0;
+}
+
+bool Merger::MergeData::isEnd()
+{
+ return ( pDiffList==0 || ( it==pDiffList->end() && d.nofEquals==0 &&
+ ( idx == 0 ? d.diff1==0 : d.diff2==0 )
+ ) );
+}
+
+void Merger::MergeData::update()
+{
+ if ( d.nofEquals > 0 )
+ --d.nofEquals;
+ else if ( idx==0 && d.diff1 > 0 )
+ --d.diff1;
+ else if ( idx==1 && d.diff2 > 0 )
+ --d.diff2;
+
+ while( d.nofEquals == 0 && (idx==0 && d.diff1 == 0 || idx==1 && d.diff2 == 0)
+ && pDiffList!=0 && it != pDiffList->end() )
+ {
+ d = *it;
+ ++it;
+ }
+}
+
+void Merger::next()
+{
+ md1.update();
+ md2.update();
+}
+
+int Merger::whatChanged()
+{
+ int changed = 0;
+ changed |= md1.eq() ? 0 : 1;
+ changed |= md2.eq() ? 0 : 2;
+ return changed;
+}
+
+bool Merger::isEndReached()
+{
+ return md1.isEnd() && md2.isEnd();
+}