Skip to content

File include/brisk/core/Reflection.hpp


ReflectionFlag enum

enum class ReflectionFlag : int

Enum representing flags for reflection metadata.

Default enumerator (ReflectionFlag::Default)

*/

SkipSerialization enumerator (ReflectionFlag::SkipSerialization)

*/

SkipPrinting enumerator (ReflectionFlag::SkipPrinting)

*/


operator+ function

constexpr std::underlying_type_t<ReflectionFlag>
operator+(ReflectionFlag x)

Converts a ReflectionFlag to its underlying integer type.
Param x The ReflectionFlag to convert.
Returns The underlying integer value of the flag.


operator&& function

constexpr bool operator&&(ReflectionFlag flags,
                          ReflectionFlag flag)

Checks if a flag is set in a combination of ReflectionFlag values.
Param flags The combination of flags.
Param flag The flag to check.
Returns true if the flag is set, false otherwise.


operator| function

constexpr ReflectionFlag operator|(ReflectionFlag x,
                                   ReflectionFlag y)

Combines two ReflectionFlag values using bitwise OR.
Param x The first flag.
Param y The second flag.
Returns The combined flag result.


ReflectionField class

template <typename Class_, typename FieldType_>
ReflectionField

Represents metadata for a reflected field in a class.
Template param Class_ The class type containing the field.
Template param FieldType_ The type of the field being reflected.

name variable (ReflectionField::name)

std::string_view name

*/

pointerToField variable (ReflectionField::pointerToField)

FieldType Class::*pointerToField

*/

flags variable (ReflectionField::flags)

ReflectionFlag flags = ReflectionFlag::Default

*/


<deduction guide for ReflectionField> function

template <size_t N, typename Class, typename FieldType>
ReflectionField(const char (&)[N], FieldType Class::*)
    ->ReflectionField<Class, FieldType>

Deduction guide for constructing ReflectionField without flags.
Template param N Size of the field name.
Template param Class The class type containing the field.
Template param FieldType The type of the field being reflected.


template <size_t N, typename Class, typename FieldType>
ReflectionField(const char (&)[N], FieldType Class::*,
                ReflectionFlag)
    ->ReflectionField<Class, FieldType>

Deduction guide for constructing ReflectionField with flags.
Template param N Size of the field name.
Template param Class The class type containing the field.
Template param FieldType The type of the field being reflected.


reflectionOf function

template <HasReflection T>
constexpr decltype(auto) reflectionOf()

Retrieves the reflection metadata of a type T.
Template param T The type with reflection metadata.
Returns The reflection metadata tuple.


reflectionOf variable

template <HasReflection T>
constexpr decltype(auto) reflectionOf

Retrieves the reflection metadata of an object of type T.
Template param T The type with reflection metadata.
Param obj The object whose reflection metadata is retrieved.
Returns The reflection metadata tuple.


forEachField function

template <HasReflection T, typename Fn>
constexpr void forEachField(Fn &&fn)

Iterates over each reflected field of a type T and applies a function to each field.
Template param T The type with reflection metadata.
Template param Fn The function type to apply to each field.
Param fn The function to apply to each reflected field.


enumSize variable

template <typename T, T Last = T::Last>
inline constexpr size_t enumSize =
    static_cast<size_t>(
        static_cast<std::underlying_type_t<T>>(Last)) +
    1

Returns the number of enum values based on the last enum value.
Template param T The enum type.
Template param Last The last enum value (default to T::Last).


lookupByEnum function

template <typename T, size_t N, typename E>
inline T lookupByEnum(T (&array)[N], E value, T fallback = T

Looks up a value in an array by its corresponding enum value.
Template param T The type of the array elements.
Template param N The size of the array.
Template param E The enum type.
Param array The array to search.
Param value The enum value to look up.
Param fallback The fallback value if the enum value is out of range.
Returns The corresponding value from the array or the fallback value if not found.


defaultNames variable

template <typename T>
inline constexpr std::nullptr_t defaultNames

Placeholder for default names of an enum type.
Template param T The enum type.


hasDefaultNames variable

template <typename T, typename = void>
inline constexpr bool hasDefaultNames = false

Checks if a type T has default names defined.
Template param T The enum type.


NameValuePair typedef

template <typename T>
NameValuePair = std::pair<std::string_view, T>

Represents a name-value pair for an enum.
Template param T The type of the value.


NameValuePair = std::pair<std::string_view, T>

Represents a name-value pair for an enum.
Template param T The type of the value.


defaultToString function

template <typename T,
          std::enable_if_t<hasDefaultNames<T>> * = nullptr>
constexpr std::string_view defaultToString(T value)

Converts an enum value to its string representation using default names.
Template param T The enum type.
Param value The enum value to convert.
Returns The corresponding string name of the enum value, or "(unknown)" if not found.


reflectFormat function

template <typename Char = char, typename T>
std::basic_string<Char> reflectFormat(const T &val)

Formats an object's fields using reflection and returns a formatted string.
Template param Char The character type for the output string (default is char).
Template param T The type of the object being reflected.
Param val The object to format.
Returns A formatted string representing the object's fields.


operator<< function

template <Brisk::HasReflection T>
std::ostream &operator<<(std::ostream &os, const T &val)

Overloads the << operator to output an object's fields using reflection.
Template param T The type of the object being reflected.
Param os The output stream.
Param val The object to output.
Returns The output stream with the reflected object.


formatter class

template <Brisk::HasReflection T, typename Char> formatter

Provides a custom formatter for types that have reflection metadata, for use with fmt::format.
Template param T The type of the object being reflected.
Template param Char The character type for the output format.


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/