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 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
32 for(int j
=2*i
;j
<=2*i
+1;j
++)
37 if(ch
>= _T('0') && ch
<= _T('9'))
38 a
|= (ch
- _T('0'))&0xF;
39 else if(ch
>=_T('A') && ch
<= _T('F'))
40 a
|= ((ch
- _T('A'))&0xF) + 10 ;
41 else if(ch
>=_T('a') && ch
<= _T('f'))
42 a
|= ((ch
- _T('a'))&0xF) + 10;
50 memset(m_hash
,0, GIT_HASH_SIZE
);
54 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
66 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
68 a
.Format(_T("%02x"),m_hash
[i
]);
78 bool operator == (const CGitHash
&hash
)
80 return memcmp(m_hash
,hash
.m_hash
,GIT_HASH_SIZE
) == 0;
84 friend bool operator<(const CGitHash
& left
, const CGitHash
& right
)
86 return memcmp(left
.m_hash
,right
.m_hash
,GIT_HASH_SIZE
) < 0;
89 friend bool operator>(const CGitHash
& left
, const CGitHash
& right
)
91 return memcmp(left
.m_hash
, right
.m_hash
, GIT_HASH_SIZE
) > 0;
95 friend CArchive
& AFXAPI
operator<<(CArchive
& ar
, CGitHash
& hash
)
97 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)
101 friend CArchive
& AFXAPI
operator>>(CArchive
& ar
, CGitHash
& hash
)
103 for(int i
=0;i
<GIT_HASH_SIZE
;i
++)