If CTGitPathList::ParserFromLsFile() fails, write the output to temp file for inspection
[TortoiseGit.git] / src / TortoiseMerge / ViewData.h
blobe8d62b501f8d72d4ef77c52a593d563c196a5ac8
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2007-2011 - 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 "DiffStates.h"
21 #include "EOL.h"
23 #include <vector>
25 enum HIDESTATE
27 HIDESTATE_SHOWN,
28 HIDESTATE_HIDDEN,
29 HIDESTATE_MARKER,
32 /**
33 * \ingroup TortoiseMerge
34 * Holds the information which is required to define a single line of text.
36 class viewdata
38 public:
39 viewdata()
40 : state(DIFFSTATE_UNKNOWN)
41 , linenumber(-1)
42 , movedIndex(-1)
43 , ending(EOL_AUTOLINE)
44 , hidestate(HIDESTATE_HIDDEN)
48 viewdata(
49 const CString& sLineInit,
50 DiffStates stateInit,
51 int linenumberInit,
52 EOL endingInit,
53 HIDESTATE hideInit,
54 int movedIndexInit)
55 : state(stateInit)
56 , linenumber(linenumberInit)
57 , movedIndex(movedIndexInit)
58 , ending(endingInit)
59 , hidestate(hideInit)
61 sLine=sLineInit;
64 CString sLine;
65 DiffStates state;
66 int linenumber;
67 int movedIndex;
68 EOL ending;
69 HIDESTATE hidestate;
72 /**
73 * \ingroup TortoiseMerge
74 * Handles the view and diff data a TortoiseMerge view needs.
76 class CViewData
78 public:
79 CViewData(void);
80 ~CViewData(void);
82 void AddData(const CString& sLine, DiffStates state, int linenumber, EOL ending, HIDESTATE hide, int movedline);
83 void AddData(const viewdata& data);
84 void AddEmpty() {AddData(CString(), DIFFSTATE_EMPTY, -1, EOL_NOENDING, HIDESTATE_SHOWN, -1);}
85 void InsertData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending, HIDESTATE hide, int movedline);
86 void InsertData(int index, const viewdata& data);
87 void RemoveData(int index) {m_data.erase(m_data.begin() + index);}
89 const viewdata& GetData(int index) {return m_data[index];}
90 const CString& GetLine(int index) const {return m_data[index].sLine;}
91 DiffStates GetState(int index) const {return m_data[index].state;}
92 HIDESTATE GetHideState(int index) {return m_data[index].hidestate;}
93 int GetLineNumber(int index) {return m_data.size() ? m_data[index].linenumber : 0;}
94 int GetMovedIndex(int index) {return m_data.size() ? m_data[index].movedIndex: 0;}
95 int FindLineNumber(int number);
96 EOL GetLineEnding(int index) const {return m_data[index].ending;}
98 int GetCount() { return (int)m_data.size(); }
100 void SetData(int index, const viewdata& data) {m_data[index] = data;};
101 void SetState(int index, DiffStates state) {m_data[index].state = state;}
102 void SetLine(int index, const CString& sLine) {m_data[index].sLine = sLine;}
103 void SetLineNumber(int index, int linenumber) {m_data[index].linenumber = linenumber;}
104 void SetLineEnding(int index, EOL ending) {m_data[index].ending = ending;}
105 void SetMovedIndex(int index, int movedIndex) {m_data[index].movedIndex = movedIndex;}
106 void SetLineHideState(int index, HIDESTATE state) {m_data[index].hidestate = state;}
108 void Clear() {m_data.clear();}
109 void Reserve(int length) {m_data.reserve(length);}
111 protected:
112 std::vector<viewdata> m_data;