浏览代码

[commons] added function unquotedstr

Exilon 3 年之前
父节点
当前提交
626e506be8
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      Quick.Commons.pas

+ 8 - 1
Quick.Commons.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 2.0
   Version     : 2.0
   Created     : 14/07/2017
   Created     : 14/07/2017
-  Modified    : 29/08/2021
+  Modified    : 03/10/2021
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -432,6 +432,7 @@ type
   //get simple quoted or dequoted string
   //get simple quoted or dequoted string
   function SpQuotedStr(const str : string): string;
   function SpQuotedStr(const str : string): string;
   function UnSpQuotedStr(const str : string): string;
   function UnSpQuotedStr(const str : string): string;
+  function UnQuotedStr(const str : string; const aQuote : Char) : string;
   //ternary operator
   //ternary operator
   function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string; overload;
   function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string; overload;
   function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Integer) : Integer; overload;
   function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : Integer) : Integer; overload;
@@ -2141,6 +2142,12 @@ begin
   end;
   end;
 end;
 end;
 
 
+function UnQuotedStr(const str : string; const aQuote : Char) : string;
+begin
+  if (str.Length > 0) and (str[Low(str)] = aQuote) and (str[High(str)] = aQuote) then Result := Copy(str, Low(str)+1, High(str) - 1)
+    else Result := str;
+end;
+
 function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string;
 function Ifx(aCondition : Boolean; const aIfIsTrue, aIfIsFalse : string) : string;
 begin
 begin
   if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;
   if aCondition then Result := aIfIsTrue else Result := aIfIsFalse;