OSDN Git Service

Add Show Whole Project Checkbox at commitdlg.
[tortoisegit/TortoiseGitJp.git] / src / Git / gittype.h
index a8b3028..a66f4b6 100644 (file)
@@ -38,6 +38,38 @@ public:
 \r
                return pos;\r
        }\r
+       int findData(const BYTE* dataToFind, size_t dataSize, int start=0)\r
+       {\r
+               //Pre checks\r
+               if(empty())\r
+                       return -1;\r
+               if(dataSize==0)\r
+                       return 0;\r
+               if(dataSize>size()-start)\r
+                       return -1;//Data to find is greater then data to search in. No match\r
+\r
+               //Initialize\r
+               const BYTE* pos=&*(begin()+start);\r
+               const BYTE* dataEnd=&*(begin()+(size()-dataSize) );++dataEnd;//Set end one step after last place to search\r
+               if(pos>=dataEnd)\r
+                       return -1;//Started over end. Return not found\r
+               if(dataSize==0)\r
+                       return start;//No search data. Return current position\r
+               BYTE firstByte=dataToFind[0];\r
+               while(pos<dataEnd)\r
+               {\r
+                       //memchr for first character\r
+                       const BYTE* found=(const BYTE*)memchr(pos,firstByte,dataEnd-pos);\r
+                       if(found==NULL)\r
+                               return -1;//Not found\r
+                       //check rest of characters\r
+                       if(memcmp(found,dataToFind,dataSize)==0)\r
+                               return found-&*begin();//Match. Return position.\r
+                       //No match. Set position on next byte and continue search\r
+                       pos=found+1;\r
+               }\r
+               return -1;\r
+       }\r
        int append( std::vector<BYTE> &v,int start=0,int end=-1)\r
        {\r
                if(end<0)\r
@@ -46,7 +78,15 @@ public:
                        this->push_back(v[i]);\r
                return 0;\r
        }\r
+       int append(const BYTE* data, size_t dataSize)\r
+       {\r
+               size_t oldsize=size();\r
+               resize(oldsize+dataSize);\r
+               memcpy(&*(begin()+oldsize),data,dataSize);\r
+               return 0;\r
+       }\r
 };\r
 typedef std::vector<CString> STRING_VECTOR;\r
 typedef std::map<CString, STRING_VECTOR> MAP_HASH_NAME;\r
-typedef CGitByteArray BYTE_VECTOR;
\ No newline at end of file
+typedef CGitByteArray BYTE_VECTOR;\r
+\r