From: <dav...@us...> - 2009-09-03 09:13:22
|
Revision: 870 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=870&view=rev Author: davidvtaylor Date: 2009-09-03 09:13:11 +0000 (Thu, 03 Sep 2009) Log Message: ----------- Fix for problem inserting and updating Blob attributes + Added new type TInstantBytes to mirror the new TBytes type in D12+ + Added Bytes property to TInstantBlob to provide access to raw stream data as a byte array * Modified AddBlobAttributeParam to properly handle data assignment for D12+ Modified Paths: -------------- trunk/Source/Core/InstantBrokers.pas trunk/Source/Core/InstantPersistence.pas trunk/Source/Core/InstantTypes.pas Modified: trunk/Source/Core/InstantBrokers.pas =================================================================== --- trunk/Source/Core/InstantBrokers.pas 2009-08-29 07:57:59 UTC (rev 869) +++ trunk/Source/Core/InstantBrokers.pas 2009-09-03 09:13:11 UTC (rev 870) @@ -2831,7 +2831,11 @@ if Attribute.IsNull then LParam.Clear else - LParam.AsMemo := (Attribute as TInstantBlob).Value; + {$IFDEF D12+} + LParam.AsBytes := (Attribute as TInstantBlob).Bytes; + {$ELSE} + LParam.AsBlob := (Attribute as TInstantBlob).Value; + {$ENDIF} end; procedure AddBooleanAttributeParam; Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2009-08-29 07:57:59 UTC (rev 869) +++ trunk/Source/Core/InstantPersistence.pas 2009-09-03 09:13:11 UTC (rev 870) @@ -446,6 +446,8 @@ function GetStream: TMemoryStream; property Stream: TMemoryStream read GetStream; protected + function GetBytes: TInstantBytes; + procedure SetBytes(const AValue: TInstantBytes); function GetValue: string; virtual; procedure SetValue(const AValue: string); virtual; class function AttributeType: TInstantAttributeType; override; @@ -472,6 +474,7 @@ function WriteBuffer(const Buffer; Position, Count: Integer): Integer; property Size: Integer read GetSize; published + property Bytes: TInstantBytes read GetBytes write SetBytes; property Value: string read GetValue write SetValue; end; @@ -3458,6 +3461,13 @@ Result := Value; end; +function TInstantBlob.GetBytes: TInstantBytes; +begin + SetLength(Result, Size); + if Size > 0 then + Read(Result[0], 0, Size); +end; + function TInstantBlob.GetSize: Integer; begin Result := Stream.Size; @@ -3556,6 +3566,21 @@ end; end; +procedure TInstantBlob.SetBytes(const AValue: TInstantBytes); +var + L: Integer; +begin + L := length(AValue); + if L > 0 then + begin + Stream.Clear; + WriteBuffer(AValue[0], 0, L); + Stream.Size := L; + end + else + Clear; +end; + procedure TInstantBlob.SetValue(const AValue: string); var L: Integer; Modified: trunk/Source/Core/InstantTypes.pas =================================================================== --- trunk/Source/Core/InstantTypes.pas 2009-08-29 07:57:59 UTC (rev 869) +++ trunk/Source/Core/InstantTypes.pas 2009-09-03 09:13:11 UTC (rev 870) @@ -40,6 +40,11 @@ interface +{$IFDEF D12+} +uses + Sysutils; // TBytes +{$ENDIF} + type {$IFNDEF D6+} IInterface = interface (IUnknown) @@ -89,6 +94,12 @@ TTime = type TDateTime; TDate = type TDateTime; + {$IFDEF D12+} + TInstantBytes = TBytes; + {$ELSE} + TInstantBytes = array of Byte; + {$ENDIF} + implementation end. |