LogDlg: When filtering only for paths log entries might contain invalid data
[TortoiseGit.git] / src / Git / gittype.h
blobcfaee237bb8c0a3712ca5ae17d36b8c03b731013
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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.
20 #pragma once
21 #include "GitHash.h"
23 enum
25 TGIT_GIT_SUCCESS=0,
26 TGIT_GIT_ERROR_OPEN_PIP,
27 TGIT_GIT_ERROR_CREATE_PROCESS,
28 TGIT_GIT_ERROR_GET_EXIT_CODE
31 class CGitByteArray:public std::vector<BYTE>
33 public:
34 int find(BYTE data, int start = 0) const
36 for (unsigned int i = start; i < size(); ++i)
37 if( at(i) == data )
38 return i;
39 return -1;
41 int RevertFind(BYTE data, int start = -1) const
43 if(start == -1)
44 start = (int)size() - 1;
46 if(start<0)
47 return -1;
49 for(int i=start; i>=0;i--)
50 if( at(i) == data )
51 return i;
52 return -1;
54 int findNextString(int start = 0) const
56 int pos=start;
59 pos=find(0,pos);
60 if(pos >= 0)
61 ++pos;
62 else
63 break;
65 if (pos >= (int)size())
66 return -1;
68 }while(at(pos)==0);
70 return pos;
72 int append( std::vector<BYTE> &v,int start=0,int end=-1)
74 if(end<0)
75 end = (int)v.size();
76 for (int i = start; i < end; ++i)
77 this->push_back(v[i]);
78 return 0;
80 int append(const BYTE* data, size_t dataSize)
82 if (dataSize == 0)
83 return 0;
84 size_t oldsize=size();
85 resize(oldsize+dataSize);
86 memcpy(&*(begin()+oldsize),data,dataSize);
87 return 0;
91 class CGitGuardedByteArray : public CGitByteArray
93 public:
94 CGitGuardedByteArray() { m_critSec.Init(); }
95 ~CGitGuardedByteArray() { m_critSec.Term(); }
96 CComCriticalSection m_critSec;
99 typedef std::vector<CString> STRING_VECTOR;
100 typedef std::map<CGitHash, STRING_VECTOR> MAP_HASH_NAME;
101 typedef std::map<CString, CString> MAP_STRING_STRING;
102 typedef CGitByteArray BYTE_VECTOR;