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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/StringToNumber.h
diff --git a/third_party/WebKit/Source/wtf/text/StringToNumber.h b/third_party/WebKit/Source/wtf/text/StringToNumber.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8484e7f8b73be1b5ad568ba4355ba4856684808
--- /dev/null
+++ b/third_party/WebKit/Source/wtf/text/StringToNumber.h
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WTF_StringToNumber_h
+#define WTF_StringToNumber_h
+
+#include "wtf/WTFExport.h"
+#include "wtf/text/Unicode.h"
+
+namespace WTF {
+
+// string -> int.
+WTF_EXPORT int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT int charactersToInt(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
+WTF_EXPORT int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
+
+// string -> unsigned.
+WTF_EXPORT unsigned charactersToUIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT unsigned charactersToUInt(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
+WTF_EXPORT unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
+
+// string -> int64_t.
+WTF_EXPORT int64_t charactersToInt64Strict(const LChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
+WTF_EXPORT int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
+
+// string -> uint64_t.
+WTF_EXPORT uint64_t charactersToUInt64Strict(const LChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
+WTF_EXPORT uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
+WTF_EXPORT uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
+
+// FIXME: Like the strict functions above, these give false for "ok" when there
+// is trailing garbage. Like the non-strict functions above, these return the
+// value when there is trailing garbage. It would be better if these were more
+// consistent with the above functions instead.
+//
+// string -> double.
+WTF_EXPORT double charactersToDouble(const LChar*, size_t, bool* ok = 0);
+WTF_EXPORT double charactersToDouble(const UChar*, size_t, bool* ok = 0);
+WTF_EXPORT double charactersToDouble(const LChar*, size_t, size_t& parsedLength);
+WTF_EXPORT double charactersToDouble(const UChar*, size_t, size_t& parsedLength);
+
+// string -> float.
+WTF_EXPORT float charactersToFloat(const LChar*, size_t, bool* ok = 0);
+WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0);
+WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
+WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
+
+} // namespace WTF
+
+using WTF::charactersToIntStrict;
+using WTF::charactersToUIntStrict;
+using WTF::charactersToInt64Strict;
+using WTF::charactersToUInt64Strict;
+using WTF::charactersToInt;
+using WTF::charactersToUInt;
+using WTF::charactersToInt64;
+using WTF::charactersToUInt64;
+using WTF::charactersToDouble;
+using WTF::charactersToFloat;
+
+#endif
« 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