TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24894 19
A standard set of metadata annotations

Hello,

I've been working for some years on https://github.com/celtera/avendish which allows to expose C++ classes through various creative environments, and as such assembled a small ontology of the various features, extensions, metadatas, ... that are often desirable to associate to data types and variables.

For instance, let's say we want to reflect this struct to automatically generate a control GUI from it, for instance like Unity gameobjects:

struct foo {
int applecount;
};


Avendish enables the user to do something like:

struct foo {
struct {
static consteval auto name() { return "Apple count"; }
struct range { int min = 0; int max = 100; int initial
value = 4; };
enum widget { spinbox };
int value;
} applecount;
};

With this "standardized" information, we can automatically generate an appropriate widget without having to store one additional byte in our actual data type: sizeof(foo) == sizeof(int).

Now, C++26 is there! And, finally, with annotations. Meaning that we're going to be able to do a much, much clearer:

struct foo {
[[=metadata::name{"Apple count"}]]
[[=metadata::range{0, 100}]]
[[=metadata::initial
value{4}]]
int applecount;
};

in practice, there's much more metadata out there. There's a million of incompatible systems defining all kinds of metadatas to match classes: it wouldn't be strange to have something like:

struct
[[=metadata::uuid{"27fc33a4-ff2f-490d-a7c2-a4f8c2eef35d"}]]
[[=metadata::author{"John Doe"}]]
[[=metadata::support
url{"https://example.com"}]]
foo {
[=metadata::name{"Apple count"}]
[=metadata::range{0, 100}]
[=metadata::initial_value{4}]
[=metadata::default_value{0}]
[=metadata::description{"Number of apples required in a harvest"}]
[=metadata::unit{apple_per_harvest{}}]
int applecount;
};

After study of a large number of these systems (did a systematic review of almost a hundred different "run-time" systems based on C or C++), what came up is that 90% of the metadatas in run-time reflection systems are actually exactly the same, just with different names. I started to define most of those related to multimedia systems through concepts, for instance in
https://github.com/celtera/avendish/blob/main/include/avnd/wrappers/metadatas.hpp and https://github.com/celtera/avendish/tree/main/include/avnd/concepts : what's an audio port, what's a texture, etc. The result is that as of today, it's possible to build from a single C++ class, types that are going to work in a dozen distinct creative environments (Max/MSP, PureData, Touchdesigner, Godot, ossia score...), since basically everyone is doing the same thing everywhere.

Since we now have a powerful, in-language way to define these static metadatas, I think it could be useful to have a more general, standardized library of such broadly-useful yet sometimes domain-specific concepts so that there is *one* consistent way for a C++ developer to say: "this field / class / <...> should be displayed as `Foo Bar 1.0` in a generated GUI", "this is a short description of this class", "this is the numeric range of this value", "this is the GUID of this class", etc.

The alternative is that everyone starts defining their own "property" / "metadata" / ... class ; someone who wants to make their type compatible (for instance across both a serialization library and a gui library) would inevitably end up into something such as:

struct
[[=cereal::uuid{"d2fac3f2-2c00-429b-b6bf-8728cfd29ff6"}]]
[[=winrt::GUID{d2fac3f2-2c00-429b-b6bf-8728cfd29ff6"}]]
foo {
[[=cereal::name{"Chocolate cakes"}]]
[[=qt::name{"Chocolate cakes"}]]
[[=gtkmm::name{"Chocolate cakes"}]]
[[=UE::name{"Chocolate cakes"}]]
int chocolate
cakes;
};


Is there interest in starting such a collaborative project?
GitHub GitHub - celtera/avendish: declarative polyamorous cross-system intermedia objects declarative polyamorous cross-system intermedia objects - celtera/avendish
More from @r_cpp
  1. Oct 6, 2026Tuning a Server for Benchmarking https://david.alvarezrosa.com/posts/tuning-a-server-for-b…
  2. Oct 6, 2026boost.org has been rebuilt: new profiles, badges, search, and library filtering The Boost…
  3. Oct 6, 2026When (Not) to Use alloca() https://voithos.io/articles/when-not-to-use-alloca/ https://red…
  4. Oct 6, 2026MSVC Build Tools Preview updates – September 2026 https://devblogs.microsoft.com/cppblog/m…
  5. Oct 6, 2026I built MrDocs, an open-source C++ reference doc generator on the Clang/LLVM AST. Looking…
  6. Oct 6, 2026WasmBolt — The LLVM Project in your browser https://anutosh21.github.io/WasmBolt/ https://…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →