ludus::content::string_dictionary::StringDictionaryView¶
Ludus Wiki · API overview · Browse API
Class
Validated, read-only view of a LUSTR dictionary held in caller-owned bytes.
The view copies no spelling bytes. Whoever owns the dictionary bytes (for example a content snapshot or a read-only mapping) must keep them alive and unmodified for as long as the view, or any spelling returned from it, is used. Views are trivially copyable and need no synchronization for concurrent reads. A default-constructed view is empty and every lookup reports InvalidHandle.
#include <ludus/content/string_dictionary/string_dictionary.h>
class ludus::content::string_dictionary::StringDictionaryView final
Methods¶
StringDictionaryView¶
constexpr ludus::content::string_dictionary::StringDictionaryView::StringDictionaryView() noexcept=default
Constructs an empty view.
IsValid¶
LUDUS_INLINE bool ludus::content::string_dictionary::StringDictionaryView::IsValid() const noexcept
Whether the view holds a validated dictionary.
GetEntryCount¶
LUDUS_INLINE uint32 ludus::content::string_dictionary::StringDictionaryView::GetEntryCount() const noexcept
Number of entries including the empty entry at index zero; zero when empty.
Related types: uint32
GetBytePolicy¶
LUDUS_INLINE uint32 ludus::content::string_dictionary::StringDictionaryView::GetBytePolicy() const noexcept
BYTE_POLICY_UTF8 or BYTE_POLICY_BYTES; zero when empty.
Related types: uint32
GetRevision¶
RevisionDigest ludus::content::string_dictionary::StringDictionaryView::GetRevision() const noexcept
Copies the dictionary's revision digest.
Returns
The header digest, or all zero bytes for an empty view.
Related types: RevisionDigest
TryResolve¶
StringDictionaryStatus ludus::content::string_dictionary::StringDictionaryView::TryResolve(foundation::StringIndex index, std::string_view &outSpelling) const noexcept
Resolves a directory index in constant time without allocating.
| Parameter | Description |
|---|---|
index |
Index from this dictionary; indices are not portable across revisions.
|
outSpelling |
Receives the counted spelling, borrowed from the dictionary bytes. The byte after it is a zero terminator. Unchanged on failure.
|
Returns
Ok, or InvalidHandle for an empty view or an out-of-range index.
Related types: StringDictionaryStatus · foundation::StringIndex
TryFind¶
StringDictionaryStatus ludus::content::string_dictionary::StringDictionaryView::TryFind(std::string_view spelling, foundation::StringIndex &outIndex) const noexcept
Finds the entry with exactly these bytes by binary search.
Comparison is exact unsigned byte order; nothing is normalized or case folded.
| Parameter | Description |
|---|---|
spelling |
Counted bytes to look up; the empty spelling finds index zero.
|
outIndex |
Receives the matching index. Unchanged on failure.
|
Returns
Ok, NotFound, or InvalidHandle for an empty view.
Related types: StringDictionaryStatus · foundation::StringIndex