Toast Engine
Loading...
Searching...
No Matches
toast::FieldInfo Struct Reference

Runtime descriptor for one reflected field. More...

#include <reflect.hpp>

Public Types

using FieldGetterPtr = std::any (*)(void*)
using FieldSetterPtr = void (*)(void*, std::any)

Public Member Functions

auto attributeMap () const -> const nlohmann::json *
 Returns the generated attribute objectpr.
auto groupName () const -> std::string
 Returns the value of the "Group" annotation, or an empty string if not present.
auto hasAttribute (std::string_view attr_name) const -> bool
 Checks whether a JSON annotation key is present on this field.
auto getAttribute (std::string_view attr_name) const -> std::string
 Returns the first string value of a JSON annotation.

Public Attributes

std::string_view name
std::string_view type
FieldType value_type
nlohmann::json attributes
bool is_array = false
FieldGetterPtr get
FieldSetterPtr set

Detailed Description

Runtime descriptor for one reflected field.

Holds type metadata, JSON attributes parsed from the header annotation (e.g. Group, Name), and a type-erased getter/setter pair that works without knowing the concrete Node subtype.

Note
The getter returns std::any; the setter silently does nothing on a type mismatch

Member Function Documentation

◆ getAttribute()

auto toast::FieldInfo::getAttribute ( std::string_view attr_name) const -> std::string
inlinenodiscard

Returns the first string value of a JSON annotation.

Parameters
attr_nameThe annotation key to look up
Returns
The first string element, or an empty string if the key is absent or has no elements
Here is the caller graph for this function:

◆ hasAttribute()

auto toast::FieldInfo::hasAttribute ( std::string_view attr_name) const -> bool
inlinenodiscard

Checks whether a JSON annotation key is present on this field.

Parameters
attr_nameThe annotation key, e.g. "Group" or "Name"
Returns
true if the attribute exists, regardless of its value

The documentation for this struct was generated from the following file: