mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
AK: Add DeprecatedStringCodePointIterator
This is a safe iterator over the underlying code points. It will be used in Jakt to assist in the migration away from DeprecatedString.
This commit is contained in:
parent
0f4bbfdfb7
commit
2dc657c77e
4 changed files with 33 additions and 0 deletions
|
@ -130,9 +130,32 @@ private:
|
|||
mutable bool m_have_length { false };
|
||||
};
|
||||
|
||||
class DeprecatedStringCodePointIterator {
|
||||
public:
|
||||
Optional<u32> next()
|
||||
{
|
||||
if (m_it.done())
|
||||
return {};
|
||||
auto value = *m_it;
|
||||
++m_it;
|
||||
return value;
|
||||
}
|
||||
|
||||
DeprecatedStringCodePointIterator(DeprecatedString string)
|
||||
: m_string(move(string))
|
||||
, m_it(Utf8View(m_string).begin())
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
DeprecatedString m_string;
|
||||
Utf8CodePointIterator m_it;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::DeprecatedStringCodePointIterator;
|
||||
using AK::Utf8CodePointIterator;
|
||||
using AK::Utf8View;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue