Top  Previous  Next

What is translated > Sets


A Delphi set is simulated in the C++ VCL by the class Set:


template<class T, unsigned char minEl, unsigned char maxEl>

class __declspec(delphireturn) Set;


This set class is part of the CBuilder VCL. Users of other compilers can use the emulation of Delphi set's in "DelphiSets.h" in the Source folder of the Delphi2Cpp installation. This file is a contribution from Daniel Flower. The set type "System::Set" can be renamed to TSet, be means of the list of substitutions of the translator.


The use of set's is translated as follows:



MySet: set of 'a'..'z';




System::Set <  char/* range 'a'..'z'*/, 97, 122 > MySet;




type TIntSet = set of 1..250; 




typedef System::Set <  int/* range 1..250*/, 1, 250 > TIntSet;



If there is no explicit type-declaration of a set, as e.g. in:


MySet := ['a','b','c'];


a helping macro and a helping type is created:


   typedef System::Set <  char, 97, 122 > test__0;

   #define test__1 ( test__0 () 

      << char ( 97 ) << char ( 98 ) << char ( 99 ) )


MySet = test__1;


The names of such helping types can be adjusted to according names in the C++ Builder VCL by means of the list of substitutions of the translator.

If a temporary set of values is passed as open array parameter to a function, a corresponding array is produced in the C++ output, which is put in front of the function call.




This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content