cubos::core::reflection::FieldsTrait class

Describes the fields of a reflected type.

Public types

template<typename O, typename F>
class AddressOfImpl
Implementation of AddressOf for a pointer to member.
struct Output
Output structure for the iterator.

Public static functions

static auto end() -> Iterator
Gets an iterator which represents the end of the field list of a type.

Constructors, destructors, conversion operators

FieldsTrait() defaulted
Constructs.
FieldsTrait(FieldsTrait&& other) noexcept
Move constructs.
Field(const Type& type, std::string name, AddressOf* addressOf)
Constructs using the given address of getter. Will be deleted using delete and thus must be allocated using new.
Iterator(const Field* field)
Constructs.
Iterator(const Iterator& iterator) defaulted
Copy constructs.
View(const FieldsTrait& trait, void* instance)
Constructs.
ConstView(const FieldsTrait& trait, const void* instance)
Constructs.
Iterator(const View& view, const Field* field)
Constructs.
Iterator(const Iterator& other) defaulted
Copy constructs.
Iterator(const ConstView& view, const Field* field)
Constructs.
Iterator(const Iterator& other) defaulted
Copy constructs.

Public functions

void addField(const Type& type, std::string name, AddressOf* addressOf)
Adds a field to the type. The getter will be deleted using delete and thus must be allocated using new.
auto withField(const Type& type, std::string name, AddressOf* addressOf) && -> FieldsTrait&&
Adds a field to the type. The getter will be deleted using delete and thus must be allocated using new.
template<typename O, typename F>
void addField(std::string name, F O::* pointer)
Adds a field to the type.
template<typename O, typename F>
auto withField(std::string name, F O::* pointer) && -> FieldsTrait&&
Adds a field to the type.
auto field(const std::string& name) const -> const Field*
Gets the field with the given name.
auto begin() const -> Iterator
Gets an iterator to the first field of the type.
auto size() const -> std::size_t
Returns how many fields there are in the trait.
auto view(void* instance) const -> View
Returns a view of the given object instance.
auto view(const void* instance) const -> ConstView
Returns a view of the given object instance.
auto get(const void* instance) const -> uintptr_t pure virtual
Gets the address of the field on a given instance.
auto type() const -> const Type&
Returns the type of the field.
auto name() const -> const std::string&
Returns the name of the field.
auto next() const -> const Field*
Returns the next field in the linked list.
auto operator*() const -> const Field&
Accesses the field referenced by this iterator.
auto operator->() const -> const Field*
Accesses the field referenced by this iterator.
auto operator++() -> Iterator&
Advances the iterator.
auto get(const Field& field) const -> void*
Gets a pointer to the value of the given field on the object.
auto get(const std::string& name) const -> void*
Gets a pointer to the value of the field with the given name on the object.
auto begin() const -> Iterator
Gets an iterator to the first field.
auto end() const -> Iterator
Gets an iterator to the field after the last field.
auto get(const Field& field) const -> const void*
Gets a pointer to the value of the given field on the object.
auto get(const std::string& name) const -> const void*
Gets a pointer to the value of the field with the given name on the object.
auto begin() const -> Iterator
Gets an iterator to the first field.
auto end() const -> Iterator
Gets an iterator to the field after the last field.
auto operator==(const Iterator& other) const -> bool
Compares two iterators.
auto operator!=(const Iterator&) const -> bool
Compares two iterators.
auto operator*() const -> const Output&
Accesses the field referenced by this iterator.
auto operator->() const -> const Output*
Accesses the field referenced by this iterator.
auto operator++() -> Iterator&
Advances the iterator.
auto operator==(const Iterator& other) const -> bool
Compares two iterators.
auto operator!=(const Iterator&) const -> bool
Compares two iterators.
auto operator*() const -> const Output&
Accesses the field referenced by this iterator.
auto operator->() const -> const Output*
Accesses the field referenced by this iterator.
auto operator++() -> Iterator&
Advances the iterator.

Function documentation

static Iterator cubos::core::reflection::FieldsTrait::end()

Gets an iterator which represents the end of the field list of a type.

Returns Iterator.

cubos::core::reflection::FieldsTrait::FieldsTrait(FieldsTrait&& other) noexcept

Move constructs.

Parameters
other Other trait.

cubos::core::reflection::FieldsTrait::Field(const Type& type, std::string name, AddressOf* addressOf)

Constructs using the given address of getter. Will be deleted using delete and thus must be allocated using new.

Parameters
type Field type.
name Field name.
addressOf Getter for the address of the field on a given instance.

cubos::core::reflection::FieldsTrait::Iterator(const Field* field)

Constructs.

Parameters
field Field.

cubos::core::reflection::FieldsTrait::Iterator(const Iterator& iterator) defaulted

Copy constructs.

Parameters
iterator Iterator.

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

Constructs.

Parameters
trait Trait.
instance Instance.

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

Constructs.

Parameters
trait Trait.
instance Instance.

