ladybird/Libraries/LibWeb/HTML/Numbers.h
Tim Ledbetter d02b763cd6 LibWeb: Add parse_integer_digits methods
The rules for parsing integers don't specify an upper bound on the
value that can be returned, so the `parse_integer_digits` method can be
used to check whether the given arbitrarily-large StringView is valid
according to these rules. The `parse_integer` and
`parse_non_negative_integer` methods would fail for values larger than
2147483647 when they shouldn't have.
2024-12-02 10:25:27 +01:00

28 lines
746 B
C++

/*
* Copyright (c) 2023, Jonatan Klemets <jonatan.r.klemets@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <AK/String.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/WebIDL/Types.h>
namespace Web::HTML {
Optional<i32> parse_integer(StringView string);
Optional<StringView> parse_integer_digits(StringView string);
Optional<u32> parse_non_negative_integer(StringView string);
Optional<StringView> parse_non_negative_integer_digits(StringView string);
Optional<double> parse_floating_point_number(StringView string);
bool is_valid_floating_point_number(StringView string);
WebIDL::ExceptionOr<String> convert_non_negative_integer_to_string(JS::Realm&, WebIDL::Long);
}