download DiffList.h
Language: C++
License: GPL
LOC: 69
Project Info
WinMerge
Server: SourceForge
Type: cvs
...erge\winmerge\WinMerge\Src\
   7zCommon.cpp
   7zCommon.h
   AboutDlg.cpp
   AboutDlg.h
   AppSerialize.cpp
   AppSerialize.h
   BCMenu.cpp
   BCMenu.h
   ByteComparator.cpp
   ByteComparator.h
   CCPrompt.cpp
   CCPrompt.h
   charsets.c
   charsets.h
   ChildFrm.cpp
   ChildFrm.h
   codepage.cpp
   codepage.h
   codepage_detect.cpp
   codepage_detect.h
   ColorButton.cpp
   ColorButton.h
   CompareOptions.h
   CompareStatisticsDlg.cpp
   CompareStatisticsDlg.h
   CompareStats.cpp
   CompareStats.h
   ConfigLog.cpp
   ConfigLog.h
   Diff.cpp
   DiffContext.cpp
   DiffContext.h
   DiffFileData.cpp
   DiffFileData.h
   DiffFileInfo.cpp
   DiffFileInfo.h
   DiffItem.cpp
   DiffItem.h
   DiffItemList.cpp
   DiffItemList.h
   DiffList.cpp
   DiffList.h
   diffmain.c
   DiffThread.cpp
   DiffThread.h
   DiffViewBar.cpp
   DiffViewBar.h
   DiffWrapper.cpp
   DiffWrapper.h
   Dir.cpp
   DirActions.cpp
   DirCmpReport.cpp
   DirCmpReport.h
   DirCmpReportDlg.cpp
   DirCmpReportDlg.h
   DirColsDlg.cpp
   DirColsDlg.h
   DirCompProgressDlg.cpp
   DirCompProgressDlg.h
   DirDoc.cpp
   DirDoc.h
   DirFrame.cpp
   DirFrame.h
   DirReportTypes.h
   DirScan.cpp
   DirScan.h
   DirView.cpp
   DirView.h
   DirViewColHandler.cpp
   DirViewColItems.cpp
   DirViewColItems.h
   dlgutil.cpp
   dlgutil.h
   dllpstub.cpp
   dllpstub.h
   dllver.cpp
   dllver.h
   EditorFilepathBar.cpp
   EditorFilepathBar.h
   Exceptions.h
   FileActionScript.cpp
   FileActionScript.h
   FileFilterHelper.cpp
   FileFilterHelper.h
   FileFilterMgr.cpp
   FileFilterMgr.h
   FileFiltersDlg.cpp
   FileFiltersDlg.h
   FileInfo.cpp
   FileInfo.h
   FileLocation.h
   FilepathEdit.cpp
   FilepathEdit.h
   files.cpp
   files.h
   FileTextEncoding.cpp
   FileTextEncoding.h
   FileTextStats.h
   FileTransform.cpp
   FileTransform.h
   GhostTextBuffer.cpp
   GhostTextBuffer.h
   GhostTextView.cpp
   GhostTextView.h
   IAbortable.h
   IntToIntMap.h
   IOptionsPanel.h
   LoadSaveCodepageDlg.cpp
   LoadSaveCodepageDlg.h
   locality.cpp
   locality.h
   LocationBar.cpp
   LocationBar.h
   LocationView.cpp
   LocationView.h
   MainFrm.cpp
   MainFrm.h
   markdown.cpp
   markdown.h
   Merge.cpp
   Merge.dsp
   Merge.h
   Merge.rc
   MergeArgs.cpp
   MergeDiffDetailView.cpp
   MergeDiffDetailView.h
   MergeDoc.cpp
   MergeDoc.h
   MergeDocEncoding.cpp
   MergeDocLineDiffs.cpp
   MergeEditStatus.h
   MergeEditView.cpp
   MergeEditView.h
   MergeLineFlags.h
   MovedBlocks.cpp
   OpenDlg.cpp
   OpenDlg.h
   OptionsDef.h
   OptionsInit.cpp
   OutputDlg.cpp
   OutputDlg.h
   PatchDlg.cpp
   PatchDlg.h
   PatchTool.cpp
   PatchTool.h
   PathContext.cpp
   PathContext.h
   paths.cpp
   paths.h
   PluginManager.cpp
   PluginManager.h
   Plugins.cpp
   Plugins.h
   ProjectFile.cpp
   ProjectFile.h
   ProjectFilePathsDlg.cpp
   ProjectFilePathsDlg.h
   PropArchive.cpp
   PropArchive.h
   PropCodepage.cpp
   PropCodepage.h
   PropColors.cpp
   PropColors.h
   PropCompare.cpp
   PropCompare.h
   PropEditor.cpp
   PropEditor.h
   PropGeneral.cpp
   PropGeneral.h
   PropLineFilter.cpp
   PropLineFilter.h
   PropRegistry.cpp
   PropRegistry.h
   PropSyntaxColors.cpp
   PropSyntaxColors.h
   PropTextColors.cpp
   PropTextColors.h
   PropVss.cpp
   PropVss.h
   resource.h
   SaveClosingDlg.cpp
   SaveClosingDlg.h
   SelectUnpackerDlg.cpp
   SelectUnpackerDlg.h
   SetResourceVersions.bat
   SetResourceVersions.wsf
   SharedFilterDlg.cpp
   SharedFilterDlg.h
   SourceControl.cpp
   Splash.cpp
   Splash.h
   ssapi.cpp
   ssapi.h
   ssauto.h
   STACK.C
   StdAfx.cpp
   StdAfx.h
   stringdiffs.cpp
   stringdiffs.h
   stringdiffsi.h
   SyntaxColors.cpp
   SyntaxColors.h
   TestFilterDlg.cpp
   TestFilterDlg.h
   ViewableWhitespace.cpp
   ViewableWhitespace.h
   VSSHelper.cpp
   VSSHelper.h
   VssPrompt.cpp
   VssPrompt.h
   WaitStatusCursor.cpp
   WaitStatusCursor.h
   winnt_supp.h
   WMGotoDlg.cpp
   WMGotoDlg.h
   XmlDoc.cpp
   XmlDoc.h

