Engine → Core → string_id.h
string_id
| Type | Class |
| Namespace | conjure::core |
| Include File Path | engine/include/conjure/core/string_id.h |
| Source File Path | engine/src/core/strings/string_id.cpp |
| API ↗ | Containers, Strings and identifiers |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | constexpr string_id() noexcept = default; | The null id: hash 0, no name. |
| public | constexpr explicit string_id(
std::string_view name); | Hashes name. When constant-evaluated (constexpr variables, static or namespace- scope ids with a literal name) the id is only hashed; otherwise the name is also interned so view()/c_str() can resolve it later. See the header comment for the exact rules; use intern() where interning must be guaranteed. |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mHash | u64 | 0 |
Functions
Public
c_str
c_str[[nodiscard]] const char *c_str() const noexcept;The interned name as a null-terminated string, or "" when unknown.
from_hash
from_hashWraps an already computed hash (deserialisation, C# interop). Nothing is interned.
hash
hash[[nodiscard]] constexpr u64 hash() const noexcept;The 64-bit FNV-1a hash of the name. 0 for the null id.
intern
intern[[nodiscard]] static string_id intern(
std::string_view name);Hashes and interns name in every context, including for ids that were first created in constant expressions. Never constexpr, so it is the right initialiser for static and namespace-scope ids whose names must be visible to tools.
interned_count
interned_count[[nodiscard]] static usize interned_count() noexcept;Number of names currently interned in the process-wide table.
is_null
is_null[[nodiscard]] constexpr bool is_null() const noexcept;True for the default-constructed id (hash 0).
null
null[[nodiscard]] static constexpr string_id null() noexcept;The null id. Equivalent to string_id().
to_string
to_string[[nodiscard]] std::string to_string() const;The interned name when known, otherwise "#" followed by the 16-digit hex hash.
view
view[[nodiscard]] std::string_view view() const noexcept;The interned name, or an empty view when this id was never interned.
Operator Overloads
Public
operator<=>
operator<=>[[nodiscard]] constexpr auto operator<=>(
const string_id &) const noexcept = default;