rtl: added overload TryStrToInt64 with int64, TryStrToQWord with QWord, TryStrToUInt64 with UInt64

This commit is contained in:
mattias 2020-11-13 11:17:55 +00:00
parent c09d97e72d
commit 45abbd53bf
2 changed files with 23 additions and 5 deletions

View File

@ -692,6 +692,7 @@ type
function ReadData(var Buffer: NativeLargeInt; Count: NativeInt): NativeInt; overload;
function ReadData(var Buffer: NativeLargeUInt): NativeInt; overload;
function ReadData(var Buffer: NativeLargeUInt; Count: NativeInt): NativeInt; overload;
// Note: a ReadData with Int64 would be Delphi/FPC incompatible
function ReadData(var Buffer: Double): NativeInt; overload;
function ReadData(var Buffer: Double; Count: NativeInt): NativeInt; overload;
procedure ReadBuffer(var Buffer: TBytes; Count: NativeInt); overload;

View File

@ -15,7 +15,7 @@ unit SysUtils;
{$mode objfpc}
{$modeswitch typehelpers}
{$modeswitch advancedrecords}
{$WARN 5078 off : }
interface
uses
@ -249,13 +249,16 @@ Function StrToNativeInt(const S : String) : NativeInt;
// For compatibility
Function StrToInt64(const S : String) : NativeLargeInt;
Function StrToInt64Def(const S : String; ADefault : NativeLargeInt) : NativeLargeInt;
Function TryStrToInt64(const S : String; Out res : NativeLargeInt) : Boolean;
Function TryStrToInt64(const S : String; Out res : NativeLargeInt) : Boolean; overload;
Function TryStrToInt64(const S : String; Out res : Int64) : Boolean; unimplemented; overload; // only 53 bits
Function StrToQWord(const S : String) : NativeLargeUInt;
Function StrToQWordDef(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;
Function TryStrToQWord(const S : String; Out res : NativeLargeUInt) : Boolean;
Function TryStrToQWord(const S : String; Out res : NativeLargeUInt) : Boolean; overload;
Function TryStrToQWord(const S : String; Out res : QWord) : Boolean; unimplemented; overload; // only 52 bits
Function StrToUInt64(const S : String) : NativeLargeUInt;
Function StrToUInt64Def(const S : String; ADefault : NativeLargeUInt) : NativeLargeUInt;
Function TryStrToUInt64(const S : String; Out res : NativeLargeUInt) : Boolean;
Function TryStrToUInt64(const S : String; Out res : NativeLargeUInt) : Boolean; overload;
Function TryStrToUInt64(const S : String; Out res : UInt64) : Boolean; unimplemented; overload; // only 52 bits
Function StrToDWord(const S : String) : DWord;
Function StrToDWordDef(const S : String; ADefault : DWord) : DWord;
Function TryStrToDWord(const S : String; Out res : DWord) : Boolean;
@ -4495,6 +4498,11 @@ begin
Res:=R;
end;
function TryStrToInt64(const S: String; out res: Int64): Boolean;
begin
Result:=TryStrToInt64(S,NativeLargeInt(res));
end;
function StrToInt64Def(const S: String; ADefault: NativeLargeInt
): NativeLargeInt;
@ -4526,6 +4534,11 @@ begin
Res:=R;
end;
function TryStrToQWord(const S: String; out res: QWord): Boolean;
begin
Result:=TryStrToQWord(S,NativeLargeUInt(res));
end;
function StrToQWordDef(const S: String; ADefault: NativeLargeUInt
): NativeLargeUInt;
@ -4534,7 +4547,6 @@ begin
Result:=ADefault;
end;
function StrToUInt64(const S: String): NativeLargeUInt;
Var
@ -4557,6 +4569,11 @@ begin
Res:=R;
end;
function TryStrToUInt64(const S: String; out res: UInt64): Boolean;
begin
Result:=TryStrToUInt64(S,NativeLargeUInt(res));
end;
function StrToUInt64Def(const S: String; ADefault: NativeLargeUInt
): NativeLargeUInt;