Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-13 Thread stdreamer
On 11/02/2016 17:13 μμ, Graeme Geldenhuys wrote: Hi, In TPersistent, we have two virtual methods. Assign() which calls AssignTo(). 1) Why are they both virtual? It seems like Assign() is what I call a template method, farming its work out to other helper methods - in this case, AssignTo(). Norm

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-12 Thread Graeme Geldenhuys
On 2016-02-12 02:17, Dennis wrote: > Is there any sample codes to copy published properties (via RTTI) ? > e.g. psuedo code below Take a look at tiOPF's TtiObject.AssignPublishedProps() method. https://sourceforge.net/p/tiopf/code/ci/tiopf2/tree/Core/tiObject.pas#l1156 The tiRTTI.pas unit also

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Dennis Poon
Martin Schreiber wrote: On Friday 12 February 2016 03:17:57 Dennis wrote: Is there any sample codes to copy published properties (via RTTI) ? e.g. psuedo code below for i := 0 to properties.count -1 do begin case properties[i].type of vtInteger : properties[i].AsInteger

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Martin Schreiber
On Friday 12 February 2016 03:17:57 Dennis wrote: > > Is there any sample codes to copy published properties (via RTTI) ? > e.g. psuedo code below > >for i := 0 to properties.count -1 do begin > case properties[i].type of > vtInteger : properties[i].AsInteger := > Source.Propert

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Dennis
Martin Schreiber wrote: On Thursday 11 February 2016 17:17:32 Graeme Geldenhuys wrote: Now the other thing that surprised be, I thought TPersistent.Assign() automatically handles protected properties (via RTTI) - thinking that descendants automatically get such functionality for free. But revi

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Martin Schreiber
On Thursday 11 February 2016 17:17:32 Graeme Geldenhuys wrote: > > Now the other thing that surprised be, I thought TPersistent.Assign() > automatically handles protected properties (via RTTI) - thinking that > descendants automatically get such functionality for free. But reviewing > the RTL code,

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Graeme Geldenhuys
On 2016-02-11 15:55, Martin Schreiber wrote: > It depends on what knows to handle what. Sometimes both have to be overridden. Thanks Martin and Andreas. So it's more about which direction you want to go. Now the other thing that surprised be, I thought TPersistent.Assign() automatically handles p

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Martin Schreiber
On Thursday 11 February 2016 16:13:22 Graeme Geldenhuys wrote: > Hi, > > In TPersistent, we have two virtual methods. Assign() which calls > AssignTo(). > > 1) Why are they both virtual? It seems like Assign() is what I call a > template method, farming its work out to other helper methods - in thi

Re: [fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Andreas Schneider
Am 2016-02-11 16:13, schrieb Graeme Geldenhuys: Hi, In TPersistent, we have two virtual methods. Assign() which calls AssignTo(). 1) Why are they both virtual? It seems like Assign() is what I call a template method, farming its work out to other helper methods - in this case, AssignTo(). Norma

[fpc-pascal] Assign() vs AssignTo()

2016-02-11 Thread Graeme Geldenhuys
Hi, In TPersistent, we have two virtual methods. Assign() which calls AssignTo(). 1) Why are they both virtual? It seems like Assign() is what I call a template method, farming its work out to other helper methods - in this case, AssignTo(). Normally template methods are not virtual, but their he