StringTable.h 694 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DistinctNumeric.h>
  8. #include <AK/String.h>
  9. #include <AK/Vector.h>
  10. namespace JS::Bytecode {
  11. TYPEDEF_DISTINCT_NUMERIC_GENERAL(size_t, false, true, false, false, false, false, StringTableIndex);
  12. class StringTable {
  13. AK_MAKE_NONMOVABLE(StringTable);
  14. AK_MAKE_NONCOPYABLE(StringTable);
  15. public:
  16. StringTable() = default;
  17. StringTableIndex insert(StringView string);
  18. String const& get(StringTableIndex) const;
  19. void dump() const;
  20. bool is_empty() const { return m_strings.is_empty(); }
  21. private:
  22. Vector<String> m_strings;
  23. };
  24. }