/////////////////////////////////////////////////////////////////////////////
//    License (GPLv2+):
//    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.
//
//    This program is distributed in the hope that it will be useful, but
//    WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; if not, write to the Free Software
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
/////////////////////////////////////////////////////////////////////////////
/** 
 * @file  DiffList.h
 *
 * @brief Declaration file for DiffList class
 */
// RCS ID line follows -- this is updated by CVS
// $Id: DiffList.h,v 1.10 2006/05/24 20:14:04 kimmov Exp $

#ifndef _DIFFLIST_H_
#define _DIFFLIST_H_

/**
 * @brief One difference defined by linenumbers.
 *
 * This struct defines one set of different lines "diff".
 * @p begin0, @p end0, @p begin1 & @p end1 are linenumbers
 * in original files. Other struct members point to linenumbers
 * calculated by WinMerge after adding empty lines to make diffs
 * be in line in screen.
 *
 * @note @p blank0 & @p blank1 are -1 if there are no blank lines
 */
struct DIFFRANGE
{
	UINT begin0;	/**< First diff line in original file1 */
	UINT end0;		/**< Last diff line in original file1 */
	UINT begin1;	/**< First diff line in original file2 */
	UINT end1;		/**< Last diff line in original file2 */
	UINT dbegin0;	/**< Synchronised (ghost lines added) first diff line in file1 */
	UINT dend0;		/**< Synchronised (ghost lines added) last diff line in file1 */
	UINT dbegin1;	/**< Synchronised (ghost lines added) first diff line in file2 */
	UINT dend1;		/**< Synchronised (ghost lines added) last diff line in file2 */
	int blank0;		/**< Number of blank lines in file1 */
	int blank1;		/**< Number of blank lines in file2 */
	BYTE op;		/**< Operation done with this diff */
	DIFFRANGE() { memset(this, 0, sizeof(*this)); }
};

/**
 * @brief DIFFRANGE with links for chain of non-trivial entries
 *
 * Next and prev are array indices used by the owner (DiffList)
 */
struct DiffRangeInfo
{
	DIFFRANGE diffrange;
	int next; /**< link (array index) for doubly-linked chain of non-trivial DIFFRANGEs */
	int prev; /**< link (array index) for doubly-linked chain of non-trivial DIFFRANGEs */

	DiffRangeInfo() { InitLinks(); }
	DiffRangeInfo(const DIFFRANGE & di) : diffrange(di) { InitLinks(); }
	void InitLinks() { next = prev = -1; }
};

/**
 * @brief Operations in diffranges.
 * DIFFRANGE structs op-member can have these values
 */
enum
{
	OP_NONE = 0,
	OP_LEFTONLY,
	OP_DIFF,
	OP_RIGHTONLY,
	OP_TRIVIAL
};

/**
 * @brief Class for storing differences in files (difflist).
 *
 * This class stores diffs in list and also offers diff-related
 * functions to e.g. check if linenumber is inside diff.
 *
 * There are two kinds of diffs:
 * - significant diffs are 'normal' diffs we want to merge and browse
 * - non-significant diffs are diffs ignored by linefilters
 */
class DiffList
{
public:
	DiffList();
	void Clear();
	int GetSize() const;
	int GetSignificantDiffs() const;
	void AddDiff(const DIFFRANGE & di);
	BOOL IsDiffSignificant(int nDiff) const;
	BOOL GetDiff(int nDiff, DIFFRANGE & di) const;
	BOOL SetDiff(int nDiff, const DIFFRANGE & di);
	int LineRelDiff(UINT nLine, UINT nDiff) const;
	BOOL LineInDiff(UINT nLine, UINT nDiff) const;
	int LineToDiff(UINT nLine) const;
	BOOL GetPrevDiff(int nLine, int & nDiff) const;
	BOOL GetNextDiff(int nLine, int & nDiff) const;
	BOOL HasSignificantDiffs() const;
	int PrevSignificantDiffFromLine(UINT nLine) const;
	int NextSignificantDiffFromLine(UINT nLine) const;
	int FirstSignificantDiff() const;
	int NextSignificantDiff(int nDiff) const;
	int PrevSignificantDiff(int nDiff) const;
	int LastSignificantDiff() const;
	const DIFFRANGE * FirstSignificantDiffRange() const;
	const DIFFRANGE * LastSignificantDiffRange() const;

	const DIFFRANGE * DiffRangeAt(int nDiff) const;

	void ConstructSignificantChain(); // must be called after diff list is entirely populated
	void Swap();
	void GetExtraLinesCounts(int &nLeftLines, int &nRightLines);

private:
	CArray<DiffRangeInfo,DiffRangeInfo> m_diffs; /**< Difference list */
	int m_firstSignificant; /**< Index of first significant diff in m_diffs */
	int m_lastSignificant; /**< Index of last significant diff in m_diffs */
};

#endif // _DIFFLIST_H_

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us