t2t-soft

The following code demonstrated the conversion of a generic Delphi type to C++.


type
   TPair<TKey,TValue> = class   // declares TPair type with two type parameters
   private
     FKey: TKey;
     FValue: TValue;
   public
     function GetKey: TKey;
     procedure SetKey(key: TKey);
     function GetValue: TValue;
     procedure SetValue(Value: TValue);
     property key: TKey Read GetKey Write SetKey;
     property Value: TValue Read GetValue Write SetValue;
   end;

 type
   TSIPair = TPair<String,Integer>; // declares instantiated type
   TSSPair = TPair<String,String>;  // declares with other data types
   TISPair = TPair<Integer,String>;
   TIIPair = TPair<Integer,Integer>;
   TSXPair = TPair<String,TXMLNode>;

implementation

function TPair<TKey,TValue>.GetValue: TValue;
 begin
   Result := FValue;
 end;

-&gt;


// declares TPair type with two type parameters
template<typename TKey, typename TValue>
class TPair : public System::TObject
{
public:
  typedef System::TObject inherited;  
private:
  TKey FKey;
  TValue FValue;
public:
  TKey GetKey() const;
  void SetKey(TKey key);
  TValue GetValue() const;
  void SetValue(TValue Value);
  /*property key : TKey read GetKey write SetKey;*/
  TKey ReadPropertykey() const { return GetKey();}
  void WritePropertykey(TKey key){SetKey(key);}
  /*property Value : TValue read GetValue write SetValue;*/
  TValue ReadPropertyValue() const { return GetValue();}
  void WritePropertyValue(TValue Value){SetValue(Value);}
  TPair() {}
};
typedef TPair<System::String, int> TSIPair; // declares instantiated type
typedef TPair<System::String, System::String> TSSPair;  // declares with other data types
typedef TPair<int, System::String> TISPair;
typedef TPair<int, int> TIIPair;
typedef TPair<System::String, TXMLNode> TSXPair;



template<typename TKey, typename TValue>
TValue TPair<TKey, TValue>::GetValue() const
{
  TValue result;
  result = FValue;
  return result;
}



   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