How to use annotation get key name?

Brian zoujiaqing at gmail.com
Tue Mar 27 15:38:48 UTC 2018


On Monday, 26 March 2018 at 08:50:31 UTC, Simen Kjærås wrote:
> On Monday, 26 March 2018 at 08:29:31 UTC, Brian wrote:
>> Rust sample code:
>>
>> #[cfg(name = "users")]
>>
>> PHP sample code:
>>
>> /*
>> @Table(name = "users")
>> */
>>
>> Java sample code:
>>
>> @Table(name = "users")
>>
>> How to use dlang get key name?
>
> If I understand your question correctly:
>
> struct Table {
>     string name;
> }
>
> struct Foo {
>     @Table("foo")
>     int n;
> }
>
> unittest {
>     import std.traits;
>
>     string name = getUDAs!(Foo.n, Table)[0].name;
> }
>
> --
>   Simen

Thanks.
but you don't understand my means, I want have keys with multiple 
indeterminate names.

Rust sample code:

#[cfg(name1 = "users", name2 = "users111")]

PHP sample code:

/*
@Table(name2 = "users", name2 = "users111")
*/

Java sample code:

@Table(name2 = "users111", name1 = "users")

How to use dlang get key name?

Don't have support get key function?

How to do?


More information about the Digitalmars-d-learn mailing list