diff options
Diffstat (limited to 'CPP/Common/StringToInt.cpp')
-rw-r--r-- | CPP/Common/StringToInt.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/CPP/Common/StringToInt.cpp b/CPP/Common/StringToInt.cpp index 839867a..bc4926e 100644 --- a/CPP/Common/StringToInt.cpp +++ b/CPP/Common/StringToInt.cpp | |||
@@ -26,6 +26,33 @@ CONVERT_STRING_TO_UINT_FUNC(UInt32, wchar_t, wchar_t) | |||
26 | CONVERT_STRING_TO_UINT_FUNC(UInt64, char, Byte) | 26 | CONVERT_STRING_TO_UINT_FUNC(UInt64, char, Byte) |
27 | CONVERT_STRING_TO_UINT_FUNC(UInt64, wchar_t, wchar_t) | 27 | CONVERT_STRING_TO_UINT_FUNC(UInt64, wchar_t, wchar_t) |
28 | 28 | ||
29 | /* | ||
30 | Int32 ConvertStringToInt32(const char *s, const char **end) throw() | ||
31 | { | ||
32 | if (end) | ||
33 | *end = s; | ||
34 | const char *s2 = s; | ||
35 | if (*s == '-') | ||
36 | s2++; | ||
37 | if (*s2 == 0) | ||
38 | return 0; | ||
39 | const char *end2; | ||
40 | UInt32 res = ConvertStringToUInt32(s2, &end2); | ||
41 | if (*s == '-') | ||
42 | { | ||
43 | if (res > ((UInt32)1 << (32 - 1))) | ||
44 | return 0; | ||
45 | } | ||
46 | else if ((res & ((UInt32)1 << (32 - 1))) != 0) | ||
47 | return 0; | ||
48 | if (end) | ||
49 | *end = end2; | ||
50 | if (*s == '-') | ||
51 | return -(Int32)res; | ||
52 | return (Int32)res; | ||
53 | } | ||
54 | */ | ||
55 | |||
29 | Int32 ConvertStringToInt32(const wchar_t *s, const wchar_t **end) throw() | 56 | Int32 ConvertStringToInt32(const wchar_t *s, const wchar_t **end) throw() |
30 | { | 57 | { |
31 | if (end) | 58 | if (end) |