OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 : public StringToUnsignedIntegerTraits<unsigned int, unsigned long> { | 103 : public StringToUnsignedIntegerTraits<unsigned int, unsigned long> { |
104 static LongType Convert(const char* str, char** end, int base) { | 104 static LongType Convert(const char* str, char** end, int base) { |
105 if (str[0] == '-') { | 105 if (str[0] == '-') { |
106 *end = const_cast<char*>(str); | 106 *end = const_cast<char*>(str); |
107 return 0; | 107 return 0; |
108 } | 108 } |
109 return strtoul(str, end, base); | 109 return strtoul(str, end, base); |
110 } | 110 } |
111 }; | 111 }; |
112 | 112 |
| 113 struct StringToInt64Traits |
| 114 : public StringToSignedIntegerTraits<int64_t, int64_t> { |
| 115 static LongType Convert(const char* str, char** end, int base) { |
| 116 return strtoll(str, end, base); |
| 117 } |
| 118 }; |
| 119 |
113 struct StringToUnsignedInt64Traits | 120 struct StringToUnsignedInt64Traits |
114 : public StringToUnsignedIntegerTraits<uint64_t, uint64_t> { | 121 : public StringToUnsignedIntegerTraits<uint64_t, uint64_t> { |
115 static LongType Convert(const char* str, char** end, int base) { | 122 static LongType Convert(const char* str, char** end, int base) { |
116 if (str[0] == '-') { | 123 if (str[0] == '-') { |
117 *end = const_cast<char*>(str); | 124 *end = const_cast<char*>(str); |
118 return 0; | 125 return 0; |
119 } | 126 } |
120 return strtoull(str, end, base); | 127 return strtoull(str, end, base); |
121 } | 128 } |
122 }; | 129 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 namespace crashpad { | 166 namespace crashpad { |
160 | 167 |
161 bool StringToNumber(const base::StringPiece& string, int* number) { | 168 bool StringToNumber(const base::StringPiece& string, int* number) { |
162 return StringToIntegerInternal<StringToIntTraits>(string, number); | 169 return StringToIntegerInternal<StringToIntTraits>(string, number); |
163 } | 170 } |
164 | 171 |
165 bool StringToNumber(const base::StringPiece& string, unsigned int* number) { | 172 bool StringToNumber(const base::StringPiece& string, unsigned int* number) { |
166 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number); | 173 return StringToIntegerInternal<StringToUnsignedIntTraits>(string, number); |
167 } | 174 } |
168 | 175 |
| 176 bool StringToNumber(const base::StringPiece& string, int64_t* number) { |
| 177 return StringToIntegerInternal<StringToInt64Traits>(string, number); |
| 178 } |
| 179 |
169 bool StringToNumber(const base::StringPiece& string, uint64_t* number) { | 180 bool StringToNumber(const base::StringPiece& string, uint64_t* number) { |
170 return StringToIntegerInternal<StringToUnsignedInt64Traits>(string, number); | 181 return StringToIntegerInternal<StringToUnsignedInt64Traits>(string, number); |
171 } | 182 } |
172 | 183 |
173 } // namespace crashpad | 184 } // namespace crashpad |
OLD | NEW |