OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/string_number_conversions.h" | 5 #include "base/strings/string_number_conversions.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <wctype.h> | 10 #include <wctype.h> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return false; | 124 return false; |
125 } | 125 } |
126 return true; | 126 return true; |
127 } | 127 } |
128 }; | 128 }; |
129 | 129 |
130 template<int BASE, typename CHAR> bool CharToDigit(CHAR c, uint8* digit) { | 130 template<int BASE, typename CHAR> bool CharToDigit(CHAR c, uint8* digit) { |
131 return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit); | 131 return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit); |
132 } | 132 } |
133 | 133 |
134 // There is an IsWhitespace for wchars defined in string_util.h, but it is | 134 // There is an IsUnicodeWhitespace for wchars defined in string_util.h, but it |
135 // locale independent, whereas the functions we are replacing were | 135 // is locale independent, whereas the functions we are replacing were |
136 // locale-dependent. TBD what is desired, but for the moment let's not introduce | 136 // locale-dependent. TBD what is desired, but for the moment let's not |
137 // a change in behaviour. | 137 // introduce a change in behaviour. |
138 template<typename CHAR> class WhitespaceHelper { | 138 template<typename CHAR> class WhitespaceHelper { |
139 }; | 139 }; |
140 | 140 |
141 template<> class WhitespaceHelper<char> { | 141 template<> class WhitespaceHelper<char> { |
142 public: | 142 public: |
143 static bool Invoke(char c) { | 143 static bool Invoke(char c) { |
144 return 0 != isspace(static_cast<unsigned char>(c)); | 144 return 0 != isspace(static_cast<unsigned char>(c)); |
145 } | 145 } |
146 }; | 146 }; |
147 | 147 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 bool HexStringToUInt64(const StringPiece& input, uint64* output) { | 520 bool HexStringToUInt64(const StringPiece& input, uint64* output) { |
521 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke( | 521 return IteratorRangeToNumber<HexIteratorRangeToUInt64Traits>::Invoke( |
522 input.begin(), input.end(), output); | 522 input.begin(), input.end(), output); |
523 } | 523 } |
524 | 524 |
525 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { | 525 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { |
526 return HexStringToBytesT(input, output); | 526 return HexStringToBytesT(input, output); |
527 } | 527 } |
528 | 528 |
529 } // namespace base | 529 } // namespace base |
OLD | NEW |