Another serialization topic, reduced scope

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Sun Dec 15 00:43:05 UTC 2019


On Monday, 9 December 2019 at 03:21:47 UTC, Jesse Phillips wrote:
> On Sunday, 8 December 2019 at 22:00:53 UTC, Steven 
> Schveighoffer wrote:
>
>> So, the conclusion I came to (and actually, I use), is that I 
>> need to tag my members with BOTH, and have some way to 
>> distinguish them. That is, vibe.data.serialization.optional is 
>> a DIFFERENT attribute than db.DB.optional. And in my case, I 
>> use a DB struct, so all my attributes look like @(DB.optional) 
>> or @(DB.name!"class")
>
> I figured this would be likely. I took a look and it would be 
> possible to specify a template argument to the attribute, the 
> libraries could supply a type, we could supply some generic 
> ones (DB, Web, Disk, Unspecified)
>
> I'll watch the video.

I took some more time to expand on the idea. While I didn't get 
my custom getUDA to work perfectly, it looks promising.

https://github.com/JesseKPhillips/DIPs/blob/serialize/attribute/DIPs/1NNN-jkp/serialattr.d

Basically the implementation will provide an attribute which 
takes an attribute to match on.

@SerializerDB!DB
struct Example {
     @Ignore!DB

The standard library will need to help search these attributes.


More information about the Digitalmars-d mailing list