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_
12 #define POCO_NO_UNWINDOWS 1
13 #include <Poco/Mutex.h>
14 #include <Poco/ThreadLocal.h>
17 #include "PathContext.h"
18 #include "DiffFileInfo.h"
19 #include "DiffItemList.h"
32 /** Interface to a provider of plugin info */
36 virtual void FetchPluginInfos(const String& filteredFilenames,
37 PackingInfo ** infoUnpacker,
38 PrediffingInfo ** infoPrediffer) = 0;
42 * The folder compare context.
43 * This class holds data of the current folder compare. There are paths
44 * to compare, filters used, compare options etc. And compare results list
45 * is also contained in this class. Many compare classes and functions have
46 * a pointer to instance of this class.
48 * @note If you add new member variables, remember to copy values in
49 * CDiffContext::CDiffContext(..,CDiffContext) constructor!
51 class CDiffContext : public DiffItemList
54 /** @brief Special values for difference counts. */
57 DIFFS_UNKNOWN = -1, /**< Difference count unknown (generally). */
58 DIFFS_UNKNOWN_QUICKCOMPARE = -9, /**< Unknown because of quick-compare method. */
61 CDiffContext(const PathContext & paths, int compareMethod);
64 void UpdateVersion(DIFFITEM & di, int nIndex) const;
67 * Get the main compare method used in this compare.
68 * @return Compare method used.
70 int GetCompareMethod(void) const { return m_nCompMethod; }
74 * @name Path accessor functions.
76 * These functions return left/right path associated to DiffContext.
77 * There is no setter fuctions and path can be set only via constructor.
78 * Normalized paths are preferred to use - short paths are expanded
79 * and trailing slashes removed (except from root path).
82 * Get left-side compare path.
83 * @return full path in left-side.
85 String GetLeftPath() const { return m_paths.GetLeft(false); }
86 String GetMiddlePath() const { return m_paths.GetMiddle(false); }
88 * Get right-side compare path.
89 * @return full path in right-side.
91 String GetRightPath() const { return m_paths.GetRight(false); }
92 String GetPath(int nIndex) const { return m_paths.GetPath(nIndex, false); }
94 * Get left-side compare path in normalized form.
95 * @return full path in left-side.
97 String GetNormalizedLeft() const { return m_paths.GetLeft(); }
98 String GetNormalizedMiddle() const { return m_paths.GetMiddle(); }
100 * Get right-side compare path in normalized form.
101 * @return full path in left-side.
103 String GetNormalizedRight() const { return m_paths.GetRight(); }
104 String GetNormalizedPath(int nIndex) const { return m_paths.GetPath(nIndex, true); }
105 PathContext GetNormalizedPaths() const
108 for (int nIndex = 0; nIndex < m_paths.GetSize(); nIndex++)
109 paths.SetPath(nIndex, m_paths.GetPath(nIndex, true));
114 // change an existing difference
115 bool UpdateInfoFromDiskHalf(DIFFITEM & di, int nIndex);
116 void UpdateStatusFromDisk(uintptr_t diffpos, int index);
118 bool CreateCompareOptions(int compareMethod, const DIFFOPTIONS & options);
119 CompareOptions * GetCompareOptions(int compareMethod);
121 // retrieve or manufacture plugin info for specified file comparison
122 void FetchPluginInfos(const String& filteredFilenames,
123 PackingInfo ** infoUnpacker, PrediffingInfo ** infoPrediffer);
127 * @name Compare aborting interface.
128 * These functions handle compare aborting using IAbortable interface.
130 bool ShouldAbort() const;
133 * Set pointer to IAbortable interface.
134 * This function sets pointer to interface used to abort the compare when
136 * @param [in] piAbortable Pointer to interface.
138 void SetAbortable(IAbortable * piAbortable) { m_piAbortable = piAbortable; }
141 * Returns a pointer to current IAbortable interface.
142 * This function returns a pointer to interface used to abort the compare.
143 * @return Pointer to current IAbortable interface.
145 const IAbortable * GetAbortable() const { return m_piAbortable; }
148 int GetCompareDirs() const { return m_paths.GetSize(); }
150 IDiffFilter * m_piFilterGlobal; /**< Interface for file filtering. */
151 IPluginInfos * m_piPluginInfos;
152 int m_iGuessEncodingType;
154 bool m_bIgnoreSmallTimeDiff; /**< Ignore small timedifferences when comparing by date */
155 CompareStats *m_pCompareStats; /**< Pointer to compare statistics */
158 * Optimize compare by stopping after first difference.
159 * In some compare methods (currently quick compare) we can stop the
160 * compare right after finding the first difference. This speeds up the
161 * compare, but also causes compare statistics to be inaccurate.
163 bool m_bStopAfterFirstDiff;
166 * Threshold size for switching to quick compare.
167 * When diffutils compare is selected, files bigger (in bytes) than this
168 * value are compared using Quick compare. This is because diffutils simply
169 * cannot compare large files. And large files are usually binary files.
171 int m_nQuickCompareLimit;
174 * Walk into unique folders and add contents.
175 * This enables/disables walking into unique folders. If we don't walk into
176 * unique folders, they are shown as such in folder compare results. If we
177 * walk into unique folders, we'll show all files in the unique folder and
178 * in possible subfolders.
180 * This value is true by default.
183 bool m_bIgnoreReparsePoints;
185 bool m_bRecursive; /**< Do we include subfolders to compare? */
186 bool m_bPluginsEnabled; /**< Are plugins enabled? */
187 std::unique_ptr<FilterList> m_pFilterList; /**< Filter list for line filters */
188 CDiffWrapper *m_pDiffWrapper;
192 * The main compare method used.
193 * This is the main compare method set when compare is started. There
194 * can be temporary switches to other method (e.g. for large file) but
195 * this main method must be set back for next file.
199 std::unique_ptr<DIFFOPTIONS> m_pOptions; /**< Generalized compare options. */
200 std::unique_ptr<CompareOptions> m_pContentCompareOptions; /**< Per compare method compare options. */
201 std::unique_ptr<CompareOptions> m_pQuickCompareOptions; /**< Per compare method compare options. */
202 PathContext m_paths; /**< (root) paths for this context */
203 IAbortable *m_piAbortable; /**< Interface for aborting the compare. */
204 Poco::FastMutex m_mutex;
207 #endif // !defined(AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_)