Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: base/string_number_conversions.cc

Issue 9296002: Add StringToSizeT to base/string_number_conversions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-land Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/string_number_conversions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_number_conversions.h" 5 #include "base/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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 419 }
420 420
421 bool StringToUint64(const StringPiece& input, uint64* output) { 421 bool StringToUint64(const StringPiece& input, uint64* output) {
422 return StringToIntImpl(input, output); 422 return StringToIntImpl(input, output);
423 } 423 }
424 424
425 bool StringToUint64(const StringPiece16& input, uint64* output) { 425 bool StringToUint64(const StringPiece16& input, uint64* output) {
426 return String16ToIntImpl(input, output); 426 return String16ToIntImpl(input, output);
427 } 427 }
428 428
429 bool StringToSizeT(const StringPiece& input, size_t* output) {
430 return StringToIntImpl(input, output);
431 }
432
433 bool StringToSizeT(const StringPiece16& input, size_t* output) {
434 return String16ToIntImpl(input, output);
435 }
436
429 bool StringToDouble(const std::string& input, double* output) { 437 bool StringToDouble(const std::string& input, double* output) {
430 errno = 0; // Thread-safe? It is on at least Mac, Linux, and Windows. 438 errno = 0; // Thread-safe? It is on at least Mac, Linux, and Windows.
431 char* endptr = NULL; 439 char* endptr = NULL;
432 *output = dmg_fp::strtod(input.c_str(), &endptr); 440 *output = dmg_fp::strtod(input.c_str(), &endptr);
433 441
434 // Cases to return false: 442 // Cases to return false:
435 // - If errno is ERANGE, there was an overflow or underflow. 443 // - If errno is ERANGE, there was an overflow or underflow.
436 // - If the input string is empty, there was nothing to parse. 444 // - If the input string is empty, there was nothing to parse.
437 // - If endptr does not point to the end of the string, there are either 445 // - If endptr does not point to the end of the string, there are either
438 // characters remaining in the string after a parsed number, or the string 446 // characters remaining in the string after a parsed number, or the string
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 bool HexStringToInt(const StringPiece& input, int* output) { 479 bool HexStringToInt(const StringPiece& input, int* output) {
472 return IteratorRangeToNumber<HexIteratorRangeToIntTraits>::Invoke( 480 return IteratorRangeToNumber<HexIteratorRangeToIntTraits>::Invoke(
473 input.begin(), input.end(), output); 481 input.begin(), input.end(), output);
474 } 482 }
475 483
476 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { 484 bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) {
477 return HexStringToBytesT(input, output); 485 return HexStringToBytesT(input, output);
478 } 486 }
479 487
480 } // namespace base 488 } // namespace base
OLDNEW
« no previous file with comments | « base/string_number_conversions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698