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_STRING_NUMBER_CONVERSIONS_H_ | 5 #ifndef BASE_STRING_NUMBER_CONVERSIONS_H_ |
6 #define BASE_STRING_NUMBER_CONVERSIONS_H_ | 6 #define BASE_STRING_NUMBER_CONVERSIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // string will be in upper case. This function does not check if |size| is | 88 // string will be in upper case. This function does not check if |size| is |
89 // within reasonable limits since it's written with trusted data in mind. If | 89 // within reasonable limits since it's written with trusted data in mind. If |
90 // you suspect that the data you want to format might be large, the absolute | 90 // you suspect that the data you want to format might be large, the absolute |
91 // max size for |size| should be is | 91 // max size for |size| should be is |
92 // std::numeric_limits<size_t>::max() / 2 | 92 // std::numeric_limits<size_t>::max() / 2 |
93 BASE_EXPORT std::string HexEncode(const void* bytes, size_t size); | 93 BASE_EXPORT std::string HexEncode(const void* bytes, size_t size); |
94 | 94 |
95 // Best effort conversion, see StringToInt above for restrictions. | 95 // Best effort conversion, see StringToInt above for restrictions. |
96 BASE_EXPORT bool HexStringToInt(const StringPiece& input, int* output); | 96 BASE_EXPORT bool HexStringToInt(const StringPiece& input, int* output); |
97 | 97 |
| 98 BASE_EXPORT bool HexStringToInt64(const StringPiece& input, int64* output); |
| 99 |
98 // Similar to the previous functions, except that output is a vector of bytes. | 100 // Similar to the previous functions, except that output is a vector of bytes. |
99 // |*output| will contain as many bytes as were successfully parsed prior to the | 101 // |*output| will contain as many bytes as were successfully parsed prior to the |
100 // error. There is no overflow, but input.size() must be evenly divisible by 2. | 102 // error. There is no overflow, but input.size() must be evenly divisible by 2. |
101 // Leading 0x or +/- are not allowed. | 103 // Leading 0x or +/- are not allowed. |
102 BASE_EXPORT bool HexStringToBytes(const std::string& input, | 104 BASE_EXPORT bool HexStringToBytes(const std::string& input, |
103 std::vector<uint8>* output); | 105 std::vector<uint8>* output); |
104 | 106 |
105 } // namespace base | 107 } // namespace base |
106 | 108 |
107 #endif // BASE_STRING_NUMBER_CONVERSIONS_H_ | 109 #endif // BASE_STRING_NUMBER_CONVERSIONS_H_ |
108 | 110 |
OLD | NEW |