Do not quit TortoiseGitProc after running Bisect Start from log list
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlameData.h
blob5d03894aff4b80647f16c7f53235ee781d165077
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
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 // CTortoiseGitBlameData.h : interface of the CTortoiseGitBlameData class
22 #pragma once
24 #include "gitlogcache.h"
26 class CTortoiseGitBlameData
28 // Implementation
29 public:
30 CTortoiseGitBlameData();
31 virtual ~CTortoiseGitBlameData();
33 public:
34 int GetEncode(unsigned char * buffer, int size, int *bomoffset);
35 int GetEncode(int *bomoffset);
36 void ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & HashToRev, DWORD dateFormat, bool bRelativeTimes);
37 // updates sourcecode lines to the given encoding, encode==0 detects the encoding, returns the used encoding
38 int UpdateEncoding(int encode = 0);
40 BOOL IsValidLine(int line)
42 return line >= 0 && line < (int)m_Hash.size();
44 int FindNextLine(CGitHash& commithash, int line, bool bUpOrDown=false);
45 // find first line with the given hash starting with given "line"
46 int FindFirstLine(CGitHash& commithash, int line)
48 int numberOfLines = (int)GetNumberOfLines();
49 for (int i = (line >= 0 ? line : 0); i < numberOfLines; ++i)
51 if (m_Hash[i] == commithash)
52 return i;
54 return -1;
56 // find first line of the current block with the given hash starting with given "line"
57 int FindFirstLineInBlock(CGitHash& commithash, int line)
59 while (line >= 0)
61 if (m_Hash[line] != commithash)
62 return line++;
63 --line;
65 return line;
67 int FindFirstLineWrapAround(const CString& what, int line, bool bCaseSensitive);
69 int GetNumberOfLines() const
71 return (int)m_Hash.size();
74 CGitHash& GetHash(int line)
76 return m_Hash[line];
79 void GetHashes(std::set<CGitHash>& hashes)
81 hashes.clear();
82 for (auto it = m_Hash.begin(); it != m_Hash.end(); ++it)
84 hashes.insert(*it);
88 const CString& GetDate(int line) const
90 return m_Dates[line];
93 const CString& GetAuthor(int line) const
95 return m_Authors[line];
98 const CString& GetFilename(int line) const
100 return m_Filenames[line];
103 int GetOriginalLineNumber(int line) const
105 return m_OriginalLineNumbers[line];
108 const CStringA& GetUtf8Line(int line) const
110 return m_Utf8Lines[line];
113 bool ContainsOnlyFilename(const CString &filename) const;
115 GitRev* GetRev(int line, CGitHashMap & hashToRev)
117 return GetRevForHash(hashToRev, GetHash(line));
120 private:
121 static GitRev* GetRevForHash(CGitHashMap & HashToRev, CGitHash& hash);
122 static CString UnquoteFilename(CStringA& s);
124 std::vector<CGitHash> m_Hash;
125 std::vector<CString> m_Dates;
126 std::vector<CString> m_Authors;
127 std::vector<CString> m_Filenames;
128 std::vector<int> m_OriginalLineNumbers;
129 std::vector<BYTE_VECTOR> m_RawLines;
131 int m_encode;
132 std::vector<CStringA> m_Utf8Lines;