Chromium Code Reviews| Index: base/string_number_conversions.cc |
| diff --git a/base/string_number_conversions.cc b/base/string_number_conversions.cc |
| index 54eca17511c190288bd04ad4e3956492a09d5836..23bbeae35014529b31ab28764607406d3cd45271 100644 |
| --- a/base/string_number_conversions.cc |
| +++ b/base/string_number_conversions.cc |
| @@ -292,13 +292,15 @@ class BaseIteratorRangeToNumberTraits { |
| static const int kBase = BASE; |
| }; |
| -typedef BaseIteratorRangeToNumberTraits<std::string::const_iterator, int, 10> |
| +typedef BaseIteratorRangeToNumberTraits<StringPiece::const_iterator, int, 10> |
| IteratorRangeToIntTraits; |
|
erikwright (departed)
2011/12/13 20:20:45
How about:
namespace {
template <typename STRING
|
| -typedef BaseIteratorRangeToNumberTraits<string16::const_iterator, int, 10> |
| +typedef BaseIteratorRangeToNumberTraits<StringPiece16::const_iterator, int, 10> |
| WideIteratorRangeToIntTraits; |
| -typedef BaseIteratorRangeToNumberTraits<std::string::const_iterator, int64, 10> |
| +typedef BaseIteratorRangeToNumberTraits<StringPiece::const_iterator, int64, 10> |
| IteratorRangeToInt64Traits; |
| -typedef BaseIteratorRangeToNumberTraits<string16::const_iterator, int64, 10> |
| +typedef BaseIteratorRangeToNumberTraits<StringPiece16::const_iterator, |
| + int64, |
| + 10> |
| WideIteratorRangeToInt64Traits; |
| typedef BaseIteratorRangeToNumberTraits<const char*, int, 10> |
| @@ -390,91 +392,27 @@ std::string DoubleToString(double value) { |
| return std::string(buffer); |
| } |
| -bool StringToInt(const std::string& input, int* output) { |
| +bool StringToInt(const StringPiece& input, int* output) { |
| return IteratorRangeToNumber<IteratorRangeToIntTraits>::Invoke(input.begin(), |
| input.end(), |
| output); |
| } |
| -bool StringToInt(std::string::const_iterator begin, |
| - std::string::const_iterator end, |
| - int* output) { |
| - return IteratorRangeToNumber<IteratorRangeToIntTraits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| - |
| -#if !defined(STD_STRING_ITERATOR_IS_CHAR_POINTER) |
| -bool StringToInt(const char* begin, const char* end, int* output) { |
| - return IteratorRangeToNumber<CharBufferToIntTraits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| -#endif |
| - |
| -bool StringToInt(const string16& input, int* output) { |
| +bool StringToInt(const StringPiece16& input, int* output) { |
| return IteratorRangeToNumber<WideIteratorRangeToIntTraits>::Invoke( |
| input.begin(), input.end(), output); |
| } |
| -bool StringToInt(string16::const_iterator begin, |
| - string16::const_iterator end, |
| - int* output) { |
| - return IteratorRangeToNumber<WideIteratorRangeToIntTraits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| - |
| -#if !defined(BASE_STRING16_ITERATOR_IS_CHAR16_POINTER) |
| -bool StringToInt(const char16* begin, const char16* end, int* output) { |
| - return IteratorRangeToNumber<WideCharBufferToIntTraits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| -#endif |
| - |
| -bool StringToInt64(const std::string& input, int64* output) { |
| +bool StringToInt64(const StringPiece& input, int64* output) { |
| return IteratorRangeToNumber<IteratorRangeToInt64Traits>::Invoke( |
| input.begin(), input.end(), output); |
| } |
| -bool StringToInt64(std::string::const_iterator begin, |
| - std::string::const_iterator end, |
| - int64* output) { |
| - return IteratorRangeToNumber<IteratorRangeToInt64Traits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| - |
| -#if !defined(STD_STRING_ITERATOR_IS_CHAR_POINTER) |
| -bool StringToInt64(const char* begin, const char* end, int64* output) { |
| - return IteratorRangeToNumber<CharBufferToInt64Traits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| -#endif |
| - |
| -bool StringToInt64(const string16& input, int64* output) { |
| +bool StringToInt64(const StringPiece16& input, int64* output) { |
| return IteratorRangeToNumber<WideIteratorRangeToInt64Traits>::Invoke( |
| input.begin(), input.end(), output); |
| } |
| -bool StringToInt64(string16::const_iterator begin, |
| - string16::const_iterator end, |
| - int64* output) { |
| - return IteratorRangeToNumber<WideIteratorRangeToInt64Traits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| - |
| -#if !defined(BASE_STRING16_ITERATOR_IS_CHAR16_POINTER) |
| -bool StringToInt64(const char16* begin, const char16* end, int64* output) { |
| - return IteratorRangeToNumber<WideCharBufferToInt64Traits>::Invoke(begin, |
| - end, |
| - output); |
| -} |
| -#endif |
| - |
| bool StringToDouble(const std::string& input, double* output) { |
| errno = 0; // Thread-safe? It is on at least Mac, Linux, and Windows. |
| char* endptr = NULL; |