t2t-soft

There is no counterpart to class/record helpers in C++. However it is possible to translate Delphi code using class helpers to C++. This is demonstrated at the following example:

TStringsHelper = class Helper for TBase
private 
  function GetTheObject(const AString: String): TObject; 
  procedure SetTheObject(const AString: String; const Value: TObject); 
public 
  property ObjectFor[const AString : String]: TObject Read GetTheObject Write SetTheObject; 
end;

becomes with Delphi2Cpp 2.x for C++Builder to

class TStringsHelper
{
  public:
  TStringsHelper(TBase* xpClass) : m_pClass(xpClass) {}
private:
  TObject* __fastcall GetTheObject(const String& AString);
  void __fastcall SetTheObject(String& AString, TObject* Value);
public:
  __property TObject* ObjectFor[const String& AString] = { read = GetTheObject, write = SetTheObject };
private:
  TBase* m_pClass;
};

Of course, for other compilers than C++Builder the properties become setter and getter functions. If S is an instance of TBase, an assignment of a TObject like:

S.ObjectFor['a'] := Object;

becomes to:

TStringsHelper(s).ObjectFor[L"a"] = Object;


The trick is, that functions calls of the helper class are redirected to calls of the helped class inside of a local instance of the helper class. For example the setter method of TStringHelper might look like:


void __fastcall TStringsHelper::SetTheObject(String& AString, TObject* Value)
{
  int idx = 0;
  idx = m_pClass->IndexOf(AString);
  if(idx >- 1)
    m_pClass->Objects[idx] = Value;
}



   deutsch Deutsch


 
Latest News
05/18/26
Delphi2Cpp 2.7: Translation heuristics [more...]

11/18/25
Delphi2Cpp 2.6: Delphi Interfaces [more...]



"We have successfully completed the projects, and the applications are (for the most part) already running at our customers' sites."





"Thanks for your great work, really appreciate the work you have done on zlib and compiling ... test case."


Mattewada, Udayabhaskar
Nokia India 02/01/2021




[from case study...]

"A masterpiece -- Delphi2Cpp has exceeded all my expectations by far."


Tony Hürlimann
virtual-optima 08/20/2011



"First off, I have to say WOW! Delphi2Cpp is doing a *fantastic* job!"


Daniel Flower
linkrealms 01/15/2011



"Though we have not finished the conversion yet, I'm glad that we've found you and could transform Eurocap to C++ with the help of Delphi2CB and you. (And I'm also glad that we could help you to make Delphi2CB better😉)"


Gáspár Huba


 
This website is generated from plain text with [Minimal Website]

Minimal Website
 
Minimal Website is made with TextTransformer

TextTransformer
 
TextTransformer is made with Borland C++Builder

  Borland