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

Side by Side Diff: base/strings/string_number_conversions.h

Issue 14109020: HexStringToUInt64 should fail for negative input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clamp to closest value in the type range Created 7 years, 7 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
« no previous file with comments | « no previous file | base/strings/string_number_conversions.cc » ('j') | 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 #ifndef BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_ 5 #ifndef BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_
6 #define BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_ 6 #define BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // DoubleToString converts the double to a string format that ignores the 44 // DoubleToString converts the double to a string format that ignores the
45 // locale. If you want to use locale specific formatting, use ICU. 45 // locale. If you want to use locale specific formatting, use ICU.
46 BASE_EXPORT std::string DoubleToString(double value); 46 BASE_EXPORT std::string DoubleToString(double value);
47 47
48 // String -> number conversions ------------------------------------------------ 48 // String -> number conversions ------------------------------------------------
49 49
50 // Perform a best-effort conversion of the input string to a numeric type, 50 // Perform a best-effort conversion of the input string to a numeric type,
51 // setting |*output| to the result of the conversion. Returns true for 51 // setting |*output| to the result of the conversion. Returns true for
52 // "perfect" conversions; returns false in the following cases: 52 // "perfect" conversions; returns false in the following cases:
53 // - Overflow/underflow. |*output| will be set to the maximum value supported 53 // - Overflow. |*output| will be set to the maximum value supported
54 // by the data type.
55 // - Underflow. |*output| will be set to the minimum value supported
54 // by the data type. 56 // by the data type.
55 // - Trailing characters in the string after parsing the number. |*output| 57 // - Trailing characters in the string after parsing the number. |*output|
56 // will be set to the value of the number that was parsed. 58 // will be set to the value of the number that was parsed.
57 // - Leading whitespace in the string before parsing the number. |*output| will 59 // - Leading whitespace in the string before parsing the number. |*output| will
58 // be set to the value of the number that was parsed. 60 // be set to the value of the number that was parsed.
59 // - No characters parseable as a number at the beginning of the string. 61 // - No characters parseable as a number at the beginning of the string.
60 // |*output| will be set to 0. 62 // |*output| will be set to 0.
61 // - Empty string. |*output| will be set to 0. 63 // - Empty string. |*output| will be set to 0.
62 BASE_EXPORT bool StringToInt(const StringPiece& input, int* output); 64 BASE_EXPORT bool StringToInt(const StringPiece& input, int* output);
63 BASE_EXPORT bool StringToInt(const StringPiece16& input, int* output); 65 BASE_EXPORT bool StringToInt(const StringPiece16& input, int* output);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Similar to the previous functions, except that output is a vector of bytes. 113 // Similar to the previous functions, except that output is a vector of bytes.
112 // |*output| will contain as many bytes as were successfully parsed prior to the 114 // |*output| will contain as many bytes as were successfully parsed prior to the
113 // error. There is no overflow, but input.size() must be evenly divisible by 2. 115 // error. There is no overflow, but input.size() must be evenly divisible by 2.
114 // Leading 0x or +/- are not allowed. 116 // Leading 0x or +/- are not allowed.
115 BASE_EXPORT bool HexStringToBytes(const std::string& input, 117 BASE_EXPORT bool HexStringToBytes(const std::string& input,
116 std::vector<uint8>* output); 118 std::vector<uint8>* output);
117 119
118 } // namespace base 120 } // namespace base
119 121
120 #endif // BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_ 122 #endif // BASE_STRINGS_STRING_NUMBER_CONVERSIONS_H_
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_number_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698