4 * @brief Declarations of CDiffContext and diff structures
6 // ID line follows -- this is updated by SVN
7 // $Id: DiffContext.h 6910 2009-07-12 09:06:54Z kimmov $
9 #if !defined(AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_)
10 #define AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_
13 #include "PathContext.h"
14 #include "DiffFileInfo.h"
15 #include "DiffItemList.h"
28 /** Interface to a provider of plugin info */
32 virtual void FetchPluginInfos(LPCTSTR filteredFilenames,
33 PackingInfo ** infoUnpacker,
34 PrediffingInfo ** infoPrediffer) = 0;
38 * The folder compare context.
39 * This class holds data of the current folder compare. There are paths
40 * to compare, filters used, compare options etc. And compare results list
41 * is also contained in this class. Many compare classes and functions have
42 * a pointer to instance of this class.
44 * @note If you add new member variables, remember to copy values in
45 * CDiffContext::CDiffContext(..,CDiffContext) constructor!
47 class CDiffContext : public DiffItemList
50 /** @brief Special values for difference counts. */
53 DIFFS_UNKNOWN = -1, /**< Difference count unknown (generally). */
54 DIFFS_UNKNOWN_QUICKCOMPARE = -9, /**< Unknown because of quick-compare method. */
57 CDiffContext(const PathContext & paths, int compareMethod);
60 void UpdateVersion(DIFFITEM & di, BOOL bLeft) const;
63 * Get the main compare method used in this compare.
64 * @return Compare method used.
66 int GetCompareMethod(void) const { return m_nCompMethod; }
70 * @name Path accessor functions.
72 * These functions return left/right path associated to DiffContext.
73 * There is no setter fuctions and path can be set only via constructor.
74 * Normalized paths are preferred to use - short paths are expanded
75 * and trailing slashes removed (except from root path).
78 * Get left-side compare path.
79 * @return full path in left-side.
81 String GetLeftPath() const { return m_paths.GetLeft(FALSE); }
82 String GetMiddlePath() const { return m_paths.GetMiddle(FALSE); }
84 * Get right-side compare path.
85 * @return full path in right-side.
87 String GetRightPath() const { return m_paths.GetRight(FALSE); }
88 String GetPath(int nIndex) const { return m_paths.GetPath(nIndex, FALSE); }
90 * Get left-side compare path in normalized form.
91 * @return full path in left-side.
93 String GetNormalizedLeft() const { return m_paths.GetLeft(); }
94 String GetNormalizedMiddle() const { return m_paths.GetMiddle(); }
96 * Get right-side compare path in normalized form.
97 * @return full path in left-side.
99 String GetNormalizedRight() const { return m_paths.GetRight(); }
100 String GetNormalizedPath(int nIndex) const { return m_paths.GetPath(nIndex, TRUE); }
101 PathContext GetNormalizedPaths() const
104 for (int nIndex = 0; nIndex < m_paths.GetSize(); nIndex++)
105 paths.SetPath(nIndex, m_paths.GetPath(nIndex, TRUE).c_str());
110 // change an existing difference
111 BOOL UpdateInfoFromDiskHalf(DIFFITEM & di, int nIndex);
112 void UpdateStatusFromDisk(UINT_PTR diffpos, BOOL bLeft, BOOL bRight);
113 void UpdateStatusFromDisk(POSITION diffpos, BOOL bLeft, BOOL bMiddle, BOOL bRight);
115 BOOL CreateCompareOptions(int compareMethod, const DIFFOPTIONS & options);
116 CompareOptions * GetCompareOptions(int compareMethod);
118 // retrieve or manufacture plugin info for specified file comparison
119 void FetchPluginInfos(LPCTSTR filteredFilenames,
120 PackingInfo ** infoUnpacker, PrediffingInfo ** infoPrediffer);
124 * @name Compare aborting interface.
125 * These functions handle compare aborting using IAbortable interface.
127 bool ShouldAbort() const;
130 * Set pointer to IAbortable interface.
131 * This function sets pointer to interface used to abort the compare when
133 * @param [in] piAbortable Pointer to interface.
135 void SetAbortable(IAbortable * piAbortable) { m_piAbortable = piAbortable; }
138 * Returns a pointer to current IAbortable interface.
139 * This function returns a pointer to interface used to abort the compare.
140 * @return Pointer to current IAbortable interface.
142 const IAbortable * GetAbortable() const { return m_piAbortable; }
145 int GetCompareDirs() const { return m_paths.GetSize(); }
147 IDiffFilter * m_piFilterGlobal; /**< Interface for file filtering. */
148 IPluginInfos * m_piPluginInfos;
149 int m_iGuessEncodingType;
152 * The current and effective compare method.
153 * During the compare we may change compare method per file. This may
154 * happen for various reasons. But the change is always temporarily and
155 * we must return to the main method indicated by m_nCompMethod.
157 int m_nCurrentCompMethod;
159 BOOL m_bIgnoreSmallTimeDiff; /**< Ignore small timedifferences when comparing by date */
160 CompareStats *m_pCompareStats; /**< Pointer to compare statistics */
163 * Optimize compare by stopping after first difference.
164 * In some compare methods (currently quick compare) we can stop the
165 * compare right after finding the first difference. This speeds up the
166 * compare, but also causes compare statistics to be inaccurate.
168 bool m_bStopAfterFirstDiff;
171 * Threshold size for switching to quick compare.
172 * When diffutils compare is selected, files bigger (in bytes) than this
173 * value are compared using Quick compare. This is because diffutils simply
174 * cannot compare large files. And large files are usually binary files.
176 int m_nQuickCompareLimit;
179 * Walk into unique folders and add contents.
180 * This enables/disables walking into unique folders. If we don't walk into
181 * unique folders, they are shown as such in folder compare results. If we
182 * walk into unique folders, we'll show all files in the unique folder and
183 * in possible subfolders.
185 * This value is true by default.
189 bool m_bRecursive; /**< Do we include subfolders to compare? */
190 bool m_bPluginsEnabled; /**< Are plugins enabled? */
191 FilterList * m_pFilterList; /**< Filter list for line filters */
192 BOOL m_bScanUnpairedDir; /** Scan into unpaired directories **/
193 CDiffWrapper *m_pDiffWrapper;
197 * The main compare method used.
198 * This is the main compare method set when compare is started. There
199 * can be temporary switches to other method (e.g. for large file) but
200 * this main method must be set back for next file.
204 DIFFOPTIONS *m_pOptions; /**< Generalized compare options. */
205 CompareOptions *m_pCompareOptions; /**< Per compare method compare options. */
206 PathContext m_paths; /**< (root) paths for this context */
207 IAbortable *m_piAbortable; /**< Interface for aborting the compare. */
210 #endif // !defined(AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_)