Browse Source

Quick.Commons new function

Unknown 6 năm trước cách đây
mục cha
commit
34cacb7d41
1 tập tin đã thay đổi với 18 bổ sung0 xóa
  1. 18 0
      Quick.Commons.pas

+ 18 - 0
Quick.Commons.pas

@@ -270,6 +270,8 @@ type
   function CountDigits(anInt: Cardinal): Cardinal; inline;
   function CountDigits(anInt: Cardinal): Cardinal; inline;
   //save stream to file
   //save stream to file
   procedure SaveStreamToFile(stream : TStream; const filename : string);
   procedure SaveStreamToFile(stream : TStream; const filename : string);
+  //save stream to string
+  function StreamToString(stream : TStream) : string;
   //returns a real comma separated text from stringlist
   //returns a real comma separated text from stringlist
   function CommaText(aList : TStringList) : string;
   function CommaText(aList : TStringList) : string;
   {$IFDEF MSWINDOWS}
   {$IFDEF MSWINDOWS}
@@ -1180,6 +1182,22 @@ begin
   end;
   end;
 end;
 end;
 
 
+function StreamToString(stream : TStream) : string;
+var
+  ss : TStringStream;
+begin
+  if stream = nil then Exit;
+  ss := TStringStream.Create;
+  try
+    stream.Seek(0,soBeginning);
+    ss.CopyFrom(stream,stream.Size);
+    Result := ss.DataString;
+  finally
+    ss.Free;
+  end;
+end;
+
+
 function CommaText(aList : TStringList) : string;
 function CommaText(aList : TStringList) : string;
 var
 var
   value : string;
   value : string;