optimize TGitCache for CLI operations
[TortoiseGit.git] / src / TortoiseMerge / ViewData.h
blobd94f29ef88e8a464873cb997b1a19678e66797e2
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2007-2008 - 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 /**
26 * \ingroup TortoiseMerge
27 * Holds the information which is required to define a single line of text.
29 typedef struct
31 CString sLine;
32 DiffStates state;
33 int linenumber;
34 EOL ending;
35 } viewdata;
37 /**
38 * \ingroup TortoiseMerge
39 * Handles the view and diff data a TortoiseMerge view needs.
41 class CViewData
43 public:
44 CViewData(void);
45 ~CViewData(void);
47 void AddData(const CString& sLine, DiffStates state, int linenumber, EOL ending);
48 void AddData(const viewdata& data);
49 void InsertData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending);
50 void InsertData(int index, const viewdata& data);
51 void RemoveData(int index) {m_data.erase(m_data.begin() + index);}
53 const viewdata& GetData(int index) {return m_data[index];}
54 const CString& GetLine(int index) {return m_data[index].sLine;}
55 DiffStates GetState(int index) {return m_data[index].state;}
56 int GetLineNumber(int index) {return m_data.size() ? m_data[index].linenumber : 0;}
57 int FindLineNumber(int number);
58 EOL GetLineEnding(int index) {return m_data[index].ending;}
60 int GetCount() {return m_data.size();}
62 void SetState(int index, DiffStates state) {m_data[index].state = state;}
63 void SetLine(int index, const CString& sLine) {m_data[index].sLine = sLine;}
64 void SetLineNumber(int index, int linenumber) {m_data[index].linenumber = linenumber;}
65 void SetLineEnding(int index, EOL ending) {m_data[index].ending = ending;}
67 void Clear() {m_data.clear();}
68 void Reserve(int length) {m_data.reserve(length);}
70 protected:
71 std::vector<viewdata> m_data;