cubos::core::reflection::DictionaryTrait class final

Exposes dictionary-like functionality of a type.

Public types

struct Entry
Output structure for the iterator.
using Length = std::size_t(*)(const void*instance)
Function pointer to get the length of a dictionary instance.
using Begin = void*(*)(uintptr_t instance, bool writeable)
Function pointer to get an iterator to the first key-value pair of a dictionary instance.
using Find = void*(*)(uintptr_t instance, const void*key, bool writeable)
Function pointer to get an iterator to a value in an dictionary instance.
using Advance = bool(*)(uintptr_t instance, void*iterator, bool writeable)
Function pointer to advance an iterator.
using Stop = void(*)(void*iterator, bool writeable)
Function pointer to destroy an iterator instance.
using Key = const void*(*)(const void*iterator, bool writeable)
Function pointer to get the address of the key pointed to by an iterator.
using Value = uintptr_t(*)(const void*iterator, bool writeable)
Function pointer to get the address of the value pointed to by an iterator.
using InsertDefault = void(*)(void*instance, const void*key)
Function pointer to insert a default value into a dictionary instance.
using InsertCopy = void(*)(void*instance, const void*key, const void*value)
Function pointer to insert a copy of the given value into a dictionary instance.
using InsertMove = void(*)(void*instance, const void*key, void*value)
Function pointer to move the given value into a dictionary instance.
using Erase = void(*)(void*instance, const void*iterator)
Function pointer to remove a key-value pair of a dictionary instance.

Constructors, destructors, conversion operators

DictionaryTrait(const Type& keyType, const Type& valueType, Length length, Begin begin, Find find, Advance advance, Stop stop, Key key, Value value)
Constructs.
View(const DictionaryTrait& trait, void* instance)
Constructs.
ConstView(const DictionaryTrait& trait, const void* instance)
Constructs.
Iterator(const Iterator& other)
Copy constructs.
Iterator(Iterator&& other) noexcept
Move constructs.
Iterator(const Iterator& other)
Copy constructs.
Iterator(Iterator&& other) noexcept
Move constructs.

Public functions

void setInsertDefault(InsertDefault insertDefault)
Sets the default-construct insert operation of the trait.
void setInsertCopy(InsertCopy insertCopy)
Sets the copy-construct insert operation of the trait.
void setInsertMove(InsertMove insertMove)
Sets the move-construct insert operation of the trait.
void setErase(Erase erase)
Sets the erase operation of the trait.
auto hasInsertDefault() const -> bool
Checks if default-construct insert is supported.
auto hasInsertCopy() const -> bool
Checks if copy-construct insert is supported.
auto hasInsertMove() const -> bool
Checks if move-construct insert is supported.
auto hasErase() const -> bool
Checks if erase is supported.
auto keyType() const -> const Type&
Returns the key type of the dictionary.
auto valueType() const -> const Type&
Returns the value type of the dictionary.
auto view(void* instance) const -> View
Returns a view of the given dictionary instance.
auto view(const void* instance) const -> ConstView
Returns a view of the given dictionary instance.
auto length() const -> std::size_t
Returns the length of the dictionary.
auto begin() const -> Iterator
Returns an iterator to the first entry.
auto end() const -> Iterator
Returns an iterator to the entry after the last entry.
auto find(const void* key) const -> Iterator
Returns an iterator to the entry with the given key.
void insertDefault(const void* key) const
Inserts a default-constructed value with the given key.
void insertCopy(const void* key, const void* value) const
Inserts a copy-constructed value with the given key.
void insertMove(const void* key, void* value) const
Inserts a move-constructed value with the given key.
void erase(Iterator& iterator) const
Removes an entry.
void erase(Iterator&& iterator) const
Removes an entry.
void clear() const
Clears the dictionary.
auto length() const -> std::size_t
Returns the length of the dictionary.
auto begin() const -> Iterator
Returns an iterator to the first entry.
auto end() const -> Iterator
Returns an iterator to the entry after the last entry.
auto find(const void* key) const -> Iterator
Returns an iterator to the entry with the given key.
auto operator=(const Iterator& other) -> Iterator&
Assigns an iterator.
auto operator==(const Iterator& other) const -> bool
Compares two iterators.
auto operator!=(const Iterator&) const -> bool
Compares two iterators.
auto operator*() const -> const Entry&
Accesses the entry referenced by this iterator.
auto operator->() const -> const Entry*
Accesses the entry referenced by this iterator.
auto operator++() -> Iterator&
Advances the iterator.
auto operator=(const Iterator& other) -> Iterator&
Assigns an iterator.
auto operator==(const Iterator& other) const -> bool
Compares two iterators.
auto operator!=(const Iterator&) const -> bool
Compares two iterators.
auto operator*() const -> const Entry&
Accesses the entry referenced by this iterator.
auto operator->() const -> const Entry*
Accesses the entry referenced by this iterator.
auto operator++() -> Iterator&
Advances the iterator.

