5 #define GIT_HASH_SIZE 20
10 unsigned char m_hash
[GIT_HASH_SIZE
];
14 memset(m_hash
,0, GIT_HASH_SIZE
);
18 memcpy(m_hash
,p
,GIT_HASH_SIZE
);
20 CGitHash
& operator = (CString
&str
)
26 CGitHash(CString
&str
)
28 if(str
.GetLength()<GIT_HASH_SIZE
)
36 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
40 for(int j
=2*i
;j
<=2*i
+1;j
++)
45 if(ch
>= _T('0') && ch
<= _T('9'))
46 a
|= (ch
- _T('0'))&0xF;
47 else if(ch
>=_T('A') && ch
<= _T('F'))
48 a
|= ((ch
- _T('A'))&0xF) + 10 ;
49 else if(ch
>=_T('a') && ch
<= _T('f'))
50 a
|= ((ch
- _T('a'))&0xF) + 10;
58 memset(m_hash
,0, GIT_HASH_SIZE
);
62 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
74 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
76 a
.Format(_T("%02x"),m_hash
[i
]);
86 bool operator == (const CGitHash
&hash
)
88 return memcmp(m_hash
,hash
.m_hash
,GIT_HASH_SIZE
) == 0;
92 friend bool operator<(const CGitHash
& left
, const CGitHash
& right
)
94 return memcmp(left
.m_hash
,right
.m_hash
,GIT_HASH_SIZE
) < 0;
97 friend bool operator>(const CGitHash
& left
, const CGitHash
& right
)
99 return memcmp(left
.m_hash
, right
.m_hash
, GIT_HASH_SIZE
) > 0;
102 friend bool operator != (const CGitHash
& left
, const CGitHash
& right
)
104 return memcmp(left
.m_hash
, right
.m_hash
, GIT_HASH_SIZE
) != 0;
106 #if defined(_MFC_VER)
107 friend CArchive
& AFXAPI
operator<<(CArchive
& ar
, CGitHash
& hash
)
109 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
113 friend CArchive
& AFXAPI
operator>>(CArchive
& ar
, CGitHash
& hash
)
115 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)