C++ Logo


Advanced search

[SG7] user-defined attribute metadata?

From: Michael Nicolella <mike.nicolella_at_[hidden]>
Date: Wed, 31 Jul 2019 01:07:43 -0700
Hi all,

Starting to browse over the reflection proposals but I didn't notice
anything talking about custom user attributes on members?

In gamedev, we often define structures that will be reflected to a GUI for
game designers and artists to use. We use this to inform the users and the
tooling. Below is a trivial example of how we might want to use custom
metadata to mark up a C++ structure.

Are there any proposals related to reflection that provide a way to have
user defined attributes like this, and tie it in to reflection so that this
metadata can be collected?

struct Description
    Description(const char* text):text(text){}
    const char* text;

struct IntRange
    IntRange(int min, int max):min(min),max(max){}
    int min;
    int max;

[[Description("describes a rectangle")]]
struct Rect
    [[IntRange(0, 100)]]
    [[Description("specifies the rect width")]]
    int width;

    [[IntRange(0, 100)]]
    [[Description("specifies the rect height")]]
    int height;

Received on 2019-07-31 03:09:59