#pragma once #include #include #include #include #include #include namespace sleela::alphabet { struct Utf8Result { std::vector codepoints; std::string error; explicit operator bool() const noexcept { return error.empty(); } }; Utf8Result decode_utf8(std::string_view bytes); std::optional encode_utf8(char32_t codepoint); std::optional codepoint_count_utf8(std::string_view bytes); std::optional parse_capacity_signature(std::string_view signature); class CharacterSet { public: explicit CharacterSet(std::size_t capacity); bool add(std::string symbol, std::string* error = nullptr); bool contains(std::string_view symbol) const; std::size_t size() const noexcept; std::size_t capacity() const noexcept; const std::vector& ordered_symbols() const noexcept; private: std::size_t capacity_; std::vector symbols_; }; } // namespace sleela::alphabet