mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK: Implement Utf8CodepointIterator::peek(size_t)
This adds a peek method for Utf8CodepointIterator, which enables it to be used in some parsing cases where peeking is necessary. peek(0) is equivalent to operator*, expect that peek() does not contain any assertions and will just return an empty Optional<u32>. This also implements a test case for iterating UTF-8.
This commit is contained in:
parent
31f6ba0952
commit
14506e8f5e
Notes:
sideshowbarker
2024-07-18 17:04:53 +09:00
Author: https://github.com/MaxWipfli
Commit: 14506e8f5e
Pull-request: https://github.com/SerenityOS/serenity/pull/7478
Reviewed-by: https://github.com/awesomekling
3 changed files with 55 additions and 0 deletions
|
@ -25,6 +25,8 @@ public:
|
|||
bool operator!=(const Utf8CodepointIterator&) const;
|
||||
Utf8CodepointIterator& operator++();
|
||||
u32 operator*() const;
|
||||
// NOTE: This returns {} if the peek is at or past EOF.
|
||||
Optional<u32> peek(size_t offset = 0) const;
|
||||
|
||||
ssize_t operator-(const Utf8CodepointIterator& other) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue