/* * Copyright (c) 2022, David Tuin * Copyright (c) 2025-2026, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace AK { template struct ParseFirstNumberResult { T value { 0 }; size_t characters_parsed { 0 }; }; template Optional> parse_first_number(StringView, TrimWhitespace = TrimWhitespace::Yes, int base = 10); template Optional> parse_first_number(Utf16View const&, TrimWhitespace = TrimWhitespace::Yes, int base = 10); template Optional parse_number(StringView, TrimWhitespace = TrimWhitespace::Yes, int base = 10); template Optional parse_number(Utf16View const&, TrimWhitespace = TrimWhitespace::Yes, int base = 10); template Optional parse_hexadecimal_number(StringView, TrimWhitespace = TrimWhitespace::Yes); template Optional parse_hexadecimal_number(Utf16View const&, TrimWhitespace = TrimWhitespace::Yes); struct DecimalExponentialForm { constexpr bool operator==(DecimalExponentialForm const& other) const = default; bool sign { false }; u64 fraction { 0 }; i32 exponent { 0 }; }; template DecimalExponentialForm convert_to_decimal_exponential_form(T value); }