Function documentation

cubos::core::reflection::DictionaryTrait::DictionaryTrait(const Type& keyType, const Type& valueType, Length length, Begin begin, Find find, Advance advance, Stop stop, Key key, Value value)

Constructs.

Parameters
keyType Key type of the dictionary.
valueType Value type of the dictionary.
length Function used to get the length of a dictionary.
begin Function used to get an iterator to the first key-value pair of a
find Function used to find a key-value pair in a dictionary.
advance Function used to advance an iterator.
stop Function used to destroy an iterator.
key Function used to get the address of the key pointed to by an iterator.
value Function used to get the address of the value pointed to by an iterator.

cubos::core::reflection::DictionaryTrait::View(const DictionaryTrait& trait, void* instance)

Constructs.

Parameters
trait Trait.
instance Instance.

cubos::core::reflection::DictionaryTrait::ConstView(const DictionaryTrait& trait, const void* instance)

Constructs.

Parameters
trait Trait.
instance Instance.

cubos::core::reflection::DictionaryTrait::Iterator(const Iterator& other)

Copy constructs.

Parameters
other Other iterator.

cubos::core::reflection::DictionaryTrait::Iterator(Iterator&& other) noexcept

Move constructs.

Parameters
other Other iterator.

cubos::core::reflection::DictionaryTrait::Iterator(const Iterator& other)

Copy constructs.

Parameters
other Other iterator.

cubos::core::reflection::DictionaryTrait::Iterator(Iterator&& other) noexcept

Move constructs.

Parameters
other Other iterator.

void cubos::core::reflection::DictionaryTrait::setInsertDefault(InsertDefault insertDefault)

Sets the default-construct insert operation of the trait.

Parameters
insertDefault Function pointer.

void cubos::core::reflection::DictionaryTrait::setInsertCopy(InsertCopy insertCopy)

Sets the copy-construct insert operation of the trait.

Parameters
insertCopy Function pointer.

void cubos::core::reflection::DictionaryTrait::setInsertMove(InsertMove insertMove)

Sets the move-construct insert operation of the trait.

Parameters
insertMove Function pointer.

void cubos::core::reflection::DictionaryTrait::setErase(Erase erase)

Sets the erase operation of the trait.

Parameters
erase Function pointer.

bool cubos::core::reflection::DictionaryTrait::hasInsertDefault() const

Checks if default-construct insert is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::DictionaryTrait::hasInsertCopy() const

Checks if copy-construct insert is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::DictionaryTrait::hasInsertMove() const

Checks if move-construct insert is supported.

Returns Whether the operation is supported.

bool cubos::core::reflection::DictionaryTrait::hasErase() const

Checks if erase is supported.

Returns Whether the operation is supported.

const Type& cubos::core::reflection::DictionaryTrait::keyType() const

Returns the key type of the dictionary.

Returns Key type.

const Type& cubos::core::reflection::DictionaryTrait::valueType() const

Returns the value type of the dictionary.

Returns Value type.

View cubos::core::reflection::DictionaryTrait::view(void* instance) const

Returns a view of the given dictionary instance.

Parameters
instance Dictionary instance.
Returns Dictionary view.

