OSDN Git Service

TGitCache.exe build success
[tortoisegit/TortoiseGitJp.git] / src / TortoiseMerge / ViewData.h
1 // TortoiseMerge - a Diff/Patch program\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 #include "DiffStates.h"\r
21 #include "EOL.h"\r
22 \r
23 #include <vector>\r
24 \r
25 /**\r
26  * \ingroup TortoiseMerge\r
27  * Holds the information which is required to define a single line of text.\r
28  */\r
29 typedef struct\r
30 {\r
31         CString                                         sLine;\r
32         DiffStates                                      state;\r
33         int                                                     linenumber; \r
34         EOL                                                     ending;\r
35 } viewdata;\r
36 \r
37 /**\r
38  * \ingroup TortoiseMerge\r
39  * Handles the view and diff data a TortoiseMerge view needs.\r
40  */\r
41 class CViewData\r
42 {\r
43 public:\r
44         CViewData(void);\r
45         ~CViewData(void);\r
46 \r
47         void                    AddData(const CString& sLine, DiffStates state, int linenumber, EOL ending);\r
48         void                    AddData(const viewdata& data);\r
49         void                    InsertData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending);\r
50         void                    InsertData(int index, const viewdata& data);\r
51         void                    RemoveData(int index) {m_data.erase(m_data.begin() + index);}\r
52 \r
53         const viewdata& GetData(int index) {return m_data[index];}\r
54         const CString&  GetLine(int index) {return m_data[index].sLine;}\r
55         DiffStates              GetState(int index) {return m_data[index].state;}\r
56         int                             GetLineNumber(int index) {return m_data.size() ? m_data[index].linenumber : 0;}\r
57         int                             FindLineNumber(int number);\r
58         EOL                             GetLineEnding(int index) {return m_data[index].ending;}\r
59 \r
60         int                             GetCount() {return m_data.size();}\r
61 \r
62         void                    SetState(int index, DiffStates state) {m_data[index].state = state;}\r
63         void                    SetLine(int index, const CString& sLine) {m_data[index].sLine = sLine;}\r
64         void                    SetLineNumber(int index, int linenumber) {m_data[index].linenumber = linenumber;}\r
65         void                    SetLineEnding(int index, EOL ending) {m_data[index].ending = ending;}\r
66 \r
67         void                    Clear() {m_data.clear();}\r
68         void                    Reserve(int length) {m_data.reserve(length);}\r
69 \r
70 protected:\r
71         std::vector<viewdata>           m_data;\r
72 };\r