nxt::GlyphTable class

Unicode string interning table for terminal glyphs. Maps UTF-8 sequences to 32-bit glyph IDs. IDs 0-255 are reserved for single-byte ASCII (self-mapped). The empty string is used as a zero-advance continuation cell for multi-column glyphs.

Public types

using GlyphId = std::uint32_t

Public static variables

static GlyphId ASCII_MAX constexpr
ASCII values 0-255 are self-mapped.

Constructors, destructors, conversion operators

GlyphTable()
Initialize with pre-populated ASCII 0-255.
GlyphTable(const GlyphTable&) deleted
Rule of 5: GlyphTable is non-copyable, non-movable (owns mutex)
GlyphTable(GlyphTable&&) deleted
~GlyphTable() defaulted

Public functions

void clear()
Clear interned glyphs and restore the reserved ASCII entries.
auto get(GlyphId id) const →  std::optional<std::string_view> noexcept
auto get_span(GlyphId id) const →  std::optional<std::span<const char>> noexcept
auto intern(std::string_view bytes) →  GlyphId
auto operator=(const GlyphTable&) →  GlyphTable& deleted
auto operator=(GlyphTable&&) →  GlyphTable& deleted
auto operator[](GlyphId id) const →  std::string_view
auto size() const →  std::size_t noexcept
Number of interned glyphs.

Function documentation

std::optional<std::string_view> nxt::GlyphTable::get(GlyphId id) const noexcept

Get the UTF-8 bytes for a glyph ID as a string_view. Returns nullopt if ID is invalid.

std::optional<std::span<const char>> nxt::GlyphTable::get_span(GlyphId id) const noexcept

Get the UTF-8 bytes for a glyph ID as a span. Returns nullopt if ID is invalid.

GlyphId nxt::GlyphTable::intern(std::string_view bytes)

Exceptions
std::length_error if bytes.size() > 255

Intern a UTF-8 string, returning its GlyphId. Single-byte strings are fast-pathed to return the byte value.

std::string_view nxt::GlyphTable::operator[](GlyphId id) const

Exceptions
std::out_of_range if ID is invalid

Get the UTF-8 bytes for a glyph ID.