ConstView cubos::core::reflection::DictionaryTrait::view(const void* instance) const

Returns a view of the given dictionary instance.

Parameters
instance Dictionary instance.
Returns Dictionary view.

std::size_t cubos::core::reflection::DictionaryTrait::length() const

Returns the length of the dictionary.

Returns Dictionary length.

Iterator cubos::core::reflection::DictionaryTrait::begin() const

Returns an iterator to the first entry.

Returns Iterator.

Iterator cubos::core::reflection::DictionaryTrait::end() const

Returns an iterator to the entry after the last entry.

Returns Iterator.

Iterator cubos::core::reflection::DictionaryTrait::find(const void* key) const

Returns an iterator to the entry with the given key.

Parameters
key Key.
Returns Iterator.

void cubos::core::reflection::DictionaryTrait::insertDefault(const void* key) const

Inserts a default-constructed value with the given key.

Parameters
key Key.

void cubos::core::reflection::DictionaryTrait::insertCopy(const void* key, const void* value) const

Inserts a copy-constructed value with the given key.

Parameters
key Key.
value Value.

void cubos::core::reflection::DictionaryTrait::insertMove(const void* key, void* value) const

Inserts a move-constructed value with the given key.

Parameters
key Key.
value Value.

void cubos::core::reflection::DictionaryTrait::erase(Iterator& iterator) const

Removes an entry.

Parameters
iterator Iterator.

void cubos::core::reflection::DictionaryTrait::erase(Iterator&& iterator) const

Removes an entry.

Parameters
iterator Iterator.

void cubos::core::reflection::DictionaryTrait::clear() const

Clears the dictionary.

std::size_t cubos::core::reflection::DictionaryTrait::length() const

Returns the length of the dictionary.

Returns Dictionary length.

Iterator cubos::core::reflection::DictionaryTrait::begin() const

Returns an iterator to the first entry.

Returns Iterator.

Iterator cubos::core::reflection::DictionaryTrait::end() const

Returns an iterator to the entry after the last entry.

Returns Iterator.

Iterator cubos::core::reflection::DictionaryTrait::find(const void* key) const

Returns an iterator to the entry with the given key.

Parameters
key Key.
Returns Iterator.

Iterator& cubos::core::reflection::DictionaryTrait::operator=(const Iterator& other)

Assigns an iterator.

Parameters
other Other iterator.
Returns Iterator.

bool cubos::core::reflection::DictionaryTrait::operator==(const Iterator& other) const

Compares two iterators.

Parameters
other Other iterator.
Returns Whether the iterators point to the same entry.

bool cubos::core::reflection::DictionaryTrait::operator!=(const Iterator&) const

Compares two iterators.

Returns Whether the iterators point to different entries.

const Entry& cubos::core::reflection::DictionaryTrait::operator*() const

Accesses the entry referenced by this iterator.

Returns Entry.

const Entry* cubos::core::reflection::DictionaryTrait::operator->() const

Accesses the entry referenced by this iterator.

Returns Entry.

Iterator& cubos::core::reflection::DictionaryTrait::operator++()

Advances the iterator.

Returns Reference to this.

Iterator& cubos::core::reflection::DictionaryTrait::operator=(const Iterator& other)

Assigns an iterator.

Parameters
other Other iterator.
Returns Iterator.

bool cubos::core::reflection::DictionaryTrait::operator==(const Iterator& other) const

Compares two iterators.

Parameters
other Other iterator.
Returns Whether the iterators point to the same entry.

bool cubos::core::reflection::DictionaryTrait::operator!=(const Iterator&) const

Compares two iterators.

Returns Whether the iterators point to different entries.

const Entry& cubos::core::reflection::DictionaryTrait::operator*() const

Accesses the entry referenced by this iterator.

Returns Entry.

const Entry* cubos::core::reflection::DictionaryTrait::operator->() const

Accesses the entry referenced by this iterator.

Returns Entry.

Iterator& cubos::core::reflection::DictionaryTrait::operator++()

Advances the iterator.

Returns Reference to this.