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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringToNumber.h

Issue 2058613002: Move WTF string to number converter functions to StringToNumber.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing files. Created 4 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WTF_StringToNumber_h
6 #define WTF_StringToNumber_h
7
8 #include "wtf/WTFExport.h"
9 #include "wtf/text/Unicode.h"
10
11 namespace WTF {
12
13 // string -> int.
14 WTF_EXPORT int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int bas e = 10);
15 WTF_EXPORT int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int bas e = 10);
16 WTF_EXPORT int charactersToInt(const LChar*, size_t, bool* ok = 0); // ignores t railing garbage
17 WTF_EXPORT int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores t railing garbage
18
19 // string -> unsigned.
20 WTF_EXPORT unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, i nt base = 10);
21 WTF_EXPORT unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, i nt base = 10);
22 WTF_EXPORT unsigned charactersToUInt(const LChar*, size_t, bool* ok = 0); // ign ores trailing garbage
23 WTF_EXPORT unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ign ores trailing garbage
24
25 // string -> int64_t.
26 WTF_EXPORT int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = 0, i nt base = 10);
27 WTF_EXPORT int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, i nt base = 10);
28 WTF_EXPORT int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ign ores trailing garbage
29 WTF_EXPORT int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ign ores trailing garbage
30
31 // string -> uint64_t.
32 WTF_EXPORT uint64_t charactersToUInt64Strict(const LChar*, size_t, bool* ok = 0, int base = 10);
33 WTF_EXPORT uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
34 WTF_EXPORT uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = 0); // i gnores trailing garbage
35 WTF_EXPORT uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // i gnores trailing garbage
36
37 // FIXME: Like the strict functions above, these give false for "ok" when there
38 // is trailing garbage. Like the non-strict functions above, these return the
39 // value when there is trailing garbage. It would be better if these were more
40 // consistent with the above functions instead.
41 //
42 // string -> double.
43 WTF_EXPORT double charactersToDouble(const LChar*, size_t, bool* ok = 0);
44 WTF_EXPORT double charactersToDouble(const UChar*, size_t, bool* ok = 0);
45 WTF_EXPORT double charactersToDouble(const LChar*, size_t, size_t& parsedLength) ;
46 WTF_EXPORT double charactersToDouble(const UChar*, size_t, size_t& parsedLength) ;
47
48 // string -> float.
49 WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0);
50 WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0);
51 WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
52 WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
53
54 } // namespace WTF
55
56 using WTF::charactersToIntStrict;
57 using WTF::charactersToUIntStrict;
58 using WTF::charactersToInt64Strict;
59 using WTF::charactersToUInt64Strict;
60 using WTF::charactersToInt;
61 using WTF::charactersToUInt;
62 using WTF::charactersToInt64;
63 using WTF::charactersToUInt64;
64 using WTF::charactersToDouble;
65 using WTF::charactersToFloat;
66
67 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | third_party/WebKit/Source/wtf/text/StringToNumber.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698