cubos::core::reflection::FieldsTrait::Iterator(const View& view, const Field* field)

Constructs.

Parameters
view View.
field Field.

cubos::core::reflection::FieldsTrait::Iterator(const Iterator& other) defaulted

Copy constructs.

Parameters
other Other iterator.

cubos::core::reflection::FieldsTrait::Iterator(const ConstView& view, const Field* field)

Constructs.

Parameters
view View.
field Field.

cubos::core::reflection::FieldsTrait::Iterator(const Iterator& other) defaulted

Copy constructs.

Parameters
other Other iterator.

void cubos::core::reflection::FieldsTrait::addField(const Type& type, std::string name, AddressOf* addressOf)

Adds a field to the type. The getter will be deleted using delete and thus must be allocated using new.

Parameters
type Field type.
name Field name.
addressOf Getter for the address of the field on a given instance.

FieldsTrait&& cubos::core::reflection::FieldsTrait::withField(const Type& type, std::string name, AddressOf* addressOf) &&

Adds a field to the type. The getter will be deleted using delete and thus must be allocated using new.

Parameters
type Field type.
name Field name.
addressOf Getter for the address of the field on a given instance.
Returns Trait.

template<typename O, typename F>
void cubos::core::reflection::FieldsTrait::addField(std::string name, F O::* pointer)

Adds a field to the type.

Template parameters
O Object type.
F Field type.
Parameters
name Field name.
pointer Field pointer.

template<typename O, typename F>
FieldsTrait&& cubos::core::reflection::FieldsTrait::withField(std::string name, F O::* pointer) &&

Adds a field to the type.

Template parameters
O Object type.
F Field type.
Parameters
name Field name.
pointer Field pointer.
Returns Trait.

const Field* cubos::core::reflection::FieldsTrait::field(const std::string& name) const

Gets the field with the given name.

Parameters
name Field name.
Returns Field with the given name, or null if no such field exists.

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

Gets an iterator to the first field of the type.

Returns Iterator.

std::size_t cubos::core::reflection::FieldsTrait::size() const

Returns how many fields there are in the trait.

Returns Field count.

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

Returns a view of the given object instance.

Parameters
instance Object instance.
Returns Object view.

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

Returns a view of the given object instance.

Parameters
instance Object instance.
Returns Object view.

uintptr_t cubos::core::reflection::FieldsTrait::get(const void* instance) const pure virtual

Gets the address of the field on a given instance.

Parameters
instance Pointer to the instance.
Returns Address of the field on the given instance.

const Type& cubos::core::reflection::FieldsTrait::type() const

Returns the type of the field.

Returns Type of the field.

const std::string& cubos::core::reflection::FieldsTrait::name() const

Returns the name of the field.

Returns Name of the field.

const Field* cubos::core::reflection::FieldsTrait::next() const

Returns the next field in the linked list.

Returns Pointer to next field or null if this is the last field.

const Field& cubos::core::reflection::FieldsTrait::operator*() const

Accesses the field referenced by this iterator.

Returns Reference to the field.

const Field* cubos::core::reflection::FieldsTrait::operator->() const

Accesses the field referenced by this iterator.

Returns Pointer to the field.

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

Advances the iterator.

Returns Reference to this.

void* cubos::core::reflection::FieldsTrait::get(const Field& field) const

Gets a pointer to the value of the given field on the object.

Parameters
field Field.
Returns Field value.

void* cubos::core::reflection::FieldsTrait::get(const std::string& name) const

Gets a pointer to the value of the field with the given name on the object.

Parameters
name Field name.
Returns Field value.

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

Gets an iterator to the first field.

Returns Iterator.

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

Gets an iterator to the field after the last field.

Returns Iterator.

const void* cubos::core::reflection::FieldsTrait::get(const Field& field) const

Gets a pointer to the value of the given field on the object.

Parameters
field Field.
Returns Field value.

const void* cubos::core::reflection::FieldsTrait::get(const std::string& name) const

Gets a pointer to the value of the field with the given name on the object.

Parameters
name Field name.
Returns Field value.

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

Gets an iterator to the first field.

Returns Iterator.

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

Gets an iterator to the field after the last field.

Returns Iterator.

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

Compares two iterators.

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

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

Compares two iterators.

Returns Whether the iterators point to different fields.

const Output& cubos::core::reflection::FieldsTrait::operator*() const

Accesses the field referenced by this iterator.

Returns Output.

const Output* cubos::core::reflection::FieldsTrait::operator->() const

Accesses the field referenced by this iterator.

Returns Output.

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

Advances the iterator.

Returns Reference to this.

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

Compares two iterators.

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

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

Compares two iterators.

Returns Whether the iterators point to different fields.

const Output& cubos::core::reflection::FieldsTrait::operator*() const

Accesses the field referenced by this iterator.

Returns Output.

const Output* cubos::core::reflection::FieldsTrait::operator->() const

Accesses the field referenced by this iterator.

Returns Output.

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

Advances the iterator.

Returns Reference to this.