1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:17:44 +00:00

AK: Add to_{double, float} convenience functions to all string types

These are guarded with #ifndef KERNEL, since doubles (and floats) are
not allowed in KERNEL mode.
In StringUtils there is convert_to_floating_point which does have a
template parameter incase you have a templated type.
This commit is contained in:
davidot 2022-10-11 00:48:45 +02:00 committed by Linus Groh
parent 2334cd85a2
commit 6fd8e96d53
8 changed files with 68 additions and 0 deletions

View file

@ -116,6 +116,10 @@ public:
[[nodiscard]] Optional<T> to_int(TrimWhitespace = TrimWhitespace::Yes) const;
template<typename T = unsigned>
[[nodiscard]] Optional<T> to_uint(TrimWhitespace = TrimWhitespace::Yes) const;
#ifndef KERNEL
[[nodiscard]] Optional<double> to_double(TrimWhitespace = TrimWhitespace::Yes) const;
[[nodiscard]] Optional<float> to_float(TrimWhitespace = TrimWhitespace::Yes) const;
#endif
[[nodiscard]] String to_lowercase() const;
[[nodiscard]] String to_uppercase() const;