Commit 723fedc0 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Add comments about ToFoo() functions to WTFString.h and AtomicString.h.

NOTRY=true

Bug: 746157
Change-Id: If1a8d3ecfa0101f6a8d432c658f676089830203c
Reviewed-on: https://chromium-review.googlesource.com/599270Reviewed-by: default avatarTakayoshi Kochi <kochi@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491648}
parent b567cf95
......@@ -185,6 +185,7 @@ class WTF_EXPORT AtomicString {
AtomicString LowerASCII() const;
AtomicString UpperASCII() const;
// See comments in WTFString.h.
int ToInt(bool* ok = 0) const { return string_.ToInt(ok); }
double ToDouble(bool* ok = 0) const { return string_.ToDouble(ok); }
float ToFloat(bool* ok = 0) const { return string_.ToFloat(ok); }
......
......@@ -373,12 +373,38 @@ class WTF_EXPORT String {
// Convert the string into a number.
// The following ToFooStrict functions accept:
// - leading '+'
// - leading Unicode whitespace
// - trailing Unicode whitespace
// - no "-0" (ToUIntStrict and ToUInt64Strict)
// - no out-of-range numbers which the resultant type can't represent
//
// If the input string is not acceptable, 0 is returned and |*ok| becomes
// |false|.
//
// We can use these functions to implement a Web Platform feature only if the
// input string is already valid according to the specification of the
// feature.
int ToIntStrict(bool* ok = 0) const;
unsigned ToUIntStrict(bool* ok = 0) const;
unsigned HexToUIntStrict(bool* ok) const;
int64_t ToInt64Strict(bool* ok = 0) const;
uint64_t ToUInt64Strict(bool* ok = 0) const;
// The following ToFoo functions accept:
// - leading '+'
// - leading Unicode whitespace
// - trailing garbage
// - no "-0" (ToUInt and ToUInt64)
// - no out-of-range numbers which the resultant type can't represent
//
// If the input string is not acceptable, 0 is returned and |*ok| becomes
// |false|.
//
// We can use these functions to implement a Web Platform feature only if the
// input string is already valid according to the specification of the
// feature.
int ToInt(bool* ok = 0) const;
unsigned ToUInt(bool* ok = 0) const;
int64_t ToInt64(bool* ok = 0) const;
......@@ -400,6 +426,13 @@ class WTF_EXPORT String {
// A small absolute numbers which a double/float can't represent is accepted,
// and 0 is returned
//
// If the input string is not acceptable, 0.0 is returned and |*ok| becomes
// |false|.
//
// We can use these functions to implement a Web Platform feature only if the
// input string is already valid according to the specification of the
// feature.
//
// 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment