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

FindPropInfo

Return property information by property name.

Declaration

Source position: typinfo.pp line 1165

function FindPropInfo(

  Instance: TObject;

  const PropName: string

):PPropInfo;

function FindPropInfo(

  Instance: TObject;

  const PropName: string;

  AKinds: TTypeKinds

):PPropInfo;

function FindPropInfo(

  AClass: TClass;

  const PropName: string

):PPropInfo;

function FindPropInfo(

  AClass: TClass;

  const PropName: string;

  AKinds: TTypeKinds

):PPropInfo;

Description

FindPropInfo examines the published property information of a class and returns a pointer to the property information for property PropName. The class to be examined can be specified in one of two ways:

AClass
a class pointer.
Instance
an instance of the class to be investigated.

If the property does not exist, a EPropertyError exception will be raised. The GetPropInfo function has the same function as the FindPropInfo function, but returns Nil if the property does not exist.

Errors

Specifying an invalid property name in PropName will result in an EPropertyError exception.

See also

GetPropInfo

  

Return property type information, by property name.

GetPropList

  

Return a list of a certain type of published properties.

GetPropInfos

  

Return a list of published properties.

Example

Program example13;

{ This program demonstrates the FindPropInfo function }

{$mode objfpc}

uses
  rttiobj,typinfo,sysutils;


Var
  O : TMyTestObject;
  PT : PTypeData;
  PI : PPropInfo;
  I,J : Longint;
  PP : PPropList;
  prI : PPropInfo;

begin
  O:=TMyTestObject.Create;
  PI:=FindPropInfo(O,'BooleanField');
  Writeln('FindPropInfo(Instance,BooleanField) : ',PI^.Name);
  PI:=FindPropInfo(O.ClassType,'ByteField');
  Writeln('FindPropInfo(Class,ByteField)       : ',PI^.Name);
  Write  ('FindPropInfo(Class,NonExistingProp) : ');
  Try
    PI:=FindPropInfo(O,'NonExistingProp');
  except
    On E: Exception do
      Writeln('Caught exception "',E.ClassName,'" with message : ',E.Message);
  end;
  O.Free;
end.

Documentation generated on: Nov 23 2024