Serenity Operating System
1/*
2 * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/String.h>
10#include <AK/Utf8View.h>
11#include <LibJS/Runtime/Object.h>
12
13namespace JS {
14
15class StringIterator final : public Object {
16 JS_OBJECT(StringIterator, Object);
17
18public:
19 static NonnullGCPtr<StringIterator> create(Realm&, String string);
20
21 virtual ~StringIterator() override = default;
22
23 Utf8CodePointIterator& iterator() { return m_iterator; }
24 bool done() const { return m_done; }
25
26private:
27 explicit StringIterator(String string, Object& prototype);
28
29 friend class StringIteratorPrototype;
30
31 String m_string;
32 Utf8CodePointIterator m_iterator;
33 bool m_done { false };
34};
35
36}