StringIterator.h 714 B

12345678910111213141516171819202122232425262728293031323334
  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 StringIterator* create(GlobalObject&, String string);
  14. explicit StringIterator(String string, Object& prototype);
  15. virtual ~StringIterator() override;
  16. Utf8CodePointIterator& iterator() { return m_iterator; }
  17. bool done() const { return m_done; }
  18. private:
  19. friend class StringIteratorPrototype;
  20. String m_string;
  21. Utf8CodePointIterator m_iterator;
  22. bool m_done { false };
  23. };
  24. }