SetToString function
Convert set to a string description.
Declaration
function SetToString(TypeInfo: PTypeInfo; Value: LongInt;
Brackets: Boolean): stringDescription
SetToString takes an integer representation of a set (as received e.g.
by
GetOrdProp) and turns it into a string representing the elements in
the set, based on the type information found in the
PropInfo property
information. By default, the string representation is not surrounded by
square brackets. Setting the
Brackets parameter to
True will
surround the string representation with brackets.
The function returns the string representation of the set.
Errors
No checking is done to see whether
PropInfo points to valid property
information.
See also
Example: ex18
program example18;
{ This program demonstrates the SetToString function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
PI : PPropInfo;
I : longint;
begin
O:=TMyTestObject.Create;
PI:=GetPropInfo(O,'SetField');
O.SetField:=[mefirst,meSecond,meThird];
I:=GetOrdProp(O,PI);
Writeln('Set property to string : ');
Writeln('Value : ',SetToString(PI,I,False));
O.SetField:=[mefirst,meSecond];
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,True));
I:=StringToSet(PI,'mefirst');
SetOrdProp(O,PI,I);
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,False));
I:=StringToSet(PI,'[mesecond,methird]');
SetOrdProp(O,PI,I);
I:=GetOrdProp(O,PI);
Writeln('Value : ',SetToString(PI,I,True));
O.Free;
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
