Unit 'TypInfo' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#rtl]

SetToString

Convert set to a string description.

Declaration

Source position: typinfo.pp line 1327

function SetToString(

  TypeInfo: PTypeInfo;

  Value: LongInt;

  Brackets: Boolean

):string;

function SetToString(

  PropInfo: PPropInfo;

  Value: LongInt;

  Brackets: Boolean

):string;

function SetToString(

  PropInfo: PPropInfo;

  Value: LongInt

):string;

function SetToString(

  TypeInfo: PTypeInfo;

  Value: Pointer;

  Brackets: Boolean = False

):string;

function SetToString(

  PropInfo: PPropInfo;

  Value: Pointer;

  Brackets: Boolean = False

):string;

Description

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

GetEnumName

  

Return name of enumeration constant.

GetEnumValue

  

Get ordinal value for enumerated type by name.

StringToSet

  

Convert string description to a set.

Example

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.

Documentation generated on: Oct 27 2024