63 |
|
private |
64 |
|
FItems: array of PParamBlockItemData; |
65 |
|
FBufferSize: integer; |
66 |
+ |
FFirebirdClientAPI: TFBClientAPI; |
67 |
|
procedure AdjustBuffer; |
68 |
|
procedure MoveBy(Item: PParamBlockItemData; delta: integer); |
69 |
|
procedure UpdateRequestItemSize(Item: TParamBlockItem; NewSize: integer); |
74 |
|
function Find(ParamType: byte): PParamBlockItemData; |
75 |
|
function GetItems(index: integer): PParamBlockItemData; |
76 |
|
public |
77 |
< |
constructor Create; |
77 |
> |
constructor Create(api: TFBClientAPI); |
78 |
|
destructor Destroy; override; |
79 |
|
function getBuffer: PByte; |
80 |
|
function getDataLength: integer; |
93 |
|
FOwner: TParamBlock; |
94 |
|
FOwnerIntf: IUnknown; |
95 |
|
FParamData: PParamBlockItemData; |
96 |
+ |
FFirebirdClientAPI: TFBClientAPI; |
97 |
|
protected |
98 |
|
property ParamData: PParamBlockItemData read FParamData; |
99 |
|
public |
104 |
|
function getAsString: AnsiString; |
105 |
|
function getAsByte: byte; |
106 |
|
procedure addByte(aValue: byte); |
107 |
+ |
procedure addShortInt(aValue: ShortInt); |
108 |
|
procedure addShortInteger(aValue: integer); |
109 |
|
procedure setAsByte(aValue: byte); |
110 |
|
procedure setAsByte2(aValue: byte); |
197 |
|
|
198 |
|
TDPB = class (TCustomParamBlock<TDPBItem,IDPBItem>, IDPB) |
199 |
|
public |
200 |
< |
constructor Create; |
200 |
> |
constructor Create(api: TFBClientAPI); |
201 |
|
end; |
202 |
|
|
203 |
|
{ TTPB } |
204 |
|
|
205 |
|
TTPB = class (TCustomParamBlock<TTPBItem,ITPBItem>, ITPB) |
206 |
|
public |
207 |
< |
constructor Create; |
207 |
> |
constructor Create(api: TFBClientAPI); |
208 |
|
end; |
209 |
|
|
210 |
|
{ TSPB } |
211 |
|
|
212 |
|
TSPB = class (TCustomParamBlock<TSPBItem,ISPBItem>, ISPB) |
213 |
|
public |
214 |
< |
constructor Create; |
214 |
> |
constructor Create(api: TFBClientAPI); |
215 |
|
end; |
216 |
|
|
217 |
|
{ TSRB } |
226 |
|
|
227 |
|
TBPB = class (TCustomParamBlock<TBPBItem,IBPBItem>, IBPB) |
228 |
|
public |
229 |
< |
constructor Create; |
229 |
> |
constructor Create(api: TFBClientAPI); |
230 |
|
end; |
231 |
|
|
232 |
|
TDIRB = class (TCustomParamBlock<TDIRBItem,IDIRBItem>, IDIRB); |
278 |
|
begin |
279 |
|
FOwner.UpdateRequestItemSize(self,count + 4); |
280 |
|
Result := source.Read((FBufPtr+3)^,count); |
281 |
< |
with FirebirdClientAPI do |
281 |
> |
with FFirebirdClientAPI do |
282 |
|
EncodeInteger(Result,2,FBufPtr+1); |
283 |
|
(FBufPtr+Result + 3)^ := isc_info_end; |
284 |
|
if Result <> count then |
306 |
|
begin |
307 |
|
inherited Create; |
308 |
|
FOwner := AOwner; |
309 |
+ |
FFirebirdClientAPI := AOwner.FFirebirdClientAPI; |
310 |
|
FOwnerIntf := AOwner; |
311 |
|
FParamData := Data; |
312 |
|
end; |
313 |
|
|
314 |
|
function TParamBlockItem.getAsInteger: integer; |
315 |
|
begin |
316 |
< |
with FirebirdClientAPI, FParamData^ do |
316 |
> |
with FFirebirdClientAPI, FParamData^ do |
317 |
|
case FDataType of |
318 |
|
dtInteger: |
319 |
|
Result := DecodeInteger(FBufPtr+1,4); |
358 |
|
end; |
359 |
|
dtString2: |
360 |
|
begin |
361 |
< |
with FirebirdClientAPI do |
361 |
> |
with FFirebirdClientAPI do |
362 |
|
len := DecodeInteger(FBufPtr+1,2); |
363 |
|
SetString(Result,PAnsiChar(FBufPtr+3),len); |
364 |
|
end; |
394 |
|
end; |
395 |
|
end; |
396 |
|
|
397 |
+ |
procedure TParamBlockItem.addShortInt(aValue: ShortInt); |
398 |
+ |
var len: integer; |
399 |
+ |
P: PByte; |
400 |
+ |
begin |
401 |
+ |
with FParamData^ do |
402 |
+ |
begin |
403 |
+ |
P := FBufPtr + FBufLength; |
404 |
+ |
len := FBufLength + 1; |
405 |
+ |
FOwner.UpdateRequestItemSize(self,len); |
406 |
+ |
PShortInt(P)^ := aValue; |
407 |
+ |
end; |
408 |
+ |
end; |
409 |
+ |
|
410 |
|
procedure TParamBlockItem.addShortInteger(aValue: integer); |
411 |
|
var len: integer; |
412 |
|
P: PByte; |
416 |
|
P := FBufPtr + FBufLength; |
417 |
|
len := FBufLength + 2; |
418 |
|
FOwner.UpdateRequestItemSize(self,len); |
419 |
< |
with FirebirdClientAPI do |
419 |
> |
with FFirebirdClientAPI do |
420 |
|
EncodeInteger(aValue,2,P); |
421 |
|
end; |
422 |
|
end; |
452 |
|
begin |
453 |
|
if FBufLength <> 5 then |
454 |
|
FOwner.UpdateRequestItemSize(self,5); |
455 |
< |
with FirebirdClientAPI do |
455 |
> |
with FFirebirdClientAPI do |
456 |
|
EncodeInteger(aValue,4,FBufPtr+1); |
457 |
|
FDataType := dtInteger; |
458 |
|
end; |
467 |
|
if FBufLength <> 6 then |
468 |
|
FOwner.UpdateRequestItemSize(self,6); |
469 |
|
(FBufPtr+1)^ := $4; |
470 |
< |
with FirebirdClientAPI do |
470 |
> |
with FFirebirdClientAPI do |
471 |
|
EncodeInteger(aValue,4,FBufPtr+2); |
472 |
|
FDataType := dtInteger1; |
473 |
|
end; |
481 |
|
begin |
482 |
|
if FBufLength <> 7 then |
483 |
|
FOwner.UpdateRequestItemSize(self,7); |
484 |
< |
with FirebirdClientAPI do |
484 |
> |
with FFirebirdClientAPI do |
485 |
|
begin |
486 |
|
EncodeInteger(4,2,FBufPtr+1); {Encode length as two bytes} |
487 |
|
EncodeInteger(aValue,4,FBufPtr+3); |
496 |
|
begin |
497 |
|
if FBufLength <> 3 then |
498 |
|
FOwner.UpdateRequestItemSize(self,3); |
499 |
< |
with FirebirdClientAPI do |
499 |
> |
with FFirebirdClientAPI do |
500 |
|
EncodeInteger(aValue,2,FBufPtr+1); |
501 |
|
FDataType := dtShortInteger; |
502 |
|
end; |
508 |
|
begin |
509 |
|
if FBufLength <> 2 then |
510 |
|
FOwner.UpdateRequestItemSize(self,2); |
511 |
< |
with FirebirdClientAPI do |
511 |
> |
with FFirebirdClientAPI do |
512 |
|
EncodeInteger(aValue,1,FBufPtr+1); |
513 |
|
FDataType := dtTinyInteger; |
514 |
|
end; |
543 |
|
if len > 65535 then |
544 |
|
IBError(ibxStringTooLong,[aValue,65535]); |
545 |
|
FOwner.UpdateRequestItemSize(self,len + 3); |
546 |
< |
with FirebirdClientAPI do |
546 |
> |
with FFirebirdClientAPI do |
547 |
|
EncodeInteger(len,2,FBufPtr+1); |
548 |
|
if len > 0 then |
549 |
|
Move(aValue[1],(FBufPtr+3)^,len); |
653 |
|
end; |
654 |
|
end; |
655 |
|
|
656 |
< |
constructor TParamBlock.Create; |
656 |
> |
constructor TParamBlock.Create(api: TFBClientAPI); |
657 |
|
begin |
658 |
|
inherited Create; |
659 |
+ |
FFirebirdClientAPI := api; |
660 |
|
GetMem(FBuffer,128); |
661 |
|
if FBuffer = nil then |
662 |
|
OutOfMemoryError; |
822 |
|
|
823 |
|
{ TDPB } |
824 |
|
|
825 |
< |
constructor TDPB.Create; |
825 |
> |
constructor TDPB.Create(api: TFBClientAPI); |
826 |
|
begin |
827 |
< |
inherited Create; |
827 |
> |
inherited Create(api); |
828 |
|
FDataLength := 1; |
829 |
|
FBuffer^ := isc_dpb_version1; |
830 |
|
end; |
831 |
|
|
832 |
|
{ TTPB } |
833 |
|
|
834 |
< |
constructor TTPB.Create; |
834 |
> |
constructor TTPB.Create(api: TFBClientAPI); |
835 |
|
begin |
836 |
< |
inherited Create; |
836 |
> |
inherited Create(api); |
837 |
|
FDataLength := 1; |
838 |
|
FBuffer^ := isc_tpb_version3; |
839 |
|
end; |
840 |
|
|
841 |
|
{ TSPB } |
842 |
|
|
843 |
< |
constructor TSPB.Create; |
843 |
> |
constructor TSPB.Create(api: TFBClientAPI); |
844 |
|
begin |
845 |
< |
inherited Create; |
845 |
> |
inherited Create(api); |
846 |
|
FDataLength := 2; |
847 |
|
FBuffer^ := isc_spb_version; |
848 |
|
(FBuffer+1)^ := isc_spb_current_version; |
850 |
|
|
851 |
|
{ TBPB } |
852 |
|
|
853 |
< |
constructor TBPB.Create; |
853 |
> |
constructor TBPB.Create(api: TFBClientAPI); |
854 |
|
begin |
855 |
< |
inherited Create; |
855 |
> |
inherited Create(api); |
856 |
|
FDataLength := 1; |
857 |
|
FBuffer^ := isc_bpb_version1; |
858 |
|
end; |