Jump to page: 1 2
Thread overview
Access private member
Jun 13, 2016
Pierre
Jun 13, 2016
Jacob Carlborg
Jun 13, 2016
Jacob Carlborg
Jun 13, 2016
Basile B.
Jun 13, 2016
Basile B.
Jun 13, 2016
Pierre
Jun 13, 2016
Jacob Carlborg
Jun 13, 2016
Basile B.
Jun 13, 2016
Basile B.
Jun 13, 2016
Basile B.
Jun 13, 2016
Jacob Carlborg
June 13, 2016
Hi,
I would like to know how can i access private member of class from outside ?
I think about serialization for instance, serializer must have access to protected attributes. How this is done ?
Thank you.
June 13, 2016
On 2016-06-13 09:43, Pierre wrote:
> Hi,
> I would like to know how can i access private member of class from
> outside ?
> I think about serialization for instance, serializer must have access to
> protected attributes. How this is done ?
> Thank you.

For fields, used .tupleof, for other symbols, use a pointer.

-- 
/Jacob Carlborg
June 13, 2016
On Monday, 13 June 2016 at 07:43:09 UTC, Pierre wrote:
> Hi,
> I would like to know how can i access private member of class from outside ?
> I think about serialization for instance, serializer must have access to protected attributes. How this is done ?
> Thank you.

You can perform the introspection in the class itself, e .g in the __ctor.


June 13, 2016
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

-- 
/Jacob Carlborg
June 13, 2016
Thank you i will try it.

June 13, 2016
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
June 13, 2016
On 2016-06-13 09:54, Pierre wrote:
> Thank you i will try it.

You don't need to involve the constructor. You can use .tupleof, as I mentioned [1] [2].

[1] http://forum.dlang.org/post/njlohq$1n99$1@digitalmars.com
[2] http://forum.dlang.org/post/njlop0$1ngk$1@digitalmars.com

-- 
/Jacob Carlborg
June 13, 2016
On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:
> On 2016-06-13 09:54, Pierre wrote:
>> Thank you i will try it.
>
> You don't need to involve the constructor. You can use .tupleof, as I mentioned [1] [2].
>
> [1] http://forum.dlang.org/post/njlohq$1n99$1@digitalmars.com
> [2] http://forum.dlang.org/post/njlop0$1ngk$1@digitalmars.com

I understand that web devels needs to dump 47 bytes and send them at 8759 miles in 200 ms, but this serialization scheme is not good for object streaming, e.g store a full GUI in a resource file. Nobody will ever use flatbuffer or message pack to store a GUI...lol.
June 13, 2016
On Monday, 13 June 2016 at 14:30:13 UTC, Basile B. wrote:
> On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:
>> On 2016-06-13 09:54, Pierre wrote:
>>> Thank you i will try it.
>>
>> You don't need to involve the constructor. You can use .tupleof, as I mentioned [1] [2].
>>
>> [1] http://forum.dlang.org/post/njlohq$1n99$1@digitalmars.com
>> [2] http://forum.dlang.org/post/njlop0$1ngk$1@digitalmars.com
>
> I understand that web devels needs to dump 47 bytes and send them at 8759 miles in 200 ms, but this serialization scheme is not good for object streaming, e.g store a full GUI in a resource file. Nobody will ever use flatbuffer or message pack to store a GUI...lol.

oops I think I've replied to another thread on another board :/

Unless It's you Jacob who have proposed Orange to phobos in 2012. And then since refused it's not developed at all. IIRC it's even not possible to compile it with DUB.
June 13, 2016
On Monday, 13 June 2016 at 15:00:06 UTC, Basile B. wrote:
> On Monday, 13 June 2016 at 14:30:13 UTC, Basile B. wrote:
>> On Monday, 13 June 2016 at 11:27:31 UTC, Jacob Carlborg wrote:
>>> On 2016-06-13 09:54, Pierre wrote:
>>>> Thank you i will try it.
>>>
>>> You don't need to involve the constructor. You can use .tupleof, as I mentioned [1] [2].
>>>
>>> [1] http://forum.dlang.org/post/njlohq$1n99$1@digitalmars.com
>>> [2] http://forum.dlang.org/post/njlop0$1ngk$1@digitalmars.com
>>
>> I understand that web devels needs to dump 47 bytes and send them at 8759 miles in 200 ms, but this serialization scheme is not good for object streaming, e.g store a full GUI in a resource file. Nobody will ever use flatbuffer or message pack to store a GUI...lol.
>
> oops I think I've replied to another thread on another board :/
>
> Unless It's you Jacob who have proposed Orange to phobos in 2012. And then since refused it's not developed at all. IIRC it's even not possible to compile it with DUB.

https://www.youtube.com/watch?v=YJO4-aa6PCI&list=PLuhnsen8iS5ltHofd21TWBx-bqmR9V8RU&index=14&nohtml5=False

now you know the origin of the hat ;)
« First   ‹ Prev
1 2