AK: Add FlyString::starts_with_bytes and FlyString::ends_with_bytes

Mirroring the API for String
This commit is contained in:
Shannon Booth 2023-11-06 23:59:15 +13:00 committed by Andreas Kling
parent 1d8ec677a3
commit 8c8ea86729
Notes: sideshowbarker 2024-07-17 01:46:00 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -205,4 +205,14 @@ bool FlyString::equals_ignoring_ascii_case(StringView other) const
return StringUtils::equals_ignoring_ascii_case(bytes_as_string_view(), other);
}
bool FlyString::starts_with_bytes(StringView bytes, CaseSensitivity case_sensitivity) const
{
return bytes_as_string_view().starts_with(bytes, case_sensitivity);
}
bool FlyString::ends_with_bytes(StringView bytes, CaseSensitivity case_sensitivity) const
{
return bytes_as_string_view().ends_with(bytes, case_sensitivity);
}
}

View file

@ -69,6 +69,10 @@ public:
[[nodiscard]] bool equals_ignoring_ascii_case(FlyString const&) const;
[[nodiscard]] bool equals_ignoring_ascii_case(StringView) const;
[[nodiscard]] bool starts_with_bytes(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] bool ends_with_bytes(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
template<typename... Ts>
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts... strings) const
{