Browse Source

Merge branch 'develop'

Unknown 6 years ago
parent
commit
3a93767e75
5 changed files with 40 additions and 10 deletions
  1. 4 3
      Quick.Azure.pas
  2. 18 0
      Quick.Commons.pas
  3. 5 1
      Quick.Console.pas
  4. 0 1
      Quick.Json.Serializer.pas
  5. 13 5
      Quick.Value.pas

+ 4 - 3
Quick.Azure.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2015-2017 Kike Pérez
+  Copyright (c) 2015-2019 Kike Pérez
 
 
   Unit        : Quick.Azure
   Unit        : Quick.Azure
   Description : Azure blobs operations
   Description : Azure blobs operations
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.2
   Version     : 1.2
   Created     : 27/08/2015
   Created     : 27/08/2015
-  Modified    : 13/09/2017
+  Modified    : 11/03/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -281,7 +281,8 @@ begin
     try
     try
       BlobService.Timeout := fTimeout;
       BlobService.Timeout := fTimeout;
       Content := FileToArray(cFilename);
       Content := FileToArray(cFilename);
-      if azBlobName = '' then blobname := cFilename;
+      if azBlobName = '' then blobname := cFilename
+        else blobname := azBlobName;
       if blobname.StartsWith('/') then blobname := Copy(blobname,2,Length(blobname));
       if blobname.StartsWith('/') then blobname := Copy(blobname,2,Length(blobname));
       Result := BlobService.PutBlockBlob(container,blobname,Content,EmptyStr,nil,nil,CloudResponseInfo);
       Result := BlobService.PutBlockBlob(container,blobname,Content,EmptyStr,nil,nil,CloudResponseInfo);
       azResponseInfo := GetResponseInfo(CloudResponseInfo);
       azResponseInfo := GetResponseInfo(CloudResponseInfo);

+ 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;

+ 5 - 1
Quick.Console.pas

@@ -1064,7 +1064,11 @@ InitCriticalSection(CSConsole);
   {$IFNDEF DELPHILINUX}
   {$IFNDEF DELPHILINUX}
   InitializeCriticalSection(CSConsole);
   InitializeCriticalSection(CSConsole);
   //init stdout if not a service
   //init stdout if not a service
-  if GetStdHandle(STD_OUTPUT_HANDLE) <> 0 then InitConsole;
+  try
+    if GetStdHandle(STD_OUTPUT_HANDLE) <> 0 then InitConsole;
+  except
+    //avoid raise exception
+  end;
   {$ELSE}
   {$ELSE}
   CSConsole := TRTLCriticalSection.Create;
   CSConsole := TRTLCriticalSection.Create;
   {$ENDIF}
   {$ENDIF}

+ 0 - 1
Quick.Json.Serializer.pas

@@ -844,7 +844,6 @@ end;
 function TRTTIJson.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
 function TRTTIJson.GetPropertyValue(Instance : TObject; const PropertyName : string) : TValue;
 var
 var
   pinfo : PPropInfo;
   pinfo : PPropInfo;
-  enum : Integer;
 begin
 begin
   Result := nil;
   Result := nil;
   pinfo := GetPropInfo(Instance,PropertyName);
   pinfo := GetPropInfo(Instance,PropertyName);

+ 13 - 5
Quick.Value.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.4
   Version     : 1.4
   Created     : 07/01/2019
   Created     : 07/01/2019
-  Modified    : 24/01/2019
+  Modified    : 11/03/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -213,7 +213,7 @@ type
     function CastToDateTime : TDateTime;
     function CastToDateTime : TDateTime;
     function CastToObject: TObject;
     function CastToObject: TObject;
     function CastToPointer: Pointer;
     function CastToPointer: Pointer;
-    function CastToInterface: Pointer;
+    function CastToInterface: IInterface;
     function CastToVariant: Variant;
     function CastToVariant: Variant;
     function CastToCardinal : Cardinal;
     function CastToCardinal : Cardinal;
     procedure SetAsString(const Value : string);
     procedure SetAsString(const Value : string);
@@ -231,6 +231,7 @@ type
     procedure SetAsDateTime(const Value : TDateTime);
     procedure SetAsDateTime(const Value : TDateTime);
     procedure SetAsVariant(const Value: Variant);
     procedure SetAsVariant(const Value: Variant);
     procedure SetAsCardinal(const Value : Cardinal);
     procedure SetAsCardinal(const Value : Cardinal);
+    procedure SetAsInterface(const Value: IInterface);
   public
   public
     constructor Create(const Value: TVarRec);
     constructor Create(const Value: TVarRec);
     property DataType : TValueDataType read fDataType;
     property DataType : TValueDataType read fDataType;
@@ -245,7 +246,7 @@ type
     property AsBoolean : Boolean read CastToBoolean write SetAsBoolean;
     property AsBoolean : Boolean read CastToBoolean write SetAsBoolean;
     property AsPointer : Pointer read CastToPointer write SetAsPointer;
     property AsPointer : Pointer read CastToPointer write SetAsPointer;
     property AsClass : TClass read CastToClass write SetAsClass;
     property AsClass : TClass read CastToClass write SetAsClass;
-    property AsInterface : Pointer read CastToInterface write SetAsPointer;
+    property AsInterface : IInterface read CastToInterface write SetAsInterface;
     property AsObject : TObject read CastToObject write SetAsObject;
     property AsObject : TObject read CastToObject write SetAsObject;
     property AsVariant : Variant  read CastToVariant write SetAsVariant;
     property AsVariant : Variant  read CastToVariant write SetAsVariant;
     property AsCardinal : Cardinal read CastToCardinal write SetAsCardinal;
     property AsCardinal : Cardinal read CastToCardinal write SetAsCardinal;
@@ -515,12 +516,13 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TFlexValue.CastToInterface: Pointer;
+function TFlexValue.CastToInterface: IInterface;
 begin
 begin
   try
   try
     case fDataType of
     case fDataType of
       dtNull : Result := nil;
       dtNull : Result := nil;
-      dtInterface : Result := IInterface(fDataIntf);
+      dtInterface : Result := fDataIntf;
+      dtPointer : Result := IInterface(fDataIntf);
       else raise Exception.Create('DataType not supported');
       else raise Exception.Create('DataType not supported');
     end;
     end;
   except
   except
@@ -720,6 +722,12 @@ begin
   fDataType := TValueDataType.dtInteger;
   fDataType := TValueDataType.dtInteger;
 end;
 end;
 
 
+procedure TFlexValue.SetAsInterface(const Value: IInterface);
+begin
+  fDataIntf := Value;
+  fDataType := TValueDataType.dtInterface;
+end;
+
 procedure TFlexValue.SetAsObject(const Value: TObject);
 procedure TFlexValue.SetAsObject(const Value: TObject);
 begin
 begin
   Clear;
   Clear;