| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 WTF_StringToNumber_h | 5 #include "platform/wtf/text/StringToNumber.h" |
| 6 #define WTF_StringToNumber_h | |
| 7 | 6 |
| 8 #include "wtf/WTFExport.h" | 7 // The contents of this header was moved to platform/wtf as part of |
| 9 #include "wtf/text/Unicode.h" | 8 // WTF migration project. See the following post for details: |
| 10 | 9 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/tLdAZCTlcAA/bYXVT8gY
CAAJ |
| 11 namespace WTF { | |
| 12 | |
| 13 // string -> int. | |
| 14 WTF_EXPORT int charactersToIntStrict(const LChar*, | |
| 15 size_t, | |
| 16 bool* ok = 0, | |
| 17 int base = 10); | |
| 18 WTF_EXPORT int charactersToIntStrict(const UChar*, | |
| 19 size_t, | |
| 20 bool* ok = 0, | |
| 21 int base = 10); | |
| 22 WTF_EXPORT int charactersToInt(const LChar*, | |
| 23 size_t, | |
| 24 bool* ok = 0); // ignores trailing garbage | |
| 25 WTF_EXPORT int charactersToInt(const UChar*, | |
| 26 size_t, | |
| 27 bool* ok = 0); // ignores trailing garbage | |
| 28 | |
| 29 // string -> unsigned. | |
| 30 WTF_EXPORT unsigned charactersToUIntStrict(const LChar*, | |
| 31 size_t, | |
| 32 bool* ok = 0, | |
| 33 int base = 10); | |
| 34 WTF_EXPORT unsigned charactersToUIntStrict(const UChar*, | |
| 35 size_t, | |
| 36 bool* ok = 0, | |
| 37 int base = 10); | |
| 38 WTF_EXPORT unsigned charactersToUInt(const LChar*, | |
| 39 size_t, | |
| 40 bool* ok = 0); // ignores trailing garbage | |
| 41 WTF_EXPORT unsigned charactersToUInt(const UChar*, | |
| 42 size_t, | |
| 43 bool* ok = 0); // ignores trailing garbage | |
| 44 | |
| 45 // string -> int64_t. | |
| 46 WTF_EXPORT int64_t charactersToInt64Strict(const LChar*, | |
| 47 size_t, | |
| 48 bool* ok = 0, | |
| 49 int base = 10); | |
| 50 WTF_EXPORT int64_t charactersToInt64Strict(const UChar*, | |
| 51 size_t, | |
| 52 bool* ok = 0, | |
| 53 int base = 10); | |
| 54 WTF_EXPORT int64_t charactersToInt64(const LChar*, | |
| 55 size_t, | |
| 56 bool* ok = 0); // ignores trailing garbage | |
| 57 WTF_EXPORT int64_t charactersToInt64(const UChar*, | |
| 58 size_t, | |
| 59 bool* ok = 0); // ignores trailing garbage | |
| 60 | |
| 61 // string -> uint64_t. | |
| 62 WTF_EXPORT uint64_t charactersToUInt64Strict(const LChar*, | |
| 63 size_t, | |
| 64 bool* ok = 0, | |
| 65 int base = 10); | |
| 66 WTF_EXPORT uint64_t charactersToUInt64Strict(const UChar*, | |
| 67 size_t, | |
| 68 bool* ok = 0, | |
| 69 int base = 10); | |
| 70 WTF_EXPORT uint64_t | |
| 71 charactersToUInt64(const LChar*, | |
| 72 size_t, | |
| 73 bool* ok = 0); // ignores trailing garbage | |
| 74 WTF_EXPORT uint64_t | |
| 75 charactersToUInt64(const UChar*, | |
| 76 size_t, | |
| 77 bool* ok = 0); // ignores trailing garbage | |
| 78 | |
| 79 // FIXME: Like the strict functions above, these give false for "ok" when there | |
| 80 // is trailing garbage. Like the non-strict functions above, these return the | |
| 81 // value when there is trailing garbage. It would be better if these were more | |
| 82 // consistent with the above functions instead. | |
| 83 // | |
| 84 // string -> double. | |
| 85 WTF_EXPORT double charactersToDouble(const LChar*, size_t, bool* ok = 0); | |
| 86 WTF_EXPORT double charactersToDouble(const UChar*, size_t, bool* ok = 0); | |
| 87 WTF_EXPORT double charactersToDouble(const LChar*, | |
| 88 size_t, | |
| 89 size_t& parsedLength); | |
| 90 WTF_EXPORT double charactersToDouble(const UChar*, | |
| 91 size_t, | |
| 92 size_t& parsedLength); | |
| 93 | |
| 94 // string -> float. | |
| 95 WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0); | |
| 96 WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0); | |
| 97 WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength); | |
| 98 WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength); | |
| 99 | |
| 100 } // namespace WTF | |
| 101 | |
| 102 using WTF::charactersToIntStrict; | |
| 103 using WTF::charactersToUIntStrict; | |
| 104 using WTF::charactersToInt64Strict; | |
| 105 using WTF::charactersToUInt64Strict; | |
| 106 using WTF::charactersToInt; | |
| 107 using WTF::charactersToUInt; | |
| 108 using WTF::charactersToInt64; | |
| 109 using WTF::charactersToUInt64; | |
| 110 using WTF::charactersToDouble; | |
| 111 using WTF::charactersToFloat; | |
| 112 | |
| 113 #endif | |
| OLD | NEW |