/src/serenity/Userland/Libraries/LibJS/Runtime/StringIterator.h
Line | Count | Source |
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 | | |
13 | | namespace JS { |
14 | | |
15 | | class StringIterator final : public Object { |
16 | | JS_OBJECT(StringIterator, Object); |
17 | | JS_DECLARE_ALLOCATOR(StringIterator); |
18 | | |
19 | | public: |
20 | | static NonnullGCPtr<StringIterator> create(Realm&, String string); |
21 | | |
22 | 0 | virtual ~StringIterator() override = default; |
23 | | |
24 | 0 | Utf8CodePointIterator& iterator() { return m_iterator; } |
25 | 0 | bool done() const { return m_done; } |
26 | | |
27 | | private: |
28 | | explicit StringIterator(String string, Object& prototype); |
29 | | |
30 | | friend class StringIteratorPrototype; |
31 | | |
32 | | String m_string; |
33 | | Utf8CodePointIterator m_iterator; |
34 | | bool m_done { false }; |
35 | | }; |
36 | | |
37 | | } |