5 #include "7zMethodID.h"
10 static wchar_t GetHex(Byte value
)
12 return (value
< 10) ? ('0' + value
) : ('A' + (value
- 10));
15 static bool HexCharToInt(wchar_t value
, Byte
&result
)
17 if (value
>= '0' && value
<= '9')
19 else if (value
>= 'a' && value
<= 'f')
20 result
= 10 + value
- 'a';
21 else if (value
>= 'A' && value
<= 'F')
22 result
= 10 + value
- 'A';
28 static bool TwoHexCharsToInt(wchar_t valueHigh
, wchar_t valueLow
, Byte
&result
)
30 Byte resultHigh
, resultLow
;
31 if (!HexCharToInt(valueHigh
, resultHigh
))
33 if (!HexCharToInt(valueLow
, resultLow
))
35 result
= (resultHigh
<< 4) + resultLow
;
39 UString
CMethodID::ConvertToString() const
42 for (int i
= 0; i
< IDSize
; i
++)
45 result
+= GetHex(b
>> 4);
46 result
+= GetHex(b
& 0xF);
51 bool CMethodID::ConvertFromString(const UString
&srcString
)
53 int length
= srcString
.Length();
54 if ((length
& 1) != 0 || (length
>> 1) > kMethodIDSize
)
58 for(i
= 0; i
< IDSize
; i
++)
59 if (!TwoHexCharsToInt(srcString
[i
* 2], srcString
[i
* 2 + 1], ID
[i
]))
61 for(; i
< kMethodIDSize
; i
++)
66 bool operator==(const CMethodID
&a1
, const CMethodID
&a2
)
68 if (a1
.IDSize
!= a2
.IDSize
)
70 for (UInt32 i
= 0; i
< a1
.IDSize
; i
++)
71 if (a1
.ID
[i
] != a2
.ID
[i
])