ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/fbintf/IBUtils.pas
(Generate patch)

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

# Line 32 | Line 32
32   {************************************************************************}
33  
34   unit IBUtils;
35 + {$IFDEF MSWINDOWS}
36 + {$DEFINE WINDOWS}
37 + {$ENDIF}
38  
39   {$IFDEF FPC}
40   {$Mode Delphi}
# Line 40 | Line 43 | unit IBUtils;
43  
44   interface
45  
46 < uses
44 < {$IFDEF WINDOWS }
45 <  Windows,
46 < {$ELSE}
47 <  unix,
48 < {$ENDIF}
49 <  Classes, SysUtils;
46 > uses Classes, SysUtils;
47  
48   const
49    CRLF = #13 + #10;
# Line 258 | Line 255 | const
255  
256   function Max(n1, n2: Integer): Integer;
257   function Min(n1, n2: Integer): Integer;
258 < function RandomString(iLength: Integer): String;
258 > function RandomString(iLength: Integer): AnsiString;
259   function RandomInteger(iLow, iHigh: Integer): Integer;
260 < function StripString(st: String; CharsToStrip: String): String;
261 < function FormatIdentifier(Dialect: Integer; Value: String): String;
262 < function FormatIdentifierValue(Dialect: Integer; Value: String): String;
263 < function FormatIdentifierValueNC(Dialect: Integer; Value: String): String;
264 < function ExtractIdentifier(Dialect: Integer; Value: String): String;
265 < function QuoteIdentifier(Dialect: Integer; Value: String): String;
266 < function QuoteIdentifierIfNeeded(Dialect: Integer; Value: String): String;
267 < function Space2Underscore(s: string): string;
268 < function SQLSafeString(const s: string): string;
260 > function StripString(st: AnsiString; CharsToStrip: AnsiString): AnsiString;
261 > function FormatIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
262 > function FormatIdentifierValue(Dialect: Integer; Value: AnsiString): AnsiString;
263 > function FormatIdentifierValueNC(Dialect: Integer; Value: AnsiString): AnsiString;
264 > function ExtractIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
265 > function QuoteIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
266 > function QuoteIdentifierIfNeeded(Dialect: Integer; Value: AnsiString): AnsiString;
267 > function Space2Underscore(s: AnsiString): AnsiString;
268 > function SQLSafeString(const s: AnsiString): AnsiString;
269  
270   implementation
271  
# Line 288 | Line 285 | begin
285      result := n2;
286   end;
287  
288 < function RandomString(iLength: Integer): String;
288 > function RandomString(iLength: Integer): AnsiString;
289   begin
290    result := '';
291    while Length(result) < iLength do
# Line 302 | Line 299 | begin
299    result := Trunc(Random(iHigh - iLow)) + iLow;
300   end;
301  
302 < function StripString(st: String; CharsToStrip: String): String;
302 > function StripString(st: AnsiString; CharsToStrip: AnsiString): AnsiString;
303   var
304    i: Integer;
305   begin
# Line 313 | Line 310 | begin
310    end;
311   end;
312  
313 < function FormatIdentifier(Dialect: Integer; Value: String): String;
313 > function FormatIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
314   begin
315    Value := Trim(Value);
316    if Dialect = 1 then
# Line 326 | Line 323 | begin
323    Result := Value;
324   end;
325  
326 < function FormatIdentifierValue(Dialect: Integer; Value: String): String;
326 > function FormatIdentifierValue(Dialect: Integer; Value: AnsiString): AnsiString;
327   begin
328    Value := Trim(Value);
329    if Dialect = 1 then
# Line 345 | Line 342 | begin
342    Result := Value;
343   end;
344  
345 < function FormatIdentifierValueNC(Dialect: Integer; Value: String): String;
345 > function FormatIdentifierValueNC(Dialect: Integer; Value: AnsiString): AnsiString;
346   begin
347    Value := Trim(Value);
348    if Dialect = 1 then
# Line 364 | Line 361 | begin
361    Result := Value;
362   end;
363  
364 < function ExtractIdentifier(Dialect: Integer; Value: String): String;
364 > function ExtractIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
365   begin
366    Value := Trim(Value);
367    if Dialect = 1 then
# Line 383 | Line 380 | begin
380    Result := Value;
381   end;
382  
383 < function IsReservedWord(w: string): boolean;
383 > function IsReservedWord(w: AnsiString): boolean;
384   var i: integer;
385   begin
386       Result := true;
# Line 393 | Line 390 | begin
390       Result := false;
391   end;
392  
393 < function QuoteIdentifier(Dialect: Integer; Value: String): String;
393 > function QuoteIdentifier(Dialect: Integer; Value: AnsiString): AnsiString;
394   begin
395    if Dialect = 1 then
396      Value := AnsiUpperCase(Trim(Value))
# Line 402 | Line 399 | begin
399    Result := Value;
400   end;
401  
402 < function QuoteIdentifierIfNeeded(Dialect: Integer; Value: String): String;
402 > function QuoteIdentifierIfNeeded(Dialect: Integer; Value: AnsiString): AnsiString;
403   begin
404    if (Dialect = 3) and
405      ((AnsiUpperCase(Value) <> Value) or IsReservedWord(Value)) then
# Line 411 | Line 408 | begin
408      Result := Value
409   end;
410  
411 < function Space2Underscore(s: string): string;
411 > function Space2Underscore(s: AnsiString): AnsiString;
412   var
413     k: integer;
414   begin
# Line 421 | Line 418 | begin
418              Result[k] := '_';
419   end;
420  
421 < function SQLSafeString(const s: string): string;
421 > function SQLSafeString(const s: AnsiString): AnsiString;
422   begin
423    Result := StringReplace(s,'''','''''',[rfReplaceAll]);
424   end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines