On Monday, 13 June 2016 at 07:53:08 UTC, Jacob Carlborg wrote:
On 2016-06-13 09:49, Jacob Carlborg wrote:
For fields, used .tupleof, for other symbols, use a pointer.
Here's an example [1] of accessing a field using the name of
the field as a string. It will bypass private.
That module [1] contains some generic functionality for working
with fields which you would need for serialization. Or you can
use the whole serialization library directly [2] ;)
[1]
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L123
[2] https://github.com/jacob-carlborg/orange
There's also the IZ serializer. It's based on accessors (called
property descriptor) to read and write private or protected
fields. Actually it's never a good idea to directly access them.
Usually they're not hidden for anything (e.g the count of items
in a list, the setter update the list...)
pd:
https://github.com/BBasile/iz/blob/master/import/iz/properties.d
ser:
https://github.com/BBasile/iz/blob/master/import/iz/serializer.d