[fpc-devel] Recent changes to TField.SetData

LacaK lacak at zoznam.sk
Tue Apr 5 07:41:34 CEST 2011


>>>
>>> Then please move approprate code at least into 
>>> TCustomBufDataset.SetFieldData
>>> Thanks
>>
>> This code was already there.
>>
>> Should the 'Validate' code be moved there too ?
>
> Yes. TDataset descendants are responsible to calling Validate, e.g., 
> zeos call it inside TZAbstractRODataset.SetFieldData.
I agree, but I do not like idea, that SAME piece of code must be 
repeated in many descendants of TDataSet (TCustomBufDataSet, TParadox, 
TMemDataset,  TFixedFormatDataSet,  TDbf, TCustomSqliteDataset etc.)

So it would be good, if we can put 'validate code' into any new method? 
and call it once from descendants (be precise only from descendants, 
which are intended for use in FPC, because components which are also for 
Delphi must do it in Delphi compatible way and can not use this new method)

>
> One of the reasons of letting descendants call it it's too improve 
> granularity so Validate can be called in the middle of the routine, as 
> is in zeos, instead to  force the call before the TDataset routine.
Yes, but I think, that in many cases can be expected, that 'validate' 
will be called before any other action,

It seems, that TDataSet descendants never call inherited 
TDataSet.SetFieldData(Field: TField; Buffer: Pointer);
(because it is empty method)
So if we move 'validate code' there then in 'our' descendants we put only
{$IFDEF FPC}
   inherited;
{$ENDIF}
at first line. This does not affect existing tdataset descendants, and 
FPC dataset descendants can be adjusted to benefit from this.
(I know, it is not perfect solution ;-) but I very dislike repeat same 
'validate'  code in X places)

--or--
introduce any new method (ValidateFieldData ? ;-))) and let tdatsset 
descendants use it:
{$IFDEF FPC}
 ValidateFieldData(Field: TField; Buffer: Pointer);
{$ENDIF}

--or--
some smarter solution ?

Laco.




More information about the fpc-devel mailing list