1
<?xml version="1.0" encoding="ISO8859-1"?>
5
$Id: typinfo.xml,v 1.5 2005/05/07 09:41:09 michael Exp $
6
This file is part of the FPC documentation.
7
Copyright (C) 1997, by Michael Van Canneyt
9
The FPC documentation is free text; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public License as
11
published by the Free Software Foundation; either version 2 of the
12
License, or (at your option) any later version.
14
The FPC Documentation is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with the FPC documentation; see the file COPYING.LIB. If not,
21
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
Boston, MA 02111-1307, USA.
25
<module name="typinfo">
26
<short>Access Run-Time Type Information (RTTI)</short>
27
<!-- \FPCexampledir{typinfex} -->
30
The <file>TypeInfo</file> unit contains many routines which can be used for
31
the querying of the Run-Time Type Information (RTTI) which is generated
32
by the compiler for classes that are compiled under the <var>{$M+}</var>
33
switch. This information can be used to retrieve or set property values
34
for published properties for totally unknown classes. In particular, it
35
can be used to stream classes. The <var>TPersistent</var> class in the
36
<file>Classes</file> unit is compiled in the <var>{$M+}</var> state and serves
37
as the base class for all classes that need to be streamed.
40
The unit should be compatible to the Delphi 5 unit with the same name.
41
The only calls that are still missing are the Variant calls, since Free Pascal
42
does not support the variant type yet.
45
The examples in this chapter use a <file>rttiobj</file> file, which contains
46
an object that has a published property of all supported types. It also
47
contains some auxiliary routines and definitions.
51
<topic name="ExaminePropInfo">
52
<short>Examining published property information</short>
55
Functions for retrieving or examining property information
58
<th><td>Name</td><td>Description</td></th>
59
<tr><td><link id="FindPropInfo"/></td><td>Getting property type information, With error checking.</td></tr>
60
<tr><td><link id="GetPropInfo"/></td><td>Getting property type information, No error checking.</td></tr>
61
<tr><td><link id="GetPropInfos"/></td><td>Find property information of a certain kind</td></tr>
62
<tr><td><link id="GetObjectPropClass"/></td><td>Return the declared class of an object property </td></tr>
63
<tr><td><link id="GetPropList"/></td><td>Get a list of all published properties</td></tr>
64
<tr><td><link id="IsPublishedProp"/></td><td>Is a property published</td></tr>
65
<tr><td><link id="IsStoredProp"/></td><td>Is a property stored</td></tr>
66
<tr><td><link id="PropIsType"/></td><td>Is a property of a certain kind</td></tr>
67
<tr><td><link id="PropType"/></td><td>Return the type of a property</td></tr>
72
<topic name="ManipulatePropValues">
73
<short>Getting or setting property values</short>
76
Functions to set or set a property's value.
79
<th><td>Name</td><td>Description</td></th>
80
<tr><td><link id="GetEnumProp"/></td><td>Return the value of an enumerated type property</td></tr>
81
<tr><td><link id="GetFloatProp"/></td><td>Return the value of a float property</td></tr>
82
<tr><td><link id="GetInt64Prop"/></td><td>Return the value of an Int64 property</td></tr>
83
<tr><td><link id="GetMethodProp"/></td><td>Return the value of a procedural type property</td></tr>
84
<tr><td><link id="GetObjectProp"/></td><td>Return the value of an object property</td></tr>
85
<tr><td><link id="GetOrdProp"/></td><td>Return the value of an ordinal type property</td></tr>
86
<tr><td><link id="GetPropValue"/></td><td>Return the value of a property as a variant</td></tr>
87
<tr><td><link id="GetSetProp"/></td><td>Return the value of a set property</td></tr>
88
<tr><td><link id="GetStrProp"/></td><td>Return the value of a string property</td></tr>
89
<tr><td><link id="GetVariantProp"/></td><td>Return the value of a variant property</td></tr>
90
<tr><td><link id="SetEnumProp"/></td><td>Set the value of an enumerated type property</td></tr>
91
<tr><td><link id="SetFloatProp"/></td><td>Set the value of a float property</td></tr>
92
<tr><td><link id="SetInt64Prop"/></td><td>Set the value of an Int64 property</td></tr>
93
<tr><td><link id="SetMethodProp"/></td><td>Set the value of a procedural type property</td></tr>
94
<tr><td><link id="SetObjectProp"/></td><td>Set the value of an object property</td></tr>
95
<tr><td><link id="SetOrdProp"/></td><td>Set the value of an ordinal type property</td></tr>
96
<tr><td><link id="SetPropValue"/></td><td>Set the value of a property trhough a variant</td></tr>
97
<tr><td><link id="SetSetProp"/></td><td>Set the value of a set property</td></tr>
98
<tr><td><link id="SetStrProp"/></td><td>Set the value of a string property</td></tr>
99
<tr><td><link id="SetVariantProp"/></td><td>Set the value of a variant property</td></tr>
104
<topic name="AuxiliaryTypinfo">
105
<short>Auxiliary functions</short>
108
Other typinfo related functions.
111
<th><td>Name</td><td>Description</td></th>
112
<tr><td><link id="GetEnumName"/></td><td>Get an enumerated type element name</td></tr>
113
<tr><td><link id="GetEnumValue"/></td><td>Get ordinal number of an enumerated tye, based on the name.</td></tr>
114
<tr><td><link id="GetTypeData"/></td><td>Skip type name and return a pointer to the type data</td></tr>
115
<tr><td><link id="SetToString"/></td><td>Convert a set to its string representation</td></tr>
116
<tr><td><link id="StringToSet"/></td><td>Convert a string representation of a set to a set</td></tr>
122
<element name="BooleanIdents">
123
<short>Names for boolean values</short>
126
<element name="DotSep">
127
<short>Name separator character</short>
130
<element name="ptField">
131
<short>Property acces directly from field</short>
134
<element name="ptStatic">
135
<short>Property acces via static method</short>
138
<element name="ptVirtual">
139
<short>Property acces via virtual method</short>
142
<element name="ptConst">
143
<short>Constant used in acces method</short>
146
<element name="tkAny">
147
<short>Any property type</short>
150
<element name="tkMethods">
151
<short>Only method properties. (event handlers)</short>
154
<element name="tkProperties">
155
<short>Real properties. (not methods)</short>
158
<element name="PShortString">
159
<short>Pointer to shortstring</short>
162
<element name="PByte">
163
<short>Pointer to byte</short>
166
<element name="PWord">
167
<short>Pointer to Word</short>
170
<element name="PLongint">
171
<short>Pointer to longint</short>
174
<element name="PBoolean">
175
<short>Pointer to boolean</short>
178
<element name="PSingle">
179
<short>Pointer to single</short>
182
<element name="PDouble">
183
<short>Pointer to double</short>
186
<element name="PExtended">
187
<short>Pointer to extended</short>
190
<element name="PComp">
191
<short>Pointer to comp</short>
194
<element name="PFixed16">
195
<short>Pointer to Fixed16</short>
198
<element name="Variant">
199
<short>Dummy type. Do not use.</short>
202
<element name="TTypeKind">
203
<short>Type of a property.</short>
206
<element name="tkString">
207
<short>Alias for the <var>tsSString</var> enumeration value</short>
211
<element name="TTypeKind.tkUnknown">
212
<short>Unknown property type.</short>
215
<element name="TTypeKind.tkInteger">
216
<short>Integer property.</short>
219
<element name="TTypeKind.tkChar">
220
<short>Char property.</short>
223
<element name="TTypeKind.tkEnumeration">
224
<short>Enumeration type property.</short>
227
<element name="TTypeKind.tkFloat">
228
<short>Float property.</short>
231
<element name="TTypeKind.tkSet">
232
<short>Set property.</short>
235
<element name="TTypeKind.tkMethod">
236
<short>Method property.</short>
239
<element name="TTypeKind.tkSString">
240
<short>Shortstring property.</short>
243
<element name="TTypeKind.tkLString">
244
<short>Longstring property.</short>
247
<element name="TTypeKind.tkAString">
248
<short>Ansistring property.</short>
251
<element name="TTypeKind.tkWString">
252
<short>Widestring property.</short>
255
<element name="TTypeKind.tkVariant">
256
<short>Variant property.</short>
259
<element name="TTypeKind.tkArray">
260
<short>Array property.</short>
263
<element name="TTypeKind.tkRecord">
264
<short>Record property.</short>
267
<element name="TTypeKind.tkInterface">
268
<short>Interface property.</short>
271
<element name="TTypeKind.tkClass">
272
<short>Class property.</short>
275
<element name="TTypeKind.tkObject">
276
<short>Object property.</short>
279
<element name="TTypeKind.tkWChar">
280
<short>Widechar property.</short>
283
<element name="TTypeKind.tkBool">
284
<short>Boolean property.</short>
287
<element name="TTypeKind.tkInt64">
288
<short>Int64 property.</short>
291
<element name="TTypeKind.tkQWord">
292
<short>QWord property.</short>
295
<element name="TTypeKind.tkDynArray">
296
<short>Dynamical array property.</short>
299
<element name="TTypeKind.tkInterfaceRaw">
300
<short>Raw interface property.</short>
303
<element name="TTOrdType">
304
<short>Size and sign of ordinal property type.</short>
306
If the property is and ordinal type, then <var>TTOrdType</var> determines
307
the size and sign of the ordinal type:
311
<element name="TTOrdType.otSByte">
312
<short>Signed byte</short>
315
<element name="TTOrdType.otUByte">
316
<short>Unsigned byte</short>
319
<element name="TTOrdType.otSWord">
320
<short>Signed word</short>
323
<element name="TTOrdType.otUWord">
324
<short>Unsigned word</short>
327
<element name="TTOrdType.otSLong">
328
<short>Signed longint</short>
331
<element name="TTOrdType.otULong">
332
<short>Unsigned longing (Cardinal)</short>
335
<element name="TOrdType">
336
<short>Alias for <link id="#rtl.typinfo.TTordType">TTordType</link>.</short>
338
If the property is and ordinal type, then <var>TOrdType</var> determines
339
the size and sign of the ordinal type:
343
<element name="TOrdType.otSByte">
344
<short>Signed byte</short>
347
<element name="TOrdType.otUByte">
348
<short>Unsigned byte</short>
351
<element name="TOrdType.otSWord">
352
<short>Signed word</short>
355
<element name="TOrdType.otUWord">
356
<short>Unsigned word</short>
359
<element name="TOrdType.otSLong">
360
<short>Signed longint</short>
363
<element name="TOrdType.otULong">
364
<short>Unsigned longing (Cardinal)</short>
367
<element name="TFloatType">
368
<short>The size of a float type.</short>
371
<element name="TFloatType.ftSingle">
372
<short>Single-sized float</short>
375
<element name="TFloatType.ftDouble">
376
<short>Double-sized float</short>
379
<element name="TFloatType.ftExtended">
380
<short>Extended-size float</short>
383
<element name="TFloatType.ftComp">
384
<short>Comp-type float</short>
387
<element name="TFloatType.ftCurr">
388
<short>Currency-type float</short>
391
<element name="TFloatType.ftFixed16">
392
<short>16-bit float type</short>
395
<element name="TFloatType.ftFixed32">
396
<short>32-bit float type.</short>
399
<element name="TMethodKind">
400
<short>Method type description</short>
403
<element name="TMethodKind.mkProcedure">
404
<short>Procedure method.</short>
407
<element name="TMethodKind.mkFunction">
408
<short>Function method</short>
411
<element name="TMethodKind.mkConstructor">
412
<short>Class constructor</short>
415
<element name="TMethodKind.mkDestructor">
416
<short>Class Desctructor</short>
419
<element name="TMethodKind.mkClassProcedure">
420
<short>Class procedure</short>
423
<element name="TMethodKind.mkClassFunction">
424
<short>Class function</short>
427
<element name="TParamFlags">
428
<short>The kind of parameter for a method</short>
431
<element name="TParamFlags.pfVar">
432
<short>Parameter passed by reference</short>
435
<element name="TParamFlags.pfConst">
436
<short>Parameter passed as const (reference)</short>
439
<element name="TParamFlags.pfArray">
440
<short>Array parameter</short>
443
<element name="TParamFlags.pfAddress">
444
<short>Address is passed</short>
447
<element name="TParamFlags.pfReference">
448
<short>Reference passed</short>
451
<element name="TParamFlags.pfOut">
452
<short>Out (by reference)</short>
455
<element name="TIntfFlag">
456
<short>Type of interface.</short>
459
<element name="TIntfFlags">
460
<short>Set of <link id="TIntfFlag"/>.</short>
463
<element name="TIntfFlagsBase">
464
<short>Set of <link id="TIntfFlag"/>.</short>
467
<element name="TIntfFlag.ifHasGuid">
468
<short>Interface has GUID identifier</short>
471
<element name="TIntfFlag.ifDispInterface">
472
<short>Interface is a dual dispatch interface</short>
475
<element name="TIntfFlag.ifDispatch">
476
<short>Interface is a dispatch interface</short>
479
<element name="TTypeKinds">
480
<short>Set of <link id="TTypeKind"/> enumeration.</short>
483
<element name="TTypeInfo">
484
<short>Type information record</short>
487
The <var>TypeInfo</var> function returns a pointer to a <var>TTypeInfo</var>
491
Note that the Name field is stored with as much bytes as needed to store the name,
492
it is not padded to 255 characters.
493
The type data immediatly follows the <var>TTypeInfo</var> record as a <link
494
id="TTypeData"/> record.
499
<element name="TTypeInfo.Name">
500
<short>Type name</short>
503
<element name="TTypeInfo.Kind">
504
<short>Type kind</short>
507
<element name="PTypeInfo">
508
<short>Pointer to <link id="TTypeInfo"/> record</short>
510
<element name="PPTypeInfo">
511
<short>Pointer to <link id="PTypeInfo"/> pointer</short>
514
<element name="PTypeData">
515
<short>Pointer to <link id="TTypeData"/> record.</short>
518
<element name="TTypeData">
519
<short>Class properties type data record.</short>
522
If the typeinfo kind is <var>tkClass</var>, then the property
523
information follows the <var>UnitName</var> string, as an array of <link
524
id="TPropInfo"/> records.
529
<element name="TPropData">
530
<short>Property data record</short>
532
The <var>TPropData</var> record is not used, but is provided for completeness and
533
compatibility with Delphi.
537
<element name="PPropInfo">
538
<short>Pointer to <link id="TPropInfo"/> record</short>
541
<element name="TPropInfo">
542
<short>Record describing one published property of a class</short>
545
The <var>TPropInfo</var> record describes one published property of a class.
546
The property information of a class are stored as an array of
547
<var>TPropInfo</var> records.
550
The <var>Name</var> field is stored not with 255 characters, but with just as many characters
551
as required to store the name.
556
<element name="TPropInfo.PropType">
557
<short>Property type</short>
559
<element name="TPropInfo.GetProc">
560
<short>Read handler</short>
562
<element name="TPropInfo.SetProc">
563
<short>Write handler</short>
565
<element name="TPropInfo.StoredProc">
566
<short>Procedure pointer for stored keyword.</short>
568
<element name="TPropInfo.Index">
569
<short>Index for array properties</short>
571
<element name="TPropInfo.Default">
572
<short>Default value</short>
574
<element name="TPropInfo.NameIndex">
575
<short>Index for indexed properties</short>
577
<element name="TPropInfo.PropProcs">
578
<short>Flags describing property procedures.</short>
580
<element name="TPropInfo.Name">
581
<short>Property name</short>
584
<element name="TProcInfoProc">
585
<short>Property info callback method</short>
588
<element name="TPropList">
589
<short>Array of property information pointers</short>
592
<element name="PPropList">
593
<short>Pointer to <link id="TPropList"/></short>
596
<element name="EPropertyError">
597
<short>Exception raised in case of an error in one of the functions.</short>
600
<element name="FindPropInfo">
601
<short>Return property information by property name.</short>
604
<var>FindPropInfo</var> examines the published property information of a class and
605
returns a pointer to the property information for property <var>PropName</var>.
606
The class to be examined can be specified in one of two ways:
609
<dt>AClass</dt><dd> a class pointer.</dd>
610
<dt>Instance</dt><dd> an instance of the class to be investigated.</dd>
613
If the property does not exist, a <var>EPropertyError</var> exception will be
614
raised. The <link id="GetPropInfo"/> function has the same function as the
615
<var>FindPropInfo</var> function, but returns <var>Nil</var> if the property does not
620
Specifying an invalid property name in <var>PropName</var> will result in an
621
<var>EPropertyError</var> exception.
624
<link id="GetPropInfo"/>
625
<link id="GetPropList"/>
626
<link id="GetPropInfos"/>
628
<example file="typinfex/ex14"/>
632
<element name="GetEnumName">
633
<short>Return name of enumeration constant.</short>
636
<var>GetEnumName</var> scans the type information for the enumeration type
637
described by <var>TypeInfo</var> and returns the name of the enumeration
638
constant for the element with ordinal value equal to <var>Value</var>.
641
If <var>Value</var> is out of range, the first element of the enumeration type
642
is returned. The result is lowercased, but this may change in the future.
645
This can be used in combination with <var>GetOrdProp</var> to stream a property
646
of an enumerated type.
650
No check is done to determine whether <var>TypeInfo</var> really points to the
651
type information for an enumerated type.
654
<link id="GetOrdProp"/>
655
<link id="GetEnumValue"/>
657
<example file="typinfex/ex9"/>
661
<element name="GetEnumProp">
662
<short>Return the value of an enumeration type property.</short>
664
<var>GetEnumProp</var> returns the value of an property of an enumerated type
665
and returns the name of the enumerated value for the objetc <var>Instance</var>.
666
The property whose value must be returned can be specified by its property
667
info in <var>PropInfo</var> or by its name in <var>PropName</var>
670
No check is done to determine whether <var>PropInfo</var> really points to the
671
property information for an enumerated type.
672
Specifying an invalid property name in <var>PropName</var> will result in an
673
<var>EPropertyError</var> exception.
676
<link id="SetEnumProp"/>
677
<link id="GetOrdProp"/>
678
<link id="GetStrProp"/>
679
<link id="GetInt64Prop"/>
680
<link id="GetMethodProp"/>
681
<link id="GetSetProp"/>
682
<link id="GetObjectProp"/>
683
<link id="GetEnumProp"/>
685
<example file="typinfex/ex2"/>
689
<element name="GetEnumValue">
690
<short>Get ordinal value for enumerated type by name</short>
693
<var>GetEnumValue</var> scans the type information for the enumeration type
694
described by <var>TypeInfo</var> and returns the ordinal value for the element
695
in the enumerated type that has identifier <var>Name</var>. The identifier is
696
searched in a case-insensitive manner.
699
This can be used to set the value of enumerated properties from a stream.
702
For an example, see <link id="GetEnumName"/>.
706
If <var>Name</var> is not found in the list of enumerated values, then -1 is
707
returned. No check is done whether <var>TypeInfo</var> points to the type information
708
for an enumerated type.
711
<link id="GetEnumName"/>
712
<link id="SetOrdProp"/>
717
<element name="GetFloatProp">
718
<short>Return value of floating point property</short>
720
<var>GetFloatProp</var> returns the value of the float property described by
721
<var>PropInfo</var> or with name <var>Propname</var> for the object <var>Instance</var>.
722
All float types are converted
726
No checking is done whether <var>Instance</var> is non-nil, or whether
727
<var>PropInfo</var> describes a valid float property of <var>Instance</var>.
728
Specifying an invalid property name in <var>PropName</var> will result in an
729
<var>EPropertyError</var> exception.
732
<link id="SetFloatProp"/>
733
<link id="GetOrdProp"/>
734
<link id="GetStrProp"/>
735
<link id="GetInt64Prop"/>
736
<link id="GetMethodProp"/>
737
<link id="GetSetProp"/>
738
<link id="GetObjectProp"/>
739
<link id="GetEnumProp"/>
741
<example file="typinfex/ex4"/>
745
<element name="GetInt64Prop">
746
<short>return value of an Int64 property</short>
749
Publishing of Int64 properties is not yet supported by Free Pascal. This
750
function is provided for Delphi compatibility only at the moment.
753
<var>GetInt64Prop</var> returns the value of the property of type
754
<var>Int64</var> that is described by <var>PropInfo</var> or with name <var>Propname</var>
755
for the object <var>Instance</var>.
759
No checking is done whether <var>Instance</var> is non-nil, or whether
760
<var>PropInfo</var> describes a valid <var>Int64</var> property of <var>Instance</var>.
761
Specifying an invalid property name in <var>PropName</var> will result in an
762
<var>EPropertyError</var> exception
765
<link id="SetInt64Prop"/>
766
<link id="GetOrdProp"/>
767
<link id="GetStrProp"/>
768
<link id="GetFloatProp"/>
769
<link id="GetMethodProp"/>
770
<link id="GetSetProp"/>
771
<link id="GetObjectProp"/>
772
<link id="GetEnumProp"/>
774
<example file="typinfex/ex15"/>
778
<element name="GetMethodProp">
779
<short>Return value of a method property</short>
782
<var>GetMethodProp</var> returns the method the property described by
783
<var>PropInfo</var> or with name <var>Propname</var> for object <var>Instance</var>.
784
The return type <var>TMethod</var> is defined in the <file>SysUtils</file> unit as:
787
TMethod = packed record
792
<var>Data</var> points to the instance of the class with the method <var>Code</var>.
796
No checking is done whether <var>Instance</var> is non-nil, or whether
797
<var>PropInfo</var> describes a valid method property of <var>Instance</var>.
798
Specifying an invalid property name in <var>PropName</var> will result in an
799
<var>EPropertyError</var> exception.
802
<link id="SetMethodProp"/>
803
<link id="GetOrdProp"/>
804
<link id="GetStrProp"/>
805
<link id="GetFloatProp"/>
806
<link id="GetInt64Prop"/>
807
<link id="GetSetProp"/>
808
<link id="GetObjectProp"/>
809
<link id="GetEnumProp"/>
811
<example file="typinfex/ex6"/>
815
<element name="GetObjectProp">
816
<short>Return value of an object-type property.</short>
819
<var>GetObjectProp</var> returns the object which the property described by
820
<var>PropInfo</var> with name <var>Propname</var> points to for object <var>Instance</var>.
823
If <var>MinClass</var> is specified, then if the object is not descendent of
824
class <var>MinClass</var>, then <var>Nil</var> is returned.
828
No checking is done whether <var>Instance</var> is non-nil, or whether
829
<var>PropInfo</var> describes a valid method property of <var>Instance</var>.
830
Specifying an invalid property name in <var>PropName</var> will result in an
831
<var>EPropertyError</var> exception.
834
<link id="SetMethodProp"/>
835
<link id="GetOrdProp"/>
836
<link id="GetStrProp"/>
837
<link id="GetFloatProp"/>
838
<link id="GetInt64Prop"/>
839
<link id="GetSetProp"/>
840
<link id="GetObjectProp"/>
841
<link id="GetEnumProp"/>
843
<example file="typinfex/ex5"/>
847
<element name="GetObjectPropClass">
848
<short>Return class of property.</short>
851
<var>GetObjectPropClass</var> returns the declared class of the property with name
852
<var>PropName</var>. This may not be the actual class of the property value.
855
For an example, see <link id="GetObjectProp"/>.
859
No checking is done whether <var>Instance</var> is non-nil.
860
Specifying an invalid property name in <var>PropName</var> will result in an
861
<var>EPropertyError</var> exception.
864
<link id="SetMethodProp"/>
865
<link id="GetOrdProp"/>
866
<link id="GetStrProp"/>
867
<link id="GetFloatProp"/>
868
<link id="GetInt64Prop"/>
873
<element name="GetOrdProp">
874
<short>Get the value of an ordinal property</short>
877
<var>GetOrdProp</var> returns the value of the ordinal property described by
878
<var>PropInfo</var> or with name <var>PropName</var> for the object <var>Instance</var>.
879
The value is returned as a longint, which should be typecasted to the
883
Ordinal properties that can be retrieved include:
886
<dt>Integers and subranges of integers</dt>
887
<dd>The value of the integer will be returned.</dd>
888
<dt>Enumerated types and subranges of enumerated types</dt>
889
<dd>The ordinal value of the enumerated type will be returned.</dd>
891
<dd>If the base type of the set has less than 31 possible values.
892
If a bit is set in the return value, then the corresponding element of the
893
base ordinal class of the set type must be included in the set.
898
No checking is done whether <var>Instance</var> is non-nil, or whether
899
<var>PropInfo</var> describes a valid ordinal property of <var>Instance</var>
900
Specifying an invalid property name in <var>PropName</var> will result in an
901
<var>EPropertyError</var> exception.
904
<link id="SetOrdProp"/>
905
<link id="GetStrProp"/>
906
<link id="GetFloatProp"/>
907
<link id="GetInt64Prop"/>
908
<link id="GetMethodProp"/>
909
<link id="GetSetProp"/>
910
<link id="GetObjectProp"/>
911
<link id="GetEnumProp"/>
913
<example file="typinfex/ex1"/>
917
<element name="GetPropInfo">
918
<short>Return property type information, by property name.</short>
921
<var>GetPropInfo</var> returns a pointer to the <var>TPropInfo</var> record for a the
922
<var>PropName</var> property of a class. The class to examine can be specified
923
in one of three ways:
926
<dt>Instance</dt><dd> An instance of the class.</dd>
927
<dt>AClass</dt><dd> A class pointer to the class.</dd>
928
<dt>TypeInfo</dt><dd> A pointer to the type information of the class.</dd>
931
In each of these three ways, if <var>AKinds</var> is specified, if the property
932
has <var>TypeKind</var> which is not included in <var>Akinds</var>, <var>Nil</var> will be
936
For an example, see most of the other functions.
940
If the property <var>PropName</var> does not exist, <var>Nil</var> is returned.
943
<link id="GetPropInfos"/>
944
<link id="GetPropList"/>
949
<element name="GetPropInfos">
950
<short>Return a list of published properties.</short>
952
<var>GetPropInfos</var> stores pointers to the property information of all published
953
properties of a class with class info <var>TypeInfo</var> in the list pointed to by
954
<var>Proplist</var>. The <var>PropList</var> pointer must point to a memory location that
955
contains enough space to hold all properties of the class and its parent classes.
958
No checks are done to see whether <var>PropList</var> points to a memory area that
959
is big enough to hold all pointers.
962
<link id="GetPropInfo"/>
963
<link id="GetPropList"/>
965
<example file="typinfex/ex12"/>
969
<element name="GetPropList">
970
<short>Return a list of a certain type of published properties.</short>
973
<var>GetPropList</var> stores pointers to property information of the class with class
974
info <var>TypeInfo</var> for properties of kind <var>TypeKinds</var> in the list pointed to
975
by <var>Proplist</var>. <var>PropList</var> must contain enough space to hold all properties.
978
The function returns the number of pointers that matched the criteria and were stored
979
in <var>PropList</var>.
983
No checks are done to see whether <var>PropList</var> points to a memory area that is big enough
984
to hold all pointers.
987
<link id="GetPropInfos"/>
988
<link id="GetPropInfo"/>
990
<example file="typinfex/ex13"/>
994
<element name="GetPropValue">
995
<short>Get property value as a string.</short>
997
Due to missing <var>Variant</var> support, <var>GetPropValue</var> is not yet implemented.
998
The declaration is provided for compatibility with Delphi.
1006
<element name="GetSetProp">
1007
<short>Return the value of a set property.</short>
1010
<var>GetSetProp</var> returns the contents of a set property as a string.
1011
The property to be returned can be specified by it's name in <var>PropName</var>
1012
or by its property information in <var>PropInfo</var>.
1015
The returned set is a string representation of the elements in the set as
1016
returned by <link id="SetToString"/>. The <var>Brackets</var> option can be used to
1017
enclose the string representation in square brackets.
1021
No checking is done whether <var>Instance</var> is non-nil, or whether
1022
<var>PropInfo</var> describes a valid ordinal property of <var>Instance</var>
1023
Specifying an invalid property name in <var>PropName</var> will result in an
1024
<var>EPropertyError</var> exception.
1027
<link id="SetSetProp"/>
1028
<link id="GetStrProp"/>
1029
<link id="GetFloatProp"/>
1030
<link id="GetInt64Prop"/>
1031
<link id="GetMethodProp"/>
1033
<example file="typinfex/ex7"/>
1037
<element name="GetStrProp">
1038
<short>Return the value of a string property.</short>
1040
<var>GetStrProp</var> returns the value of the string property described by
1041
<var>PropInfo</var> or with name <var>PropName</var> for object <var>Instance</var>.
1044
No checking is done whether <var>Instance</var> is non-nil, or whether
1045
<var>PropInfo</var> describes a valid string property of <var>Instance</var>.
1046
Specifying an invalid property name in <var>PropName</var> will result in an
1047
<var>EPropertyError</var> exception.
1050
<link id="SetStrProp"/>
1051
<link id="GetOrdProp"/>
1052
<link id="GetFloatProp"/>,
1053
<link id="GetInt64Prop"/>
1054
<link id="GetMethodProp"/>
1056
<example file="typinfex/ex3"/>
1060
<element name="GetTypeData">
1061
<short>Return a pointer to type data, based on type information.</short>
1063
<var>GetTypeData</var> returns a pointer to the <var>TTypeData</var> record that
1064
follows after the <var>TTypeInfo</var> record pointed to by <var>TypeInfo</var>.
1065
It essentially skips the <var>Kind</var> and <var>Name</var> fields in the
1066
<var>TTypeInfo</var> record.
1075
<element name="GetVariantProp">
1076
<short>Return the value of a variant property.</short>
1078
Due to mising Variant support, the <var>GetVariantProp</var> function is not
1079
yet implemented. Provided for Delphi compatibility only.
1084
<link id="SetVariantProp"/>
1088
<element name="IsPublishedProp">
1089
<short>Check whether a published property exists.</short>
1092
<var>IsPublishedProp</var> returns true if a class has a published property with
1093
name <var>PropName</var>. The class can be specfied in one of two ways:
1096
<dt>AClass</dt><dd> A class pointer to the class.</dd>
1097
<dt>Instance</dt><dd> An instance of the class.</dd>
1101
No checks are done to ensure <var>Instance</var> or <var>AClass</var> are valid
1102
pointers. Specifying an invalid property name in <var>PropName</var> will result
1103
in an <var>EPropertyError</var> exception.
1106
<link id="IsStoredProp"/>
1107
<link id="PropIsType"/>
1109
<example file="typinfex/ex10"/>
1113
<element name="IsStoredProp">
1114
<short>Check whether a property is stored.</short>
1117
<var>IsStoredProp</var> returns <var>True</var> if the <var>Stored</var> modifier evaluates
1118
to <var>True</var> for the property described by <var>PropInfo</var> or with name
1119
<var>PropName</var> for object <var>Instance</var>.
1120
It returns <var>False</var> otherwise. If the function returns
1121
<var>True</var>, this indicates that the property should be written when
1122
streaming the object <var>Instance</var>.
1125
If there was no <var>stored</var> modifier in the declaration of the property,
1126
<var>True</var> will be returned.
1130
No checking is done whether <var>Instance</var> is non-nil, or whether
1131
<var>PropInfo</var> describes a valid property of <var>Instance</var>.
1132
Specifying an invalid property name in <var>PropName</var> will result in an
1133
<var>EPropertyError</var> exception.
1136
<link id="IsPublishedProp"/>
1137
<link id="PropIsType"/>
1139
<example file="typinfex/ex11"/>
1143
<element name="PropIsType">
1144
<short>Check the type of a published property.</short>
1147
<var>PropIsType</var> returns <var>True</var> if the property with name <var>PropName</var>
1148
has type <var>TypeKind</var>. It returns <var>False</var> otherwise. The class to be
1149
examined can be specified in one of two ways:
1152
<dt>AClass</dt><dd> A class pointer. </dd>
1153
<dt>Instance</dt><dd> An instance of the class.</dd>
1157
No checks are done to ensure <var>Instance</var> or <var>AClass</var> are valid
1158
pointers.Specifying an invalid property name in <var>PropName</var> will result
1159
in an <var>EPropertyError</var> exception.
1162
<link id="IsPublishedProp"/>
1163
<link id="IsStoredProp"/>
1164
<link id="PropType"/>
1166
<example file="typinfex/ex16"/>
1170
<element name="PropType">
1171
<short>Return the type of a property</short>
1174
<var>Proptype</var> returns the type of the property <var>PropName</var> for a class.
1175
The class to be examined can be specified in one of 2 ways:
1178
<dt>AClass</dt><dd>A class pointer.</dd>
1179
<dt>Instance</dt><dd>An instance of the class.</dd>
1183
No checks are done to ensure <var>Instance</var> or <var>AClass</var> are valid
1184
pointers. Specifying an invalid property name in <var>PropName</var> will result
1185
in an <var>EPropertyError</var> exception.
1188
<link id="IsPublishedProp"/>
1189
<link id="IsStoredProp"/>
1190
<link id="PropIsType"/>
1192
<example file="typinfex/ex17"/>
1196
<element name="SetEnumProp">
1197
<short>Set value of an enumerated-type property</short>
1200
<var>SetEnumProp</var> sets the property described by <var>PropInfo</var> or with name
1201
<var>PropName</var> to <var>Value</var>. <var>Value</var> must be a string with the name
1202
of the enumerate value, i.e. it can be used as an argument to
1203
<link id="GetEnumValue"/>.
1206
For an example, see <link id="GetEnumProp"/>.
1210
No checks are done to ensure <var>Instance</var> or <var>PropInfo</var> are valid
1211
pointers. Specifying an invalid property name in <var>PropName</var> will result
1212
in an <var>EPropertyError</var> exception.
1215
<link id="GetEnumProp"/>
1216
<link id="SetStrProp"/>
1217
<link id="SetFloatProp"/>
1218
<link id="SetInt64Prop"/>
1219
<link id="SetMethodProp"/>
1224
<element name="SetFloatProp">
1225
<short>Set value of a float property.</short>
1228
<var>SetFloatProp</var> assigns <var>Value</var> to the property described by
1229
<var>PropInfo</var> or with name <var>Propname</var> for the object <var>Instance</var>.
1232
For an example, see <link id="GetFloatProp"/>.
1236
No checking is done whether <var>Instance</var> is non-nil, or whether
1237
<var>PropInfo</var> describes a valid float property of <var>Instance</var>.
1238
Specifying an invalid property name in <var>PropName</var> will result in an
1239
<var>EPropertyError</var> exception.
1242
<link id="GetFloatProp"/>
1243
<link id="SetOrdProp"/>
1244
<link id="SetStrProp"/>,
1245
<link id="SetInt64Prop"/>
1246
<link id="SetMethodProp"/>
1252
<element name="SetInt64Prop">
1253
<short>Set value of a Int64 property</short>
1256
<var>SetInt64Prop</var> assigns <var>Value</var> to the property of type
1257
<var>Int64</var> that is described by <var>PropInfo</var> or with name <var>Propname</var>
1258
for the object <var>Instance</var>.
1261
For an example, see <link id="GetInt64Prop"/>.
1265
No checking is done whether <var>Instance</var> is non-nil, or whether
1266
<var>PropInfo</var> describes a valid <var>Int64</var> property of <var>Instance</var>.
1267
Specifying an invalid property name in <var>PropName</var> will result in an
1268
<var>EPropertyError</var> exception.
1271
<link id="GetInt64Prop"/>
1272
<link id="GetMethodProp"/>
1273
<link id="SetOrdProp"/>
1274
<link id="SetStrProp"/>
1275
<link id="SetFloatProp"/>
1279
<element name="SetMethodProp">
1280
<short>Set the value of a method property</short>
1283
<var>SetMethodProp</var> assigns <var>Value</var> to the method the property described
1284
by <var>PropInfo</var> or with name <var>Propname</var> for object <var>Instance</var>.
1287
The type <var>TMethod</var> of the <var>Value</var> parameter is defined in the
1288
<file>SysUtils</file> unit as:
1291
TMethod = packed record
1292
Code, Data: Pointer;
1296
<var>Data</var> should point to the instance of the class with the method <var>Code</var>.
1299
For an example, see <link id="GetMethodProp"/>.
1303
No checking is done whether <var>Instance</var> is non-nil, or whether
1304
<var>PropInfo</var> describes a valid method property of <var>Instance</var>.
1305
Specifying an invalid property name in <var>PropName</var> will result in an
1306
<var>EPropertyError</var> exception.
1309
<link id="GetMethodProp"/>
1310
<link id="SetOrdProp"/>
1311
<link id="SetStrProp"/>
1312
<link id="SetFloatProp"/>
1313
<link id="SetInt64Prop"/>
1317
<element name="SetObjectProp">
1318
<short>Set the value of an object-type property.</short>
1321
<var>SetObjectProp</var> assigns <var>Value</var> to the the object property described by
1322
<var>PropInfo</var> or with name <var>Propname</var> for the object <var>Instance</var>.
1325
For an example, see <link id="GetObjectProp"/>.
1329
No checking is done whether <var>Instance</var> is non-nil, or whether
1330
<var>PropInfo</var> describes a valid method property of <var>Instance</var>.
1331
Specifying an invalid property name in <var>PropName</var> will result in an
1332
<var>EPropertyError</var> exception.
1335
<link id="GetObjectProp"/>
1336
<link id="SetOrdProp"/>
1337
<link id="SetStrProp"/>
1338
<link id="SetFloatProp"/>
1339
<link id="SetInt64Prop"/>
1340
<link id="SetMethodProp"/>
1345
<element name="SetOrdProp">
1346
<short>Set value of an ordinal property</short>
1349
<var>SetOrdProp</var> assigns <var>Value</var> to the the ordinal property described by
1350
<var>PropInfo</var> or with name <var>Propname</var> for the object <var>Instance</var>.
1353
Ordinal properties that can be set include:
1356
<dt>Integers and subranges of integers</dt>
1357
<dd>The actual value of the integer must be passed.</dd>
1358
<dt>Enumerated types and subranges of enumerated types</dt>
1359
<dd>The ordinal value of the enumerated type must be passed.</dd>
1360
<dt>Subrange types</dt>
1361
<dd>of integers or enumerated types. Here the ordinal value must be passed.</dd>
1363
<dd> If the base type of the set has less than 31 possible values.
1364
For each possible value; the corresponding bit of <var>Value</var> must be set.</dd>
1367
For an example, see <link id="GetOrdProp"/>.
1371
No checking is done whether <var>Instance</var> is non-nil, or whether
1372
<var>PropInfo</var> describes a valid ordinal property of <var>Instance</var>.
1373
No range checking is performed.
1374
Specifying an invalid property name in <var>PropName</var> will result in an
1375
<var>EPropertyError</var> exception.
1378
<link id="GetOrdProp"/>
1379
<link id="SetStrProp"/>
1380
<link id="SetFloatProp"/>
1381
<link id="SetInt64Prop"/>
1382
<link id="SetMethodProp"/>
1387
<element name="SetPropValue">
1388
<short>Set property value as variant</short>
1390
Due to missing Variant support, this function is not yet implemented;
1391
it is provided for Delphi compatibility only.
1399
<element name="SetSetProp">
1400
<short>Set value of set-typed property.</short>
1403
<var>SetSetProp</var> sets the property specified by <var>PropInfo</var> or
1404
<var>PropName</var> for object <var>Instance</var> to <var>Value</var>. <var>Value</var> is a
1405
string which contains a comma-separated list of values, each value being a
1406
string-representation of the enumerated value that should be included in
1407
the set. The value should be accepted by the <link id="StringToSet"/> function.
1410
The value can be formed using the <link id="SetToString"/> function.
1413
For an example, see <link id="GetSetProp"/>.
1417
No checking is done whether <var>Instance</var> is non-nil, or whether
1418
<var>PropInfo</var> describes a valid ordinal property of <var>Instance</var>.
1419
No range checking is performed.
1420
Specifying an invalid property name in <var>PropName</var> will result in an
1421
<var>EPropertyError</var> exception.
1424
<link id="GetSetProp"/>
1425
<link id="SetOrdProp"/>
1426
<link id="SetStrProp"/>
1427
<link id="SetFloatProp"/>
1428
<link id="SetInt64Prop"/>
1429
<link id="SetMethodProp"/>
1430
<link id="SetToString"/>
1431
<link id="StringToSet"/>
1436
<element name="SetStrProp">
1437
<short>Set value of a string property</short>
1440
<var>SetStrProp</var> assigns <var>Value</var> to the string property described by
1441
<var>PropInfo</var> or with name <var>Propname</var> for object <var>Instance</var>.
1444
For an example, see <link id="GetStrProp"/>
1448
No checking is done whether <var>Instance</var> is non-nil, or whether
1449
<var>PropInfo</var> describes a valid string property of <var>Instance</var>.
1450
Specifying an invalid property name in <var>PropName</var> will result in an
1451
<var>EPropertyError</var> exception.
1454
<link id="GetStrProp"/>
1455
<link id="SetOrdProp"/>
1456
<link id="SetFloatProp"/>,
1457
<link id="SetInt64Prop"/>
1458
<link id="SetMethodProp"/>
1463
<element name="SetToString">
1464
<short>Convert set to a string description</short>
1467
<var>SetToString</var> takes an integer representation of a set (as received e.g.
1468
by <var>GetOrdProp</var>) and turns it into a string representing the elements in
1469
the set, based on the type information found in the <var>PropInfo</var> property
1470
information. By default, the string representation is not surrounded by
1471
square brackets. Setting the <var>Brackets</var> parameter to <var>True</var> will
1472
surround the string representation with brackets.
1475
The function returns the string representation of the set.
1479
No checking is done to see whether <var>PropInfo</var> points to valid property
1483
<link id="GetEnumName"/>
1484
<link id="GetEnumValue"/>
1485
<link id="StringToSet"/>
1487
<example file="typinfex/ex18"/>
1491
<element name="SetVariantProp">
1492
<short>Set value of a variant property</short>
1494
Due to missing Variant support, this function is not yet implemented.
1495
Provided for Delphi compatibility only.
1504
<element name="StringToSet">
1505
<short>Convert string description to a set.</short>
1508
<var>StringToSet</var> converts the string representation of a set in <var>Value</var>
1509
to a integer representation of the set, using the property information found
1510
in <var>PropInfo</var>. This property information should point to the property
1511
information of a set property. The function returns the integer
1512
representation of the set. (i.e, the set value, typecast to an integer)
1515
The string representation can be surrounded with square brackets, and must
1516
consist of the names of the elements of the base type of the set. The base
1517
type of the set should be an enumerated type. The elements should be
1518
separated by commas, and may be surrounded by spaces.
1519
each of the names will be fed to the <link id="GetEnumValue"/> function.
1522
For an example, see <link id="SetToString"/>.
1526
No checking is done to see whether <var>PropInfo</var> points to valid property
1527
information. If a wrong name is given for an enumerated value, then an
1528
<var>EPropertyError</var> will be raised.
1531
<link id="GetEnumName"/>
1532
<link id="GetEnumValue"/>
1533
<link id="SetToString"/>
1537
<element name="OnGetPropValue">
1538
<short>Callback to get a property value as a variant.</short>
1540
This callback is set by the variants unit to enable reading of properties as
1541
a variant. If set, it is called by the <link id="GetPropValue"/> function.
1546
<element name="OnGetVariantprop">
1547
<short>Callback to get a variant property value.</short>
1549
This callback is set by the variants unit to enable reading of variant properties
1550
If set, it is called by the <link id="GetVariantProp"/> function.
1555
<element name="OnSetPropValue">
1556
<short>Callback to set a property value as a variant.</short>
1558
This callback is set by the variants unit to enable writing of properties as
1559
a variant. If set, it is called by the <link id="SetPropValue"/> function.
1564
<element name="OnSetVariantprop">
1565
<short>Callback to set a variant property value.</short>
1567
This callback is set by the variants unit to enable writing of variant
1568
properties. If set, it is called by the <link id="GetVariantProp"/> function.
1573
<element name="TGetPropValue">
1574
<short>Callback type for the <link id="#rtl.TypInfo.OnGetPropValue">OnGetPropValue</link> callback
1577
The callback function must return the property with name <var>PropName</var>
1578
of instance <var>Instance</var>. If <var>PreferStrings</var> is true, it
1579
should favour converting the property to a string value. The function needs
1580
to return the variant with the property value.
1586
<element name="TGetVariantProp">
1587
<short>Callback type for the <link id="#rtl.TypInfo.OnGetVariantProp">OnGetVariantProp</link> callback
1590
The callback function must return the variant property with name <var>PropName</var>
1591
of instance <var>Instance</var>.
1596
<element name="TSetPropValue">
1597
<short>Callback type for the <link id="#rtl.TypInfo.OnSetPropValue">OnSetPropValue</link> callback
1600
The callback function must set the property with name <var>PropName</var>
1601
of instance <var>Instance</var> to <var>Value</var>.
1606
<element name="TSetVariantProp">
1607
<short>Callback type for the <link id="#rtl.TypInfo.OnSetVariantProp">OnSetVariantProp</link> callback
1610
The callback function must set the variant property with name <var>PropName</var>
1611
of instance to <var>Value</var>.
1619
</fpdoc-descriptions>