StringIterator.h 761 B

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