1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:58:11 +00:00

AK: Generalize AK::String::to_int() for more types

This commit is contained in:
Sahan Fernando 2020-12-11 00:17:30 +11:00 committed by Andreas Kling
parent 39364bdda4
commit 37df4bbd90
8 changed files with 93 additions and 24 deletions

View file

@ -59,9 +59,12 @@ struct MaskSpan {
namespace StringUtils {
bool matches(const StringView& str, const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive, Vector<MaskSpan>* match_spans = nullptr);
Optional<int> convert_to_int(const StringView&);
Optional<unsigned> convert_to_uint(const StringView&);
Optional<unsigned> convert_to_uint_from_hex(const StringView&);
template<typename T = int>
Optional<T> convert_to_int(const StringView&);
template<typename T = unsigned>
Optional<T> convert_to_uint(const StringView&);
template<typename T = unsigned>
Optional<T> convert_to_uint_from_hex(const StringView&);
bool equals_ignoring_case(const StringView&, const StringView&);
bool ends_with(const StringView& a, const StringView& b, CaseSensitivity);
bool starts_with(const StringView&, const StringView&, CaseSensitivity);