mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:04:57 +00:00
AK: Prepare Utf32View for use within templated LibGfx contexts
Forward declare its iterator and add a peek() method analagous to Utf8CodePointIterator::peek().
This commit is contained in:
parent
0f20586346
commit
832e9b8302
3 changed files with 23 additions and 0 deletions
|
@ -9,6 +9,24 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
Optional<u32> Utf32CodePointIterator::peek(size_t offset) const
|
||||
{
|
||||
if (offset == 0) {
|
||||
if (this->done())
|
||||
return {};
|
||||
return this->operator*();
|
||||
}
|
||||
|
||||
auto new_iterator = *this;
|
||||
for (size_t index = 0; index < offset; ++index) {
|
||||
++new_iterator;
|
||||
if (new_iterator.done())
|
||||
return {};
|
||||
}
|
||||
|
||||
return *new_iterator;
|
||||
}
|
||||
|
||||
ErrorOr<void> Formatter<Utf32View>::format(FormatBuilder& builder, Utf32View const& string)
|
||||
{
|
||||
return builder.builder().try_append(string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue