1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2007-2011, 2013-2014 - 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.
20 #include "DiffStates.h"
33 * \ingroup TortoiseMerge
34 * Holds the information which is required to define a single line of text.
40 : state(DIFFSTATE_UNKNOWN
)
44 , ending(EOL_AUTOLINE
)
45 , hidestate(HIDESTATE_HIDDEN
)
51 const CString
& sLineInit
,
56 bool markedInit
= false)
58 , linenumber(linenumberInit
)
79 * \ingroup TortoiseMerge
80 * Handles the view and diff data a TortoiseMerge view needs.
88 void AddData(const CString
& sLine
, DiffStates state
, int linenumber
, EOL ending
, HIDESTATE hide
, int movedline
);
89 void AddData(const viewdata
& data
);
90 void AddEmpty() {AddData(CString(), DIFFSTATE_EMPTY
, -1, EOL_NOENDING
, HIDESTATE_SHOWN
, -1);}
91 void InsertData(int index
, const CString
& sLine
, DiffStates state
, int linenumber
, EOL ending
, HIDESTATE hide
, int movedline
);
92 void InsertData(int index
, const viewdata
& data
);
93 void RemoveData(int index
) {m_data
.erase(m_data
.begin() + index
);}
95 const viewdata
& GetData(int index
) const {return m_data
[index
];}
96 const CString
& GetLine(int index
) const {return m_data
[index
].sLine
;}
97 DiffStates
GetState(int index
) const {return m_data
[index
].state
;}
98 HIDESTATE
GetHideState(int index
) const {return m_data
[index
].hidestate
;}
99 int GetLineNumber(int index
) const {return m_data
.size() ? m_data
[index
].linenumber
: 0;}
100 int GetMovedIndex(int index
) const {return m_data
.size() ? m_data
[index
].movedIndex
: 0;}
101 bool IsMoved(int index
) const {return m_data
.size() ? m_data
[index
].movedIndex
>= 0 : false;}
102 bool IsMovedFrom(int index
) const {return m_data
.size() ? m_data
[index
].movedFrom
: true;}
103 int FindLineNumber(int number
) const;
104 EOL
GetLineEnding(int index
) const {return m_data
[index
].ending
;}
105 bool GetMarked(int index
) const {return m_data
[index
].marked
;}
107 int GetCount() const { return (int)m_data
.size();}
109 void SetData(int index
, const viewdata
& data
) {m_data
[index
] = data
;};
110 void SetState(int index
, DiffStates state
) {m_data
[index
].state
= state
;}
111 void SetLine(int index
, const CString
& sLine
) {m_data
[index
].sLine
= sLine
;}
112 void SetLineNumber(int index
, int linenumber
) {m_data
[index
].linenumber
= linenumber
;}
113 void SetLineEnding(int index
, EOL ending
) {m_data
[index
].ending
= ending
;}
114 void SetMovedIndex(int index
, int movedIndex
, bool movedFrom
) {m_data
[index
].movedIndex
= movedIndex
; m_data
[index
].movedFrom
= movedFrom
;}
115 void SetLineHideState(int index
, HIDESTATE state
) {m_data
[index
].hidestate
= state
;}
116 void SetMarked(int index
, bool marked
) {m_data
[index
].marked
= marked
;}
118 void Clear() {m_data
.clear();}
119 void Reserve(int length
) {m_data
.reserve(length
);}
122 std::vector
<viewdata
> m_data
;