Success build TortoiseMerge.
[TortoiseGit.git] / src / TortoiseMerge / svninclude / SVNLineDiff.h
blob56a7036f22d313f872e1c561169236830959c5ad
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2006-2007 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "svn_diff.h"
21 #include "diff.h"
22 #include "svn_pools.h"
24 /**
25 * \ingroup TortoiseMerge
26 * Handles diffs of single lines. Used for inline diffs.
28 class SVNLineDiff
30 public:
31 SVNLineDiff();
32 ~SVNLineDiff();
34 bool Diff(svn_diff_t** diff, LPCTSTR line1, int len1, LPCTSTR line2, int len2, bool bWordDiff);
35 /** Checks if we really should show inline diffs.
36 * Inline diffs are only useful if the two lines are not
37 * completely different but at least a little bit similar.
39 static bool ShowInlineDiff(svn_diff_t* diff);
41 std::vector<std::wstring> m_line1tokens;
42 std::vector<std::wstring> m_line2tokens;
43 private:
45 apr_pool_t * m_pool;
46 apr_pool_t * m_subpool;
47 LPCTSTR m_line1;
48 unsigned long m_line1length;
49 LPCTSTR m_line2;
50 unsigned long m_line2length;
51 unsigned long m_line1pos;
52 unsigned long m_line2pos;
54 bool m_bWordDiff;
56 static svn_error_t * datasource_open(void *baton, svn_diff_datasource_e datasource);
57 static svn_error_t * datasource_close(void *baton, svn_diff_datasource_e datasource);
58 static svn_error_t * next_token(apr_uint32_t * hash, void ** token, void * baton, svn_diff_datasource_e datasource);
59 static svn_error_t * compare_token(void * baton, void * token1, void * token2, int * compare);
60 static void discard_token(void * baton, void * token);
61 static void discard_all_token(void *baton);
62 static bool IsCharWhiteSpace(TCHAR c);
64 static apr_uint32_t Adler32(apr_uint32_t checksum, const WCHAR *data, apr_size_t len);
65 static void ParseLineWords(
66 LPCTSTR line, unsigned long lineLength, std::vector<std::wstring>& tokens);
67 static void ParseLineChars(
68 LPCTSTR line, unsigned long lineLength, std::vector<std::wstring>& tokens);
69 static void NextTokenWords(
70 apr_uint32_t* hash, void** token, unsigned long& linePos, const std::vector<std::wstring>& tokens);
71 static void NextTokenChars(
72 apr_uint32_t* hash, void** token, unsigned long& linePos, LPCTSTR line, unsigned long lineLength);
73 static const svn_diff_fns_t SVNLineDiff_vtable;