Browse Source

+ StrToQWord patch from Vincent Snijders

git-svn-id: trunk@2148 -
florian 19 years ago
parent
commit
f60d89cc75
2 changed files with 32 additions and 7 deletions
  1. 29 7
      rtl/objpas/sysutils/sysstr.inc
  2. 3 0
      rtl/objpas/sysutils/sysstrh.inc

+ 29 - 7
rtl/objpas/sysutils/sysstr.inc

@@ -773,7 +773,6 @@ end ;
 
 function StrToInt64(const S: string): int64;
 var Error: word;
-
 begin
   Val(S, result, Error);
   if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
@@ -788,6 +787,20 @@ begin
 end;
 
 
+function StrToQWord(const s: string): QWord;
+var Error: word;
+begin
+  Val(S, result, Error);
+  if Error <> 0 then raise EConvertError.createfmt(SInvalidInteger,[S]);
+end;
+
+
+function TryStrQWord(const s: string; var i: QWord): boolean;
+var Error : word;
+begin
+  Val(s, i, Error);
+  TryStrQWord:=Error=0
+end;
 
 {   StrToIntDef converts the string S to an integer value,
     Default is returned in case S does not represent a valid integer value  }
@@ -795,20 +808,29 @@ end;
 function StrToIntDef(const S: string; Default: integer): integer;
 var Error: word;
 begin
-Val(S, result, Error);
-if Error <> 0 then result := Default;
+  Val(S, result, Error);
+  if Error <> 0 then result := Default;
 end ;
 
-{   StrToIntDef converts the string S to an integer value,
-    Default is returned in case S does not represent a valid integer value  }
+{   StrToInt64Def converts the string S to an int64 value,
+    Default is returned in case S does not represent a valid int64 value  }
 
 function StrToInt64Def(const S: string; Default: int64): int64;
 var Error: word;
 begin
-Val(S, result, Error);
-if Error <> 0 then result := Default;
+  Val(S, result, Error);
+  if Error <> 0 then result := Default;
 end ;
 
+{   StrToQWordDef converts the string S to an QWord value,
+    Default is returned in case S does not represent a valid QWord value  }
+
+function StrToQWordDef(const S: string; Default: QWord): QWord;
+var Error: word;
+begin
+  Val(S, result, Error);
+  if Error <> 0 then result := Default;
+end;
 
 {   LoadStr returns the string resource Ident.   }
 

+ 3 - 0
rtl/objpas/sysutils/sysstrh.inc

@@ -107,8 +107,11 @@ function StrToInt(const s: string): integer;
 function TryStrToInt(const s: string; var i : integer) : boolean;
 function StrToInt64(const s: string): int64;
 function TryStrToInt64(const s: string; var i : int64) : boolean;
+function StrToQWord(const s: string): QWord;
+function TryStrQWord(const s: string; var i : QWord) : boolean;
 function StrToIntDef(const S: string; Default: integer): integer;
 function StrToInt64Def(const S: string; Default: int64): int64;
+function StrToQWordDef(const S: string; Default: QWord): QWord;
 function LoadStr(Ident: integer): string;
 // function FmtLoadStr(Ident: integer; const Args: array of const): string;
 Function Format (Const Fmt : String; const Args : Array of const) : String;