wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Add metadata to types, unions and enums. #97

Open wc-duck opened 6 years ago

wc-duck commented 6 years ago

You define your metadata as dl-types and then the metadata of a type as

"metadata" : [ { "range" : { "min" : 1, "max" : 5 } ]

I.e. "range" here would be a dl-type as any other and parsed as such. The instance is then stored in the typelib and accessed via something as:

unsigned int meta_cnt = dl_get_metadata_cnt(ctx, typeid);
for(; i < meta_cnt; ++i)
{
    dl_typeid_t meta_type;
    void* meta_inst = dl_get_metadata(ctx, typeid, i, &out_type_id);

    switch (meta_type)
    {
        /// cast and use!
    }
}
Tisten commented 1 year ago

Just so you don't happen to start to implement this over the weekend, I will finish this on Monday and create a PR

wc-duck commented 1 year ago

That will not happen... the entire weekend is booked by me and my better half :)

Tisten commented 1 year ago

I hope this can be marked as fixed when the PR is approved.

Tisten commented 1 year ago

Feel free to close this now