Chapter 23
The TYPINFO unit

The TypeInfo unit contains many routines which can be used for the querying of the Run-Time Type Information (RTTI) which is generated by the compiler for classes that are compiled under the {$M+} switch. This information can be used to retrieve or set property values for published properties for totally unknown classes. In particular, it can be used to stream classes. The TPersistent class in the Classes unit is compiled in the {$M+} state and serves as the base class for all classes that need to be streamed.

The unit should be compatible to the Delphi 5 unit with the same name. The only calls that are still missing are the Variant calls, since Free Pascal does not support the variant type yet.

The examples in this chapter use a rttiobj file, which contains an object that has a published property of all supported types. It also contains some auxiliary routines and definitions.


 23.1 Constants, Types and variables
   Constants
   types
 23.2 Function list by category
   Examining published property information
   Getting or setting property values
   Auxiliary functions
 23.3 Functions and Procedures
   FindPropInfo
   GetEnumName
   GetEnumProp
   GetEnumValue
   GetFloatProp
   GetInt64Prop
   GetMethodProp
   GetObjectProp
   GetObjectPropClass
   GetOrdProp
   GetPropInfo
   GetPropInfos
   GetPropList
   GetPropValue
   GetSetProp
   GetStrProp
   GetTypeData
   GetVariantProp
   IsPublishedProp
   IsStoredProp
   PropIsType
   PropType
   SetEnumProp
   SetFloatProp
   SetInt64Prop
   SetMethodProp
   SetObjectProp
   SetOrdProp
   SetPropValue
   SetSetProp
   SetStrProp
   SetToString
   SetVariantProp
   StringToSet