| 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 #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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |