t2t-soft

Die Formatierungsroutinen machen einen erheblichen Teil der SysUtils-Einheit aus. Einige davon sind verschachtelt und bestehen aus etwa 1000 Codezeilen. Dennoch funktioniert der übersetzte Code nahezu perfekt.


#include "pch.h"

#include "d7_formatting.h"
#include "System.SysUtils.h"
#include "d2c_sysvariant.h"
#include "d2c_openarray.h"
#include "OnLeavingScope.h"

using namespace std;
using namespace d2c_system;
using namespace System;
using namespace System::Sysutils;

namespace D7_formatting
{

bool CheckBuildMessage()
{
  bool result = false;
  String MessageText;
  MessageText = Format(L"Build %s produced %d artifacts", ArrayOfConst(String(L"linux-x64"), 18));
  result = MessageText == L"Build linux-x64 produced 18 artifacts";
  return result;
}

bool CheckIdentifierLayout()
{
  bool result = false;
  result = true;
  if(Format(L"ID-%6.4d", ArrayOfConst(73)) != L"ID-  0073")
    result = false;
  if(Format(L"HEX-%4.4x", ArrayOfConst(0x2A)) != L"HEX-002A")
    result = false;
  if(Format(L"%1:s/%0:s/%1:s", ArrayOfConst(String(L"source"), String(L"target"))) != L"target/source/target")
    result = false;
  return result;
}

bool CheckFloatingPointText()
{
  bool result = false;
  TFormatSettings SavedSettings = {};
  double Measurement = 0.0;
  SavedSettings = FormatSettings;
  {
    auto olsLambda = onLeavingScope([&] 
    {
      FormatSettings = SavedSettings;
    });
    FormatSettings.DecimalSeparator = L',';
    FormatSettings.ThousandSeparator = L'.';
    Measurement = 4312.24;
    result = true;
    if(FloatToStr(12.5L) != L"12,5")
      result = false;
    if(FloatToStr(1E40L) != L"1E40")
      result = false;
    if(FormatFloat(L"#,##0.00", Measurement) != L"4.312,24")
      result = false;
    if(FormatFloat(L"000000", Measurement) != L"004312")
      result = false;
    if(FormatFloat(L"0.000", Measurement) != L"4312,240")
      result = false;
    if(FormatFloat(L"0.000E+00", Measurement) != L"4,312E+03")
      result = false;
    if(FormatFloat(L"0.0 \"up\";0.0 \"down\"", -Measurement) != L"4312,2 down")
      result = false;
    if(FormatFloat(L"0.0;-0.0;\"idle\"", 0.0L) != L"idle")
      result = false;
  }
  return result;
}

bool RunFormattingChecks()
{
  bool result = false;
  result = true;
  if(!CheckBuildMessage())
    result = false;
  if(!CheckIdentifierLayout())
    result = false;
  if(!CheckFloatingPointText())
    result = false;
  return result;
}

}  // namespace D7_formatting

Der Code wurde generiert aus:


unit d7_formatting;
    
interface

function RunFormattingChecks: Boolean;

implementation

uses
  System.SysUtils;

function CheckBuildMessage: Boolean;
var
  MessageText: string;
begin
  MessageText := Format('Build %s produced %d artifacts',
    ['linux-x64', 18]);

Result := MessageText =
'Build linux-x64 produced 18 artifacts';
end;

function CheckIdentifierLayout: Boolean;
begin
  Result := True;

if Format('ID-%6.4d', [73]) <> 'ID- 0073' then
Result := False;

if Format('HEX-%4.4x', [$2A]) <> 'HEX-002A' then
Result := False;

if Format('%1:s/%0:s/%1:s', ['source', 'target']) <>
'target/source/target' then
Result := False;
end;

function CheckFloatingPointText: Boolean;
var
  SavedSettings: TFormatSettings;
  Measurement: Double;
begin
  SavedSettings := FormatSettings;
  try
    FormatSettings.DecimalSeparator := ',';
    FormatSettings.ThousandSeparator := '.';
    Measurement := 4312.24;

    Result := True;

    if FloatToStr(12.5) <> '12,5' then
      Result := False;

    if FloatToStr(1E40) <> '1E40' then
      Result := False;

    if FormatFloat('#,##0.00', Measurement) <> '4.312,24' then
      Result := False;

    if FormatFloat('000000', Measurement) <> '004312' then
      Result := False;

    if FormatFloat('0.000', Measurement) <> '4312,240' then
      Result := False;

    if FormatFloat('0.000E+00', Measurement) <> '4,312E+03' then
      Result := False;

    if FormatFloat('0.0 "up";0.0 "down"', -Measurement) <>
      '4312,2 down' then
      Result := False;

    if FormatFloat('0.0;-0.0;"idle"', 0) <> 'idle' then
      Result := False;
  finally
    FormatSettings := SavedSettings;
  end;
end;

function RunFormattingChecks: Boolean;
begin
  Result := True;

  if not CheckBuildMessage then
    Result := False;

  if not CheckIdentifierLayout then
    Result := False;

  if not CheckFloatingPointText then
    Result := False;
end;

end.



   English English


 
Letzte Neuigkeiten
01.09.26
Delphi2Cpp 2.8.0: Wartungsupdate mit Fehlerkorrekturen und Verbesserungen [more...]
18.05.26
Delphi2Cpp 2.7: Übersetzungsheuristiken [more...]



"die Projekte haben wir erfolgreich beendet, die Anwendungen laufen (zum überwiegenden Teil) bereits bei unseren Kunden."


ProCom AUTOMATION 26.05.2026



[aus Fallstudie...]

"Eine Meisterleistung -- Delphi2Cpp hat alle meine Erwartungen weit übertroffen."


Tony Hürlimann
virtual-optima 29.08.2011



"Ich muss mich nochmal für deinen Einsatz und die Qualität deiner Arbeit bedanken, das ist absolut überdurchschnittlich ..."


Gerald Ebner


 
Diese Homepage ist aus einfachen Texten mit [Minimal Website] generiert.

Minimal Website
 
Minimal Website ist mit Hilfe des TextTransformers hergestellt.

TextTransformer
 
Der TextTransformer ist gemacht mit dem Borland C++Builder

  Borland