typinfo.tex 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 2001, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % The TYPINFO unit
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. \chapter{The TYPINFO unit}
  26. \FPCexampledir{typinfex}
  27. The \file{TypeInfo} unit contains many routines which can be used for
  28. the querying of the Run-Time Type Information (RTTI) which is generated
  29. by the compiler for classes that are compiled under the \var{\{\$M+\}}
  30. switch. This information can be used to retrieve or set property values
  31. for published properties for totally unknown classes. In particular, it
  32. can be used to stream classes. The \var{TPersistent} class in the
  33. \file{Classes} unit is compiled in the \var{\{\$M+\}} state and serves
  34. as the base class for all classes that need to be streamed.
  35. The unit should be compatible to the Delphi 5 unit with the same name.
  36. The only calls that are still missing are the Variant calls, since \fpc
  37. does not support the variant type yet.
  38. The examples in this chapter use a \file{rttiobj} file, which contains
  39. an object that has a published property of all supported types. It also
  40. contains some auxiliary routines and definitions.
  41. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  42. % Constants, Types and variables
  43. \section{Constants, Types and variables}
  44. \subsection{Constants}
  45. The following constants are used in the implementation section of the unit.
  46. \begin{verbatim}
  47. BooleanIdents: array[Boolean] of String = ('False', 'True');
  48. DotSep: String = '.';
  49. \end{verbatim}
  50. The following constants determine the access method for the \var{Stored}
  51. identifier of a property as used in the \var{PropProcs} field of the
  52. \var{TPropInfo} record:
  53. \begin{verbatim}
  54. ptField = 0;
  55. ptStatic = 1;
  56. ptVirtual = 2;
  57. ptConst = 3;
  58. \end{verbatim}
  59. The following typed constants are used for easy selection of property types.
  60. \begin{verbatim}
  61. tkAny = [Low(TTypeKind)..High(TTypeKind)];
  62. tkMethods = [tkMethod];
  63. tkProperties = tkAny-tkMethods-[tkUnknown];
  64. \end{verbatim}
  65. \subsection{types}
  66. The following pointer types are defined:
  67. \begin{verbatim}
  68. PShortString =^ShortString;
  69. PByte =^Byte;
  70. PWord =^Word;
  71. PLongint =^Longint;
  72. PBoolean =^Boolean;
  73. PSingle =^Single;
  74. PDouble =^Double;
  75. PExtended =^Extended;
  76. PComp =^Comp;
  77. PFixed16 =^Fixed16;
  78. Variant = Pointer;
  79. \end{verbatim}
  80. The \var{TTypeKind} determines the type of a property:
  81. \begin{verbatim}
  82. TTypeKind = (tkUnknown,tkInteger,tkChar,tkEnumeration,
  83. tkFloat,tkSet,tkMethod,tkSString,tkLString,tkAString,
  84. tkWString,tkVariant,tkArray,tkRecord,tkInterface,
  85. tkClass,tkObject,tkWChar,tkBool,tkInt64,tkQWord,
  86. tkDynArray,tkInterfaceRaw);
  87. tkString = tkSString;
  88. \end{verbatim}
  89. \var{tkString} is an alias that is introduced for Delphi compatibility.
  90. If the property is and ordinal type, then \var{TTOrdType} determines the
  91. size and sign of the ordinal type:
  92. \begin{verbatim}
  93. TTOrdType = (otSByte,otUByte,otSWord,otUWord,otSLong,otULong);
  94. \end{verbatim}
  95. The size of a float type is determined by \var{TFloatType}:
  96. \begin{verbatim}
  97. TFloatType = (ftSingle,ftDouble,ftExtended,ftComp,ftCurr,
  98. ftFixed16,ftFixed32);
  99. \end{verbatim}
  100. A method property (e.g. an event) can have one of several types:
  101. \begin{verbatim}
  102. TMethodKind = (mkProcedure,mkFunction,mkConstructor,mkDestructor,
  103. mkClassProcedure, mkClassFunction);
  104. \end{verbatim}
  105. The kind of parameter to a method is determined by \var{TParamFlags}:
  106. \begin{verbatim}
  107. TParamFlags = set of (pfVar,pfConst,pfArray,pfAddress,pfReference,pfOut);
  108. \end{verbatim}
  109. Interfaces are described further with \var{TntfFlags}:
  110. \begin{verbatim}
  111. TIntfFlags = set of (ifHasGuid,ifDispInterface,ifDispatch);
  112. \end{verbatim}
  113. The following defines a set of \var{TTypeKind}:
  114. \begin{verbatim}
  115. TTypeKinds = set of TTypeKind;
  116. \end{verbatim}
  117. The \var{TypeInfo} function returns a pointer to a \var{TTypeInfo} record:
  118. \begin{verbatim}
  119. TTypeInfo = record
  120. Kind : TTypeKind;
  121. Name : ShortString;
  122. end;
  123. PTypeInfo = ^TTypeInfo;
  124. PPTypeInfo = ^PTypeInfo;
  125. \end{verbatim}
  126. Note that the Name is stored with as much bytes as needed to store the name,
  127. it is not padded to 255 characters.
  128. The type data immediatly follows the \var{TTypeInfo} record as a \var{TTypeData} record:
  129. \begin{verbatim}
  130. PTypeData = ^TTypeData;
  131. TTypeData = packed record
  132. case TTypeKind of
  133. tkUnKnown,tkLString,tkWString,tkAString,tkVariant:
  134. ();
  135. tkInteger,tkChar,tkEnumeration,tkWChar:
  136. (OrdType : TTOrdType;
  137. case TTypeKind of
  138. tkInteger,tkChar,tkEnumeration,tkBool,tkWChar : (
  139. MinValue,MaxValue : Longint;
  140. case TTypeKind of
  141. tkEnumeration: (
  142. BaseType : PTypeInfo;
  143. NameList : ShortString
  144. )
  145. );
  146. tkSet: (
  147. CompType : PTypeInfo
  148. )
  149. );
  150. tkFloat: (
  151. FloatType : TFloatType
  152. );
  153. tkSString:
  154. (MaxLength : Byte);
  155. tkClass:
  156. (ClassType : TClass;
  157. ParentInfo : PTypeInfo;
  158. PropCount : SmallInt;
  159. UnitName : ShortString
  160. );
  161. tkMethod:
  162. (MethodKind : TMethodKind;
  163. ParamCount : Byte;
  164. ParamList : array[0..1023] of Char
  165. {in reality ParamList is a array[1..ParamCount] of:
  166. record
  167. Flags : TParamFlags;
  168. ParamName : ShortString;
  169. TypeName : ShortString;
  170. end;
  171. followed by
  172. ResultType : ShortString}
  173. );
  174. tkInt64:
  175. (MinInt64Value, MaxInt64Value: Int64);
  176. tkQWord:
  177. (MinQWordValue, MaxQWordValue: QWord);
  178. tkInterface:
  179. ();
  180. end;
  181. \end{verbatim}
  182. If the typeinfo kind is \var{tkClass}, then the property
  183. information follows the \var{UnitName} string, as an array of \var{TPropInfo} records.
  184. The \var{TPropData} record is not used, but is provided for completeness and
  185. compatibility with Delphi.
  186. \begin{verbatim}
  187. TPropData = packed record
  188. PropCount : Word;
  189. PropList : record end;
  190. end;
  191. \end{verbatim}
  192. The \var{TPropInfo} record describes one published property of a class:
  193. \begin{verbatim}
  194. PPropInfo = ^TPropInfo;
  195. TPropInfo = packed record
  196. PropType : PTypeInfo;
  197. GetProc : Pointer;
  198. SetProc : Pointer;
  199. StoredProc : Pointer;
  200. Index : Integer;
  201. Default : Longint;
  202. NameIndex : SmallInt;
  203. PropProcs : Byte;
  204. Name : ShortString;
  205. end;
  206. \end{verbatim}
  207. The \var{Name} field is stored not with 255 characters, but with just as many characters
  208. as required to store the name.
  209. \begin{verbatim}
  210. TProcInfoProc = procedure(PropInfo : PPropInfo) of object;
  211. \end{verbatim}
  212. The following pointer and array types are used for typecasts:
  213. \begin{verbatim}
  214. PPropList = ^TPropList;
  215. TPropList = array[0..65535] of PPropInfo;
  216. \end{verbatim}
  217. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  218. % Functions and procedures by category
  219. \section{Function list by category}
  220. What follows is a listing of the available functions, grouped by category.
  221. For each function there is a reference to the page where the function
  222. can be found.
  223. \subsection{Examining published property information}
  224. Functions for retrieving or examining property information
  225. \begin{funclist}
  226. \funcref{FindPropInfo}{Getting property type information, With error checking.}
  227. \funcref{GetPropInfo}{Getting property type information, No error checking.}
  228. \funcref{GetPropInfos}{Find property information of a certain kind}
  229. \funcref{GetObjectPropClass}{Return the declared class of an object property }
  230. \funcref{GetPropList}{Get a list of all published properties}
  231. \funcref{IsPublishedProp}{Is a property published}
  232. \funcref{IsStoredProp}{Is a property stored}
  233. \funcref{PropIsType}{Is a property of a certain kind}
  234. \funcref{PropType}{Return the type of a property}
  235. \end{funclist}
  236. \subsection{Getting or setting property values}
  237. Functions to set or set a property's value.
  238. \begin{funclist}
  239. \funcref{GetEnumProp}{Return the value of an enumerated type property}
  240. \funcref{GetFloatProp}{Return the value of a float property}
  241. \funcref{GetInt64Prop}{Return the value of an Int64 property}
  242. \funcref{GetMethodProp}{Return the value of a procedural type property}
  243. \funcref{GetObjectProp}{Return the value of an object property}
  244. \funcref{GetOrdProp}{Return the value of an ordinal type property}
  245. \funcref{GetPropValue}{Return the value of a property as a variant}
  246. \funcref{GetSetProp}{Return the value of a set property}
  247. \funcref{GetStrProp}{Return the value of a string property}
  248. \funcref{GetVariantProp}{Return the value of a variant property}
  249. \funcref{SetEnumProp}{Set the value of an enumerated type property}
  250. \funcref{SetFloatProp}{Set the value of a float property}
  251. \funcref{SetInt64Prop}{Set the value of an Int64 property}
  252. \funcref{SetMethodProp}{Set the value of a procedural type property}
  253. \funcref{SetObjectProp}{Set the value of an object property}
  254. \funcref{SetOrdProp}{Set the value of an ordinal type property}
  255. \funcref{SetPropValue}{Set the value of a property trhough a variant}
  256. \funcref{SetSetProp}{Set the value of a set property}
  257. \funcref{SetStrProp}{Set the value of a string property}
  258. \funcref{SetVariantProp}{Set the value of a variant property}
  259. \end{funclist}
  260. \subsection{Auxiliary functions}
  261. \begin{funclist}
  262. \funcref{GetEnumName}{Get an enumerated type element name}
  263. \funcref{GetEnumValue}{Get ordinal number of an enumerated tye, based on the
  264. name.}
  265. \funcref{GetTypeData}{Skip type name and return a pointer to the type data}
  266. \funcref{SetToString}{Convert a set to its string representation}
  267. \funcref{StringToSet}{Convert a string representation of a set to a set}
  268. \end{funclist}
  269. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  270. % Functions and procedures
  271. \section{Functions and Procedures}
  272. \begin{function}{FindPropInfo}
  273. \Declaration
  274. Function FindPropInfo(AClass:TClass;const PropName: string): PPropInfo;\\
  275. Function FindPropInfo(Instance: TObject; const PropName: string): PPropInfo;
  276. \Description
  277. \var{FindPropInfo} examines the published property information of a class and
  278. returns a pointer to the property information for property \var{PropName}.
  279. The class to be examined can be specified in one of two ways:
  280. \begin{description}
  281. \item[AClass] a class pointer.
  282. \item[Instance] an instance of the class to be investigated.
  283. \end{description}
  284. If the property does not exist, a \var{EPropertyError} exception will be
  285. raised. The \seef{GetPropInfo} function has the same function as the
  286. \var{FindPropInfo} function, but returns \var{Nil} if the property does not
  287. exist.
  288. \Errors
  289. Specifying an invalid property name in \var{PropName} will result in an
  290. \var{EPropertyError} exception.
  291. \SeeAlso
  292. \seef{GetPropInfo}, \seef{GetPropList}, \seep{GetPropInfos}
  293. \end{function}
  294. \FPCexample{ex14}
  295. \begin{function}{GetEnumName}
  296. \Declaration
  297. Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
  298. \Description
  299. \var{GetEnumName} scans the type information for the enumeration type
  300. described by \var{TypeInfo} and returns the name of the enumeration
  301. constant for the element with ordinal value equal to \var{Value}.
  302. If \var{Value} is out of range, the first element of the enumeration type
  303. is returned. The result is lowercased, but this may change in the future.
  304. This can be used in combination with \var{GetOrdProp} to stream a property
  305. of an enumerated type.
  306. \Errors
  307. No check is done to determine whether \var{TypeInfo} really points to the
  308. type information for an enumerated type.
  309. \SeeAlso
  310. \seef{GetOrdProp}, \seef{GetEnumValue}
  311. \end{function}
  312. \FPCexample{ex9}
  313. \begin{function}{GetEnumProp}
  314. \Declaration
  315. Function GetEnumProp(Instance: TObject;const PropInfo: PPropInfo): string;\\
  316. Function GetEnumProp(Instance: TObject;const PropName: string): string;
  317. \Description
  318. \var{GetEnumProp} returns the value of an property of an enumerated type
  319. and returns the name of the enumerated value for the objetc \var{Instance}.
  320. The property whose value must be returned can be specified by its property
  321. info in \var{PropInfo} or by its name in \var{PropName}
  322. \Errors
  323. No check is done to determine whether \var{PropInfo} really points to the
  324. property information for an enumerated type.
  325. Specifying an invalid property name in \var{PropName} will result in an
  326. \var{EPropertyError} exception.
  327. \SeeAlso
  328. \seep{SetEnumProp} \seef{GetOrdProp}, \seef{GetStrProp},
  329. \seef{GetInt64Prop},\seef{GetMethodProp}, \seef{GetSetProp},
  330. \seef{GetObjectProp}, \seef{GetEnumProp}
  331. \end{function}
  332. \FPCexample{ex2}
  333. \begin{function}{GetEnumValue}
  334. \Declaration
  335. Function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
  336. \Description
  337. \var{GetEnumValue} scans the type information for the enumeration type
  338. described by \var{TypeInfor} and returns the ordinal value for the element
  339. in the enumerated type that has identifier \var{Name}. The identifier is
  340. searched in a case-insensitive manner.
  341. This can be used to set the value of enumerated properties from a stream.
  342. \Errors
  343. If \var{Name} is not found in the list of enumerated values, then -1 is
  344. returned. No check is done whether \var{TypeInfo} points to the type information
  345. for an enumerated type.
  346. \SeeAlso
  347. \seef{GetEnumName}, \seep{SetOrdProp}
  348. \end{function}
  349. For an example, see \seef{GetEnumName}.
  350. \begin{function}{GetFloatProp}
  351. \Declaration
  352. Function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;\\
  353. Procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Extended);
  354. \Description
  355. \var{GetFloatProp} returns the value of the float property described by
  356. \var{PropInfo} or with name \var{Propname} for the object \var{Instance}.
  357. All float types are converted
  358. to extended.
  359. \Errors
  360. No checking is done whether \var{Instance} is non-nil, or whether
  361. \var{PropInfo} describes a valid float property of \var{Instance}.
  362. Specifying an invalid property name in \var{PropName} will result in an
  363. \var{EPropertyError} exception.
  364. \SeeAlso
  365. \seep{SetFloatProp}, \seef{GetOrdProp}, \seef{GetStrProp},
  366. \seef{GetInt64Prop},\seef{GetMethodProp}, \seef{GetSetProp},
  367. \seef{GetObjectProp}, \seef{GetEnumProp}
  368. \end{function}
  369. \FPCexample{ex4}
  370. \begin{function}{GetInt64Prop}
  371. \Declaration
  372. Function GetInt64Prop(Instance: TObject; PropInfo: PPropInfo): Int64;\\
  373. Function GetInt64Prop(Instance: TObject; const PropName: string): Int64;
  374. \Description
  375. {\em Publishing of Int64 properties is not yet supported by \fpc. This
  376. function is provided for Delphi compatibility only at the moment.}
  377. \var{GetInt64Prop} returns the value of the property of type
  378. \var{Int64} that is described by \var{PropInfo} or with name \var{Propname}
  379. for the object \var{Instance}.
  380. \Errors
  381. No checking is done whether \var{Instance} is non-nil, or whether
  382. \var{PropInfo} describes a valid \var{Int64} property of \var{Instance}.
  383. Specifying an invalid property name in \var{PropName} will result in an
  384. \var{EPropertyError} exception
  385. \SeeAlso
  386. \seep{SetInt64Prop}, \seef{GetOrdProp}, \seef{GetStrProp},
  387. \seef{GetFloatProp}, \seef{GetMethodProp}, \seef{GetSetProp},
  388. \seef{GetObjectProp}, \seef{GetEnumProp}
  389. \end{function}
  390. \FPCexample{ex15}
  391. \begin{function}{GetMethodProp}
  392. \Declaration
  393. Function GetMethodProp(Instance : TObject;PropInfo : PPropInfo) : TMethod;\\
  394. Function GetMethodProp(Instance: TObject; const PropName: string): TMethod;
  395. \Description
  396. \var{GetMethodProp} returns the method the property described by
  397. \var{PropInfo} or with name \var{Propname} for object \var{Instance}.
  398. The return type \var{TMethod} is defined in the \file{SysUtils} unit as:
  399. \begin{verbatim}
  400. TMethod = packed record
  401. Code, Data: Pointer;
  402. end;
  403. \end{verbatim}
  404. \var{Data} points to the instance of the class with the method \var{Code}.
  405. \Errors
  406. No checking is done whether \var{Instance} is non-nil, or whether
  407. \var{PropInfo} describes a valid method property of \var{Instance}.
  408. Specifying an invalid property name in \var{PropName} will result in an
  409. \var{EPropertyError} exception
  410. \SeeAlso
  411. \seep{SetMethodProp}, \seef{GetOrdProp}, \seef{GetStrProp},
  412. \seef{GetFloatProp}, \seef{GetInt64Prop}, \seef{GetSetProp},
  413. \seef{GetObjectProp}, \seef{GetEnumProp}
  414. \end{function}
  415. \FPCexample{ex6}
  416. \begin{function}{GetObjectProp}
  417. \Declaration
  418. Function GetObjectProp(Instance: TObject; const PropName: string): TObject;\\
  419. Function GetObjectProp(Instance: TObject; const PropName: string; MinClass:TClass): TObject; \\
  420. Function GetObjectProp(Instance: TObject; PropInfo: PPropInfo; MinClass: TClass):
  421. TObject;\\
  422. \Description
  423. \var{GetObjectProp} returns the object which the property descroibed by
  424. \var{PropInfo} with name \var{Propname} points to for object \var{Instance}.
  425. If \var{MinClass} is specified, then if the object is not descendent of
  426. class \var{MinClass}, then \var{Nil} is returned.
  427. \Errors
  428. No checking is done whether \var{Instance} is non-nil, or whether
  429. \var{PropInfo} describes a valid method property of \var{Instance}.
  430. Specifying an invalid property name in \var{PropName} will result in an
  431. \var{EPropertyError} exception.
  432. \SeeAlso
  433. \seep{SetMethodProp}, \seef{GetOrdProp}, \seef{GetStrProp},
  434. \seef{GetFloatProp}, \seef{GetInt64Prop}, \seef{GetSetProp},
  435. \seef{GetObjectProp}, \seef{GetEnumProp}
  436. \end{function}
  437. \FPCexample{ex5}
  438. \begin{function}{GetObjectPropClass}
  439. \Declaration
  440. Function GetObjectPropClass(Instance: TObject; const PropName: string): TClass;
  441. \Description
  442. \var{GetObjectPropClass} returns the declared class of the property with name
  443. \var{PropName}. This may not be the actual class of the property value.
  444. \Errors
  445. No checking is done whether \var{Instance} is non-nil.
  446. Specifying an invalid property name in \var{PropName} will result in an
  447. \var{EPropertyError} exception.
  448. \SeeAlso
  449. \seep{SetMethodProp}, \seef{GetOrdProp}, \seef{GetStrProp},
  450. \seef{GetFloatProp}, \seef{GetInt64Prop}
  451. \end{function}
  452. For an example, see \seef{GetObjectProp}.
  453. \begin{function}{GetOrdProp}
  454. \Declaration
  455. Function GetOrdProp(Instance : TObject;PropInfo : PPropInfo) : Longint;\\
  456. Function GetOrdProp(Instance: TObject;const PropName: string): Longint;
  457. \Description
  458. \var{GetOrdProp} returns the value of the ordinal property described by
  459. \var{PropInfo} or with name \var{PropName} for the object \var{Instance}.
  460. The value is returned as a longint, which should be typecasted to the
  461. needed type.
  462. Ordinal properties that can be retrieved include:
  463. \begin{description}
  464. \item[Integers and subranges of integers] The value of the integer will be
  465. returned.
  466. \item[Enumerated types and subranges of enumerated types] The ordinal value
  467. of the enumerated type will be returned.
  468. \item[Sets] If the base type of the set has less than 31 possible values.
  469. If a bit is set in the return value, then the corresponding element of the
  470. base ordinal class of the set type must be included in the set.
  471. \end{description}
  472. \Errors
  473. No checking is done whether \var{Instance} is non-nil, or whether
  474. \var{PropInfo} describes a valid ordinal property of \var{Instance}
  475. Specifying an invalid property name in \var{PropName} will result in an
  476. \var{EPropertyError} exception.
  477. \SeeAlso
  478. \seep{SetOrdProp}, \seef{GetStrProp}, \seef{GetFloatProp},
  479. \seef{GetInt64Prop},\seef{GetMethodProp}, \seef{GetSetProp},
  480. \seef{GetObjectProp}, \seef{GetEnumProp}
  481. \end{function}
  482. \FPCexample{ex1}
  483. \begin{function}{GetPropInfo}
  484. \Declaration
  485. Function GetPropInfo(AClass: TClass; const PropName: string; AKinds: TTypeKinds) : PPropInfo;\\
  486. Function GetPropInfo(AClass: TClass; const PropName: string): PPropInfo;\\
  487. Function GetPropInfo(Instance: TObject; const PropName: string): PPropInfo;\\
  488. Function GetPropInfo(Instance: TObject; const PropName: string; AKinds: TTypeKinds) : PPropInfo;\\
  489. Function GetPropInfo(TypeInfo: PTypeInfo;const PropName: string) : PPropInfo;\\
  490. Function GetPropInfo(TypeInfo: PTypeInfo;const PropName: string; AKinds : TTypeKinds) : PPropInfo;
  491. \Description
  492. \var{GetPropInfo} returns a pointer to the \var{TPropInfo} record for a the
  493. \var{PropName} property of a class. The class to examine can be specified
  494. in one of three ways:
  495. \begin{description}
  496. \item[Instance] An instance of the class.
  497. \item[AClass] A class pointer to the class.
  498. \item[TypeInfo] A pointer to the type information of the class.
  499. \end{description}
  500. In each of these three ways, if \var{AKinds} is specified, if the property
  501. has \var{TypeKind} which is not included in \var{Akinds}, \var{Nil} will be
  502. returned.
  503. \Errors
  504. If the property \var{PropName} does not exist, \var{Nil} is returned.
  505. \SeeAlso
  506. \seep{GetPropInfos},\seef{GetPropList}
  507. \end{function}
  508. For an example, see most of the other functions.
  509. \begin{procedure}{GetPropInfos}
  510. \Declaration
  511. Procedure GetPropInfos(TypeInfo: PTypeInfo;PropList: PPropList);
  512. \Description
  513. \var{GetPropInfos} stores pointers to the property information of all published
  514. properties of a class with class info \var{TypeInfo} in the list pointed to by
  515. \var{Proplist}. The \var{PropList} pointer must point to a memory location that
  516. contains enough space to hold all properties of the class and its parent classes.
  517. \Errors
  518. No checks are done to see whether \var{PropList} points to a memory area that
  519. is big enough to hold all pointers.
  520. \SeeAlso
  521. \seef{GetPropInfo},\seef{GetPropList}
  522. \end{procedure}
  523. \FPCexample{ex12}
  524. \begin{function}{GetPropList}
  525. \Declaration
  526. Function GetPropList(TypeInfo : PTypeInfo;
  527. TypeKinds : TTypeKinds;
  528. PropList : PPropList) : Integer;
  529. \Description
  530. \var{GetPropList} stores pointers to property information of the class with class
  531. info \var{TypeInfo} for properties of kind \var{TypeKinds} in the list pointed to
  532. by \var{Proplist}. \var{PropList} must contain enough space to hold all properties.
  533. The function returns the number of pointers that matched the criteria and were stored
  534. in \var{PropList}.
  535. \Errors
  536. No checks are done to see whether \var{PropList} points to a memory area that is big enough
  537. to hold all pointers.
  538. \SeeAlso
  539. \seep{GetPropInfos}, \seef{GetPropInfo}
  540. \end{function}
  541. \FPCexample{ex13}
  542. \begin{function}{GetPropValue}
  543. \Declaration
  544. Function GetPropValue(Instance: TObject; const PropName: string): Variant;\\
  545. Function GetPropValue(Instance: TObject; const PropName: string; PreferStrings: Boolean): Variant;
  546. \Description
  547. Due to missing \var{Variant} support, \var{GetPropValue} is not yet implemented.
  548. The declaration is provided for compatibility with Delphi.
  549. \Errors
  550. \SeeAlso
  551. \end{function}
  552. \begin{function}{GetSetProp}
  553. \Declaration
  554. Function GetSetProp(Instance: TObject; const PropInfo: PPropInfo; Brackets: Boolean):
  555. string;\\
  556. Function GetSetProp(Instance: TObject; const PropName: string): string;\\
  557. Function GetSetProp(Instance: TObject; const PropName: string; Brackets: Boolean): string;
  558. \Description
  559. \var{GetSetProp} returns the contents of a set property as a string.
  560. The property to be returned can be specified by it's name in \var{PropName}
  561. or by its property information in \var{PropInfo}.
  562. The returned set is a string representation of the elements in the set as
  563. returned by \seef{SetToString}. The \var{Brackets} option can be used to
  564. enclose the string representation in square brackets.
  565. \Errors
  566. No checking is done whether \var{Instance} is non-nil, or whether
  567. \var{PropInfo} describes a valid ordinal property of \var{Instance}
  568. Specifying an invalid property name in \var{PropName} will result in an
  569. \var{EPropertyError} exception.
  570. \SeeAlso
  571. \seep{SetSetProp}, \seef{GetStrProp}, \seef{GetFloatProp},
  572. \seef{GetInt64Prop},\seef{GetMethodProp}
  573. \end{function}
  574. \FPCexample{ex7}
  575. \begin{function}{GetStrProp}
  576. \Declaration
  577. Function GetStrProp(Instance : TObject;
  578. PropInfo : PPropInfo) : Ansistring;\\
  579. Function GetStrProp(Instance: TObject;
  580. const PropName: string): string;
  581. \Description
  582. \var{GetStrProp} returns the value of the string property described by
  583. \var{PropInfo} or with name \var{PropName} for object \var{Instance}.
  584. \Errors
  585. No checking is done whether \var{Instance} is non-nil, or whether
  586. \var{PropInfo} describes a valid string property of \var{Instance}.
  587. Specifying an invalid property name in \var{PropName} will result in an
  588. \var{EPropertyError} exception.
  589. \SeeAlso
  590. \seep{SetStrProp}, \seef{GetOrdProp}, \seef{GetFloatProp},
  591. \seef{GetInt64Prop},\seef{GetMethodProp}
  592. \end{function}
  593. \FPCexample{ex3}
  594. \begin{function}{GetTypeData}
  595. \Declaration
  596. Function GetTypeData(TypeInfo : PTypeInfo) : PTypeData;
  597. \Description
  598. \var{GetTypeData} returns a pointer to the \var{TTypeData} record that
  599. follows after the \var{TTypeInfo} record pointed to by \var{TypeInfo}.
  600. It essentially skips the \var{Kind} and \var{Name} fields in the
  601. \var{TTypeInfo} record.
  602. \Errors
  603. None.
  604. \SeeAlso
  605. \end{function}
  606. \begin{function}{GetVariantProp}
  607. \Declaration
  608. Function GetVariantProp(Instance : TObject;PropInfo : PPropInfo): Variant;
  609. \Description
  610. Due to mising Variant support, the \var{GetVariantProp} function is not
  611. yet implemented. Provided for Delphi compatibility only.
  612. \Errors
  613. \SeeAlso
  614. \seep{SetVariantProp}
  615. \end{function}
  616. \begin{function}{IsPublishedProp}
  617. \Declaration
  618. Function IsPublishedProp(AClass: TClass; const PropName: string): Boolean;\\
  619. Function IsPublishedProp(Instance: TObject; const PropName: string): Boolean;
  620. \Description
  621. \var{IsPublishedProp} returns true if a class has a published property with
  622. name \var{PropName}. The class can be specfied in one of two ways:
  623. \begin{description}
  624. \item[AClass] A class pointer to the class.
  625. \item[Instance] An instance of the class.
  626. \end{description}
  627. \Errors
  628. No checks are done to ensure \var{Instance} or \var{AClass} are valid
  629. pointers. Specifying an invalid property name in \var{PropName} will result
  630. in an \var{EPropertyError} exception.
  631. \SeeAlso
  632. \seef{IsStoredProp}, \seef{PropIsType}
  633. \end{function}
  634. \FPCexample{ex10}
  635. \begin{function}{IsStoredProp}
  636. \Declaration
  637. Function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;\\
  638. Function IsStoredProp(Instance: TObject; const PropName: string): Boolean;
  639. \Description
  640. \var{IsStoredProp} returns \var{True} if the \var{Stored} modifier evaluates
  641. to \var{True} for the property described by \var{PropInfo} or with name
  642. \var{PropName} for object \var{Instance}.
  643. It returns \var{False} otherwise. If the function returns
  644. \var{True}, this indicates that the property should be written when
  645. streaming the object \var{Instance}.
  646. If there was no \var{stored} modifier in the declaration of the property,
  647. \var{True} will be returned.
  648. \Errors
  649. No checking is done whether \var{Instance} is non-nil, or whether
  650. \var{PropInfo} describes a valid property of \var{Instance}.
  651. Specifying an invalid property name in \var{PropName} will result in an
  652. \var{EPropertyError} exception.
  653. \SeeAlso
  654. \seef{IsPublishedProp}, \seef{PropIsType}
  655. \end{function}
  656. \FPCexample{ex11}
  657. \begin{function}{PropIsType}
  658. \Declaration
  659. Function PropIsType(AClass: TClass;
  660. const PropName: string; TypeKind: TTypeKind): Boolean;\\
  661. Function PropIsType(Instance: TObject;
  662. const PropName: string; TypeKind: TTypeKind): Boolean;
  663. \Description
  664. \var{PropIsType} returns \var{True} if the property with name \var{PropName}
  665. has type \var{TypeKind}. It returns \var{False} otherwise. The class to be
  666. examined can be specified in one of two ways:
  667. \begin{description}
  668. \item[AClass] A class pointer.
  669. \item[Instance] An instance of the class.
  670. \end{description}
  671. \Errors
  672. No checks are done to ensure \var{Instance} or \var{AClass} are valid
  673. pointers.Specifying an invalid property name in \var{PropName} will result
  674. in an \var{EPropertyError} exception.
  675. \SeeAlso
  676. \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropType}
  677. \end{function}
  678. \FPCexample{ex16}
  679. \begin{function}{PropType}
  680. \Declaration
  681. Function PropType(AClass: TClass; const PropName: string): TTypeKind;\\
  682. Function PropType(Instance: TObject; const PropName: string): TTypeKind;
  683. \Description
  684. \var{Proptype} returns the type of the property \var{PropName} for a class.
  685. The class to be examined can be specified in one of 2 ways:
  686. \begin{description}
  687. \item[AClass] A class pointer.
  688. \item[Instance] An instance of the class.
  689. \end{description}
  690. \Errors
  691. No checks are done to ensure \var{Instance} or \var{AClass} are valid
  692. pointers. Specifying an invalid property name in \var{PropName} will result
  693. in an \var{EPropertyError} exception.
  694. \SeeAlso
  695. \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropIsType}
  696. \end{function}
  697. \FPCexample{ex17}
  698. \begin{procedure}{SetEnumProp}
  699. \Declaration
  700. Procedure SetEnumProp(Instance: TObject; const PropInfo: PPropInfo;
  701. const Value: string);\\
  702. Procedure SetEnumProp(Instance: TObject; const PropName: string;
  703. const Value: string);
  704. \Description
  705. \var{SetEnumProp} sets the property described by \var{PropInfo} or with name
  706. \var{PropName} to \var{Value}. \var{Value} must be a string with the name
  707. of the enumerate value, i.e. it can be used as an argument to
  708. \seef{GetEnumValue}.
  709. \Errors
  710. No checks are done to ensure \var{Instance} or \var{PropInfo} are valid
  711. pointers. Specifying an invalid property name in \var{PropName} will result
  712. in an \var{EPropertyError} exception.
  713. \SeeAlso
  714. \seef{GetEnumProp}, \seep{SetStrProp}, \seep{SetFloatProp},
  715. \seep{SetInt64Prop},\seep{SetMethodProp}.
  716. \end{procedure}
  717. For an example, see \seef{GetEnumProp}.
  718. \begin{procedure}{SetFloatProp}
  719. \Declaration
  720. Procedure SetFloatProp(Instance : TObject;
  721. PropInfo : PPropInfo;
  722. Value : Extended);\\
  723. Procedure SetFloatProp(Instance: TObject;
  724. const PropName: string;
  725. Value: Extended);
  726. \Description
  727. \var{SetFloatProp} assigns \var{Value} to the property described by
  728. \var{PropInfo} or with name \var{Propname} for the object \var{Instance}.
  729. \Errors
  730. No checking is done whether \var{Instance} is non-nil, or whether
  731. \var{PropInfo} describes a valid float property of \var{Instance}.
  732. Specifying an invalid property name in \var{PropName} will result in an
  733. \var{EPropertyError} exception.
  734. \SeeAlso
  735. \seef{GetFloatProp}, \seep{SetOrdProp}, \seep{SetStrProp},
  736. \seep{SetInt64Prop},\seep{SetMethodProp}
  737. \end{procedure}
  738. For an example, see \seef{GetFloatProp}.
  739. \begin{procedure}{SetInt64Prop}
  740. \Declaration
  741. Procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo; const Value: Int64);\\
  742. Procedure SetInt64Prop(Instance: TObject; const PropName: string; const Value: Int64);
  743. \Description
  744. \var{SetInt64Prop} assigns \var{Value} to the property of type
  745. \var{Int64} that is described by \var{PropInfo} or with name \var{Propname}
  746. for the object \var{Instance}.
  747. \Errors
  748. No checking is done whether \var{Instance} is non-nil, or whether
  749. \var{PropInfo} describes a valid \var{Int64} property of \var{Instance}.
  750. Specifying an invalid property name in \var{PropName} will result in an
  751. \var{EPropertyError} exception.
  752. \SeeAlso
  753. \seef{GetInt64Prop}, \seef{GetMethodProp}, \seep{SetOrdProp}, \seep{SetStrProp},
  754. \seep{SetFloatProp}
  755. \end{procedure}
  756. For an example, see \seef{GetInt64Prop}.
  757. \begin{procedure}{SetMethodProp}
  758. \Declaration
  759. Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value :
  760. TMethod);\\
  761. Procedure SetMethodProp(Instance: TObject; const PropName: string; const Value: TMethod);
  762. \Description
  763. \var{SetMethodProp} assigns \var{Value} to the method the property described
  764. by \var{PropInfo} or with name \var{Propname} for object \var{Instance}.
  765. The type \var{TMethod} of the \var{Value} parameter is defined in the
  766. \file{SysUtils} unit as:
  767. \begin{verbatim}
  768. TMethod = packed record
  769. Code, Data: Pointer;
  770. end;
  771. \end{verbatim}
  772. \var{Data} should point to the instance of the class with the method \var{Code}.
  773. \Errors
  774. No checking is done whether \var{Instance} is non-nil, or whether
  775. \var{PropInfo} describes a valid method property of \var{Instance}.
  776. Specifying an invalid property name in \var{PropName} will result in an
  777. \var{EPropertyError} exception.
  778. \SeeAlso
  779. \seef{GetMethodProp}, \seep{SetOrdProp}, \seep{SetStrProp},
  780. \seep{SetFloatProp}, \seep{SetInt64Prop}
  781. \end{procedure}
  782. For an example, see \seef{GetMethodProp}.
  783. \begin{procedure}{SetObjectProp}
  784. \Declaration
  785. Procedure SetObjectProp(Instance: TObject;
  786. PropInfo: PPropInfo; Value: TObject);\\
  787. Procedure SetObjectProp(Instance: TObject;
  788. const PropName: string; Value: TObject);
  789. \Description
  790. \var{SetObjectProp} assigns \var{Value} to the the object property described by
  791. \var{PropInfo} or with name \var{Propname} for the object \var{Instance}.
  792. \Errors
  793. No checking is done whether \var{Instance} is non-nil, or whether
  794. \var{PropInfo} describes a valid method property of \var{Instance}.
  795. Specifying an invalid property name in \var{PropName} will result in an
  796. \var{EPropertyError} exception.
  797. \SeeAlso
  798. \seef{GetObjectProp}, \seep{SetOrdProp}, \seep{SetStrProp},
  799. \seep{SetFloatProp}, \seep{SetInt64Prop}, \seep{SetMethodProp}
  800. \end{procedure}
  801. For an example, see \seef{GetObjectProp}.
  802. \begin{procedure}{SetOrdProp}
  803. \Declaration
  804. Procedure SetOrdProp(Instance : TObject; PropInfo : PPropInfo;
  805. Value : Longint);\\
  806. Procedure SetOrdProp(Instance: TObject; const PropName: string;
  807. Value: Longint);
  808. \Description
  809. \var{SetOrdProp} assigns \var{Value} to the the ordinal property described by
  810. \var{PropInfo} or with name \var{Propname} for the object \var{Instance}.
  811. Ordinal properties that can be set include:
  812. \begin{description}
  813. \item[Integers and subranges of integers] The actual value of the integer must be
  814. passed.
  815. \item[Enumerated types and subranges of enumerated types] The ordinal value
  816. of the enumerated type must be passed.
  817. \item[Subrange types] of integers or enumerated types. Here the ordinal
  818. value must be passed.
  819. \item[Sets] If the base type of the set has less than 31 possible values.
  820. For each possible value; the corresponding bit of \var{Value} must be set.
  821. \end{description}
  822. \Errors
  823. No checking is done whether \var{Instance} is non-nil, or whether
  824. \var{PropInfo} describes a valid ordinal property of \var{Instance}.
  825. No range checking is performed.
  826. Specifying an invalid property name in \var{PropName} will result in an
  827. \var{EPropertyError} exception.
  828. \SeeAlso
  829. \seef{GetOrdProp}, \seep{SetStrProp}, \seep{SetFloatProp},
  830. \seep{SetInt64Prop},\seep{SetMethodProp}
  831. \end{procedure}
  832. For an example, see \seef{GetOrdProp}.
  833. \begin{procedure}{SetPropValue}
  834. \Declaration
  835. Procedure SetPropValue(Instance: TObject;
  836. const PropName: string; const Value: Variant);
  837. \Description
  838. Due to missing Variant support, this function is not yet implemented;
  839. it is provided for Delphi compatibility only.
  840. \Errors
  841. \SeeAlso
  842. \end{procedure}
  843. \begin{procedure}{SetSetProp}
  844. \Declaration
  845. Procedure SetSetProp(Instance: TObject;
  846. const PropInfo: PPropInfo; const Value: string);\\
  847. Procedure SetSetProp(Instance: TObject;
  848. const PropName: string; const Value: string);
  849. \Description
  850. \var{SetSetProp} sets the property specified by \var{PropInfo} or
  851. \var{PropName} for object \var{Instance} to \var{Value}. \var{Value} is a
  852. string which contains a comma-separated list of values, each value being a
  853. string-representation of the enumerated value that should be included in
  854. the set. The value should be accepted by the \seef{StringToSet} function.
  855. The value can be formed using the \seef{SetToString} function.
  856. \Errors
  857. No checking is done whether \var{Instance} is non-nil, or whether
  858. \var{PropInfo} describes a valid ordinal property of \var{Instance}.
  859. No range checking is performed.
  860. Specifying an invalid property name in \var{PropName} will result in an
  861. \var{EPropertyError} exception.
  862. \SeeAlso
  863. \seef{GetSetProp}, \seep{SetOrdProp}, \seep{SetStrProp}, \seep{SetFloatProp},
  864. \seep{SetInt64Prop},\seep{SetMethodProp}, \seef{SetToString},
  865. \seef{StringToSet}
  866. \end{procedure}
  867. For an example, see \seef{GetSetProp}.
  868. \begin{procedure}{SetStrProp}
  869. \Declaration
  870. procedure SetStrProp(Instance : TObject; PropInfo : PPropInfo;
  871. const Value : Ansistring);\\
  872. Procedure SetStrProp(Instance: TObject; const PropName: string;
  873. const Value: AnsiString);
  874. \Description
  875. \var{SetStrProp} assigns \var{Value} to the string property described by
  876. \var{PropInfo} or with name \var{Propname} for object \var{Instance}.
  877. \Errors
  878. No checking is done whether \var{Instance} is non-nil, or whether
  879. \var{PropInfo} describes a valid string property of \var{Instance}.
  880. Specifying an invalid property name in \var{PropName} will result in an
  881. \var{EPropertyError} exception.
  882. \SeeAlso
  883. \seef{GetStrProp}, \seep{SetOrdProp}, \seep{SetFloatProp},
  884. \seep{SetInt64Prop},\seep{SetMethodProp}
  885. \end{procedure}
  886. For an example, see \seef{GetStrProp}
  887. \begin{function}{SetToString}
  888. \Declaration
  889. function SetToString(PropInfo: PPropInfo;
  890. Value: Integer) : String;\\
  891. function SetToString(PropInfo: PPropInfo;
  892. Value: Integer; Brackets: Boolean) : String;
  893. \Description
  894. \var{SetToString} takes an integer representation of a set (as received e.g.
  895. by \var{GetOrdProp}) and turns it into a string representing the elements in
  896. the set, based on the type information found in the \var{PropInfo} property
  897. information. By default, the string representation is not surrounded by
  898. square brackets. Setting the \var{Brackets} parameter to \var{True} will
  899. surround the string representation with brackets.
  900. The function returns the string representation of the set.
  901. \Errors
  902. No checking is done to see whether \var{PropInfo} points to valid property
  903. information.
  904. \SeeAlso
  905. \seef{GetEnumName}, \seef{GetEnumValue}, \seef{StringToSet}
  906. \end{function}
  907. \FPCexample{ex18}
  908. \begin{procedure}{SetVariantProp}
  909. \Declaration
  910. Procedure SetVariantProp(Instance : TObject;
  911. PropInfo : PPropInfo;
  912. Const Value: Variant);\\
  913. Procedure SetVariantProp(Instance: TObject;
  914. const PropName: string;
  915. const Value: Variant);
  916. \Description
  917. Due to missing Variant support, this function is not yet implemented.
  918. Provided for Delphi compatibility only.
  919. \Errors
  920. \SeeAlso
  921. \end{procedure}
  922. \begin{function}{StringToSet}
  923. \Declaration
  924. function StringToSet(PropInfo: PPropInfo; const Value: string): Integer;
  925. \Description
  926. \var{StringToSet} converts the string representation of a set in \var{Value}
  927. to a integer representation of the set, using the property information found
  928. in \var{PropInfo}. This property information should point to the property
  929. information of a set property. The function returns the integer
  930. representation of the set. (i.e, the set value, typecast to an integer)
  931. The string representation can be surrounded with square brackets, and must
  932. consist of the names of the elements of the base type of the set. The base
  933. type of the set should be an enumerated type. The elements should be
  934. separated by commas, and may be surrounded by spaces.
  935. each of the names will be fed to the \seef{GetEnumValue} function.
  936. \Errors
  937. No checking is done to see whether \var{PropInfo} points to valid property
  938. information. If a wrong name is given for an enumerated value, then an
  939. \var{EPropertyError} will be raised.
  940. \SeeAlso
  941. \seef{GetEnumName}, \seef{GetEnumValue}, \seef{SetToString}
  942. \end{function}
  943. For an example, see \seef{SetToString}.