diff options
author | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-05-11 13:14:47 +0000 |
---|---|---|
committer | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2020-05-11 13:14:47 +0000 |
commit | 144dcd21a5555a5f3f24cf049c2824bb0f8b26c8 (patch) | |
tree | d0ea3f9f5686265d972d6c2b141eea6d6a887c3f | |
parent | c42f58414273d938468955cf596b4be9e9f8a6d3 (diff) | |
download | fpc-144dcd21a5555a5f3f24cf049c2824bb0f8b26c8.tar.gz |
* Patch from N. Neumann, implement some delphi compatible StrToUint functions (bug id 37049)
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@45336 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | rtl/objpas/sysutils/sysstr.inc | 15 | ||||
-rw-r--r-- | rtl/objpas/sysutils/sysstrh.inc | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index 529ac2a77c..3819eb2a4e 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -979,6 +979,16 @@ begin TryStrToDWord:=Error=0 end; +function StrToUInt(const s: string): Cardinal; +begin + StrToUInt:=StrToDWord(s); +end; + +function TryStrToUInt(const s: string; out C: Cardinal): Boolean; +begin + TryStrToUInt:=TryStrToDWord(s, C); +end; + function TryStrToQWord(const s: string; Out Q: QWord): boolean; var Error : word; begin @@ -1011,6 +1021,11 @@ begin if Error <> 0 then result := Default; end; +function StrToUIntDef(const S: string; Default: Cardinal): Cardinal; +begin + Result:=StrToDWordDef(S, Default); +end; + { StrToInt64Def converts the string S to an int64 value, Default is returned in case S does not represent a valid int64 value } diff --git a/rtl/objpas/sysutils/sysstrh.inc b/rtl/objpas/sysutils/sysstrh.inc index 30d8716623..1cf84e07fe 100644 --- a/rtl/objpas/sysutils/sysstrh.inc +++ b/rtl/objpas/sysutils/sysstrh.inc @@ -122,16 +122,19 @@ function IntToHex(Value: Int64; Digits: integer): string; function IntToHex(Value: QWord; Digits: integer): string; {$ifdef SYSUTILSINLINE}inline;{$ENDIF} function StrToInt(const s: string): Longint; function StrToDWord(const s: string): DWord; +function StrToUInt(const s: string): Cardinal; function StrToInt64(const s: string): int64; function StrToQWord(const s: string): QWord; function StrToUInt64(const s: string): UInt64; inline; function TryStrToInt(const s: string; Out i : Longint) : boolean; function TryStrToDWord(const s: string; Out D : DWord) : boolean; +function TryStrToUInt(const s: string; out C: Cardinal): Boolean; function TryStrToInt64(const s: string; Out i : int64) : boolean; function TryStrToQWord(const s: string; Out Q : QWord) : boolean; function TryStrToUInt64(const s: string; Out u : UInt64) : boolean; inline; function StrToIntDef(const S: string; Default: Longint): Longint; function StrToDWordDef(const S: string; Default: DWord): DWord; +function StrToUIntDef(const S: string; Default: Cardinal): Cardinal; function StrToInt64Def(const S: string; Default: int64): int64; function StrToQWordDef(const S: string; Default: QWord): QWord; function StrToUInt64Def(const S: string; Default: UInt64): UInt64; inline; |