Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Michael Van Canneyt via fpc-pascal
On Thu, 22 Dec 2022, Andrew Haines via fpc-pascal wrote: Hi what I want to do is similar to this question here: https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/ I am going to create multiple type helpers for enums and I would like to look up the

Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal
So, I came up with a solution using Custom Attributes. I can declare this: [TEnumAttr('YES', 'NO', 'COULD_BE')]   TMyEnum = (meYes, meNo, meCouldBe); and at runtime look for the TEnumAttr attribute and use that. TEnumAttr = class(TCustomAttribute)   protected     FValues: TStringArray;    

[fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal
Hi what I want to do is similar to this question here: https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/ I am going to create multiple type helpers for enums and I would like to look up the helper and use common methods AsString AsOrdinal to get/set the