ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/3.0/FB30ClientAPI.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/3.0/FB30ClientAPI.pas (file contents):
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 56 by tony, Mon Mar 6 10:20:02 2017 UTC

# Line 25 | Line 25
25   *
26   *)
27   unit FB30ClientAPI;
28 + {$IFDEF MSWINDOWS}
29 + {$DEFINE WINDOWS}
30 + {$ENDIF}
31  
32   {$IFDEF FPC}
33   {$mode delphi}
# Line 87 | Line 90 | type
90      function AllocateTPB: ITPB;
91  
92      {Database connections}
93 <    function OpenDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
94 <    function CreateDatabase(DatabaseName: string; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
95 <    function CreateDatabase(sql: string; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
93 >    function OpenDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnConnectError: boolean=true): IAttachment;
94 >    function CreateDatabase(DatabaseName: AnsiString; DPB: IDPB; RaiseExceptionOnError: boolean=true): IAttachment; overload;
95 >    function CreateDatabase(sql: AnsiString; aSQLDialect: integer; RaiseExceptionOnError: boolean=true): IAttachment; overload;
96      {Start Transaction against multiple databases}
97      function StartTransaction(Attachments: array of IAttachment;
98               TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; overload;
# Line 98 | Line 101 | type
101  
102      {Service Manager}
103      function AllocateSPB: ISPB;
104 <    function GetServiceManager(ServerName: string; Protocol: TProtocol; SPB: ISPB): IServiceManager;
104 >    function GetServiceManager(ServerName: AnsiString; Protocol: TProtocol; SPB: ISPB): IServiceManager;
105  
106      {Information}
107      function HasServiceAPI: boolean;
108      function HasRollbackRetaining: boolean;
109      function IsEmbeddedServer: boolean; override;
110 <    function GetImplementationVersion: string;
110 >    function GetImplementationVersion: AnsiString;
111  
112      {Firebird 3 API}
113      function HasMasterIntf: boolean;
114      function GetIMaster: TObject;
115  
116      {Encode/Decode}
117 <    function DecodeInteger(bufptr: PChar; len: short): integer; override;
118 <    procedure SQLEncodeDate(aDate: TDateTime; bufptr: PChar); override;
119 <    function SQLDecodeDate(bufptr: PChar): TDateTime; override;
120 <    procedure SQLEncodeTime(aTime: TDateTime; bufptr: PChar); override;
121 <    function SQLDecodeTime(bufptr: PChar): TDateTime;  override;
122 <    procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PChar); override;
123 <    function SQLDecodeDateTime(bufptr: PChar): TDateTime; override;
117 >    function DecodeInteger(bufptr: PByte; len: short): integer; override;
118 >    procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override;
119 >    function SQLDecodeDate(bufptr: PByte): TDateTime; override;
120 >    procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override;
121 >    function SQLDecodeTime(bufptr: PByte): TDateTime;  override;
122 >    procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override;
123 >    function SQLDecodeDateTime(bufptr: PByte): TDateTime; override;
124  
125      {Firebird Interfaces}
126      property MasterIntf: Firebird.IMaster read FMaster;
# Line 129 | Line 132 | var Firebird30ClientAPI: TFB30ClientAPI;
132  
133   implementation
134  
135 < uses FBParamBlock, FB30Attachment, dynlibs, FBMessages, FB30Services,
136 <  FB30Transaction;
135 > uses FBParamBlock, FB30Attachment, {$IFDEF FPC}dynlibs{$ELSE} windows{$ENDIF},
136 >     FBMessages, FB30Services, FB30Transaction;
137  
138   type
139    PISC_DATE = ^ISC_DATE;
# Line 167 | Line 170 | end;
170  
171   procedure TFB30ClientAPI.CheckPlugins;
172   var FBConf: Firebird.IFirebirdConf;
173 <    Plugins: string;
173 >    Plugins: AnsiString;
174      PluginsList: TStringList;
175   begin
176    FIsEmbeddedServer := false;
# Line 258 | Line 261 | begin
261    Result := TTPB.Create;
262   end;
263  
264 < function TFB30ClientAPI.OpenDatabase(DatabaseName: string; DPB: IDPB;
264 > function TFB30ClientAPI.OpenDatabase(DatabaseName: AnsiString; DPB: IDPB;
265    RaiseExceptionOnConnectError: boolean): IAttachment;
266   begin
267    Result := TFB30Attachment.Create(DatabaseName, DPB, RaiseExceptionOnConnectError);
# Line 266 | Line 269 | begin
269      Result := nil;
270   end;
271  
272 < function TFB30ClientAPI.CreateDatabase(DatabaseName: string; DPB: IDPB;
272 > function TFB30ClientAPI.CreateDatabase(DatabaseName: AnsiString; DPB: IDPB;
273    RaiseExceptionOnError: boolean): IAttachment;
274   begin
275    Result := TFB30Attachment.CreateDatabase(DatabaseName,DPB, RaiseExceptionOnError);
# Line 274 | Line 277 | begin
277      Result := nil;
278   end;
279  
280 < function TFB30ClientAPI.CreateDatabase(sql: string; aSQLDialect: integer;
280 > function TFB30ClientAPI.CreateDatabase(sql: AnsiString; aSQLDialect: integer;
281    RaiseExceptionOnError: boolean): IAttachment;
282   begin
283    Result := TFB30Attachment.CreateDatabase(sql,aSQLDialect, RaiseExceptionOnError);
# Line 299 | Line 302 | begin
302    Result := TSPB.Create;
303   end;
304  
305 < function TFB30ClientAPI.GetServiceManager(ServerName: string;
305 > function TFB30ClientAPI.GetServiceManager(ServerName: AnsiString;
306    Protocol: TProtocol; SPB: ISPB): IServiceManager;
307   begin
308    Result := TFB30ServiceManager.Create(ServerName,Protocol,SPB);
# Line 330 | Line 333 | begin
333    Result := FIsEmbeddedServer;
334   end;
335  
336 < function TFB30ClientAPI.GetImplementationVersion: string;
336 > function TFB30ClientAPI.GetImplementationVersion: AnsiString;
337   begin
338    Result := Format('3.%d',[UtilIntf.GetClientVersion]);
339   end;
340  
341 < function TFB30ClientAPI.DecodeInteger(bufptr: PChar; len: short): integer;
342 < var P: PChar;
341 > function TFB30ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer;
342 > var P: PByte;
343   begin
344    Result := 0;
345    P := Bufptr + len - 1;
346    while P >= bufptr do
347    begin
348 <    Result := (Result shl 8 ) or byte(P^);
348 >    Result := (Result shl 8 ) or P^;
349      Dec(P);
350    end;
351   end;
352  
353 < procedure TFB30ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PChar);
353 > procedure TFB30ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte);
354   var
355    Yr, Mn, Dy: Word;
356   begin
# Line 355 | Line 358 | begin
358     PISC_Date(Bufptr)^ := UtilIntf.encodeDate(Yr, Mn, Dy);
359   end;
360  
361 < function TFB30ClientAPI.SQLDecodeDate(bufptr: PChar): TDateTime;
361 > function TFB30ClientAPI.SQLDecodeDate(bufptr: PByte): TDateTime;
362   var
363 <  Yr, Mn, Dy: Word;
363 >  Yr, Mn, Dy: cardinal;
364   begin
365    UtilIntf.decodeDate(PISC_DATE(bufptr)^,@Yr, @Mn, @Dy);
366    try
# Line 369 | Line 372 | begin
372    end;
373   end;
374  
375 < procedure TFB30ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PChar);
375 > procedure TFB30ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte);
376   var
377    Hr, Mt, S, Ms: Word;
378   begin
# Line 377 | Line 380 | begin
380    PISC_TIME(bufptr)^ :=  UtilIntf.encodeTime(Hr, Mt, S, Ms*10);
381   end;
382  
383 < function TFB30ClientAPI.SQLDecodeTime(bufptr: PChar): TDateTime;
383 > function TFB30ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime;
384   var
385 <  Hr, Mt, S, Ms: Word;
385 >  Hr, Mt, S, Ms: cardinal;
386   begin
387    UtilIntf.decodeTime(PISC_TIME(bufptr)^,@Hr, @Mt, @S, @Ms);
388    try
# Line 391 | Line 394 | begin
394    end;
395   end;
396  
397 < procedure TFB30ClientAPI.SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PChar);
397 > procedure TFB30ClientAPI.SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte);
398   begin
399    SQLEncodeDate(aDateTime,bufPtr);
400    Inc(bufptr,sizeof(ISC_DATE));
401    SQLEncodeTime(aDateTime,bufPtr);
402   end;
403  
404 < function TFB30ClientAPI.SQLDecodeDateTime(bufptr: PChar): TDateTime;
404 > function TFB30ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime;
405   begin
406    Result := SQLDecodeDate(bufPtr);
407    Inc(bufptr,sizeof(ISC_DATE));
408 <  Result += SQLDecodeTime(bufPtr);
408 >  Result := Result + SQLDecodeTime(bufPtr);
409   end;
410  
411   end.
412  
413 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines