Browse Source

* Made overloading situation ifthen more Delphi compatible. Mantis #12662
All string variants now in one unit.

git-svn-id: trunk@12442 -

marco 16 years ago
parent
commit
f0c236b992
2 changed files with 8 additions and 14 deletions
  1. 3 9
      rtl/objpas/math.pp
  2. 5 5
      rtl/objpas/strutils.pp

+ 3 - 9
rtl/objpas/math.pp

@@ -510,10 +510,9 @@ function norm(const data : array of Extended) : float;
 function norm(const data : PExtended; Const N : Integer) : float;
 {$endif FPC_HAS_TYPE_EXTENDED}
 
-function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; inline;
-function ifthen(val:boolean;const iftrue:int64  ; const iffalse:int64 = 0)  :int64;   inline;
-function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double;  inline;
-function ifthen(val:boolean;const iftrue:String ; const iffalse:String ='') :String;  inline;
+function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; inline; overload;
+function ifthen(val:boolean;const iftrue:int64  ; const iffalse:int64 = 0)  :int64;   inline; overload;
+function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double;  inline; overload;
 
 function CompareValue ( const A, B  : Integer) : TValueRelationship; inline;
 function CompareValue ( const A, B  : Int64) : TValueRelationship; inline;
@@ -2240,11 +2239,6 @@ begin
   if val then result:=iftrue else result:=iffalse;
 end;
 
-function ifthen(val:boolean;const iftrue:String ; const iffalse:String ='') :String;  inline;
-begin
-  if val then result:=iftrue else result:=iffalse;
-end;
-
 // dilemma here. asm can do the two comparisons in one go?
 // but pascal is portable and can be i inline;ed. Ah well, we need purepascal's anyway:
 function CompareValue ( const A, B  : Integer) : TValueRelationship;

+ 5 - 5
rtl/objpas/strutils.pp

@@ -56,6 +56,7 @@ Function StuffString(const AText: string; AStart, ALength: Cardinal;  const ASub
 Function RandomFrom(const AValues: array of string): string; overload;
 Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline;
 Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = ''
+Function IfThen(AValue: Boolean; const ATrue: shortString ; const Afalse: shortString ='') :shortString;  inline;
 
 { ---------------------------------------------------------------------
     VB emulations.
@@ -395,8 +396,6 @@ begin
   result:=Avalues[random(High(AValues)+1)];
 end;
 
-
-
 Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline;
 
 begin
@@ -406,8 +405,6 @@ begin
     result:=afalse;
 end;
 
-
-
 Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = ''
 
 begin
@@ -417,7 +414,10 @@ begin
     result:='';
 end;
 
-
+Function IfThen(AValue:boolean;const ATrue:shortString ; const AFalse:shortString ='') :shortString;  inline;
+begin
+  if AValue then result:=ATrue else result:=AFalse;
+end;
 
 { ---------------------------------------------------------------------
     VB emulations.