mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:18:12 +00:00
AK: Add two starts_with{bytes,}() APIs to String
This commit is contained in:
parent
3a5802540e
commit
79e4027480
2 changed files with 13 additions and 0 deletions
|
@ -491,6 +491,16 @@ bool String::contains(char needle, CaseSensitivity case_sensitivity) const
|
||||||
return contains(StringView { &needle, 1 }, case_sensitivity);
|
return contains(StringView { &needle, 1 }, case_sensitivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool String::starts_with_bytes(StringView bytes) const
|
||||||
|
{
|
||||||
|
return bytes_as_string_view().starts_with(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool String::starts_with(u32 code_point) const
|
||||||
|
{
|
||||||
|
return bytes_as_string_view().starts_with(code_point);
|
||||||
|
}
|
||||||
|
|
||||||
bool String::is_short_string() const
|
bool String::is_short_string() const
|
||||||
{
|
{
|
||||||
return has_short_string_bit(reinterpret_cast<uintptr_t>(m_data));
|
return has_short_string_bit(reinterpret_cast<uintptr_t>(m_data));
|
||||||
|
|
|
@ -109,6 +109,9 @@ public:
|
||||||
// Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application.
|
// Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application.
|
||||||
ErrorOr<bool> equals_ignoring_case(String const&) const;
|
ErrorOr<bool> equals_ignoring_case(String const&) const;
|
||||||
|
|
||||||
|
bool starts_with(u32 code_point) const;
|
||||||
|
bool starts_with_bytes(StringView) const;
|
||||||
|
|
||||||
// Creates a substring with a deep copy of the specified data window.
|
// Creates a substring with a deep copy of the specified data window.
|
||||||
ErrorOr<String> substring_from_byte_offset(size_t start, size_t byte_count) const;
|
ErrorOr<String> substring_from_byte_offset(size_t start, size_t byte_count) const;
|
||||||
ErrorOr<String> substring_from_byte_offset(size_t start) const;
|
ErrorOr<String> substring_from_byte_offset(size_t start) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue