title: Change Variant property-names (Delphi)
body: <p>I'm learning a great framework mORMot for Delphi, and I found plenty of useful functions to handle with <code>Variant</code> (in SynCommons).</p>
  
  <p>Now I want to change some property-names of a <code>Variant</code>, but after a search I have not found such a function, so I decide to write one:</p>
  
  <pre><code>program Project7;
  
  {$APPTYPE CONSOLE}
  
  {$R *.res}
  
  uses
    System.SysUtils, SynCommons;
  
  function VariantChangeNames(var V: Variant; const FromNames, ToNames: TRawUTF8DynArray): Boolean;
  var
    Name: RawUTF8;
    PData: PDocVariantData;
    Val: Variant;
    i, k: Integer;
  begin
    Result := False;
    PData := DocVariantData(V);
    i := 0;
    for Name in FromNames do
    begin
      k := PData^.GetValueIndex(Name);
      if k &lt;&gt; -1 then
      begin
        Val := PData^.Value[k];
        PData^.Value[ToNames[i]] := Val;
        PData^.Delete(k); // If delete before setting value, Val will be incorrect.
        Result := True;
      end;
      Inc(i);
    end;
  end;
  
  var
    V: Variant;
  begin
    V := TDocVariant.New();
    V.Name := 'John';
    V.Age := 20;
    VariantChangeNames(V, ['Name'], ['RealName']);
    Writeln(VariantToString(V)); // {"Age":20,"RealName":"John"}
  end.
  </code></pre>
  
  <p><code>VariantChangeNames</code> I wrote may not be very efficient since it needs to do both <code>delete</code> and <code>add</code>. It seems that directly modify the <code>VName</code> member of the <code>TDocVariantData</code> is the most efficient way, but it's a private member.</p>
  
  <p>Any advice? Thanks in advance.</p>
  
  <p>BTW: The mail server of mORMot official forum seems to have a problem, when I post a topic, it shows:</p>
  
  <pre><code>An error was encountered
  Error: Could not connect to smtp host "217.70.184.11" (111) (Connection refused).
  </code></pre>