+ Added ex16 and ex17

This commit is contained in:
michael 2001-09-05 22:18:41 +00:00
parent 3b4b673069
commit 6497cd43b7
4 changed files with 103 additions and 3 deletions

View File

@ -21,4 +21,6 @@ ex11.pp This program demonstrates the IsStoredProp function
ex12.pp This program demonstrates the GetPropInfos function
ex13.pp This program demonstrates the GetPropList function
ex14.pp This program demonstrates the FindPropInfo function
ex15.pp This program demonstrates the GetInt64Prop function
ex15.pp This program demonstrates the GetInt64Prop function
ex16.pp This program demonstrates the PropIsType function
ex17.pp This program demonstrates the PropType function

24
docs/typinfex/ex16.pp Normal file
View File

@ -0,0 +1,24 @@
program example16;
{ This program demonstrates the PropIsType function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
begin
O:=TMyTestObject.Create;
Writeln('Property tests : ');
Write('PropIsType(O,BooleanField,tkBool) : ');
Writeln(PropIsType(O,'BooleanField',tkBool));
Write('PropIsType(Class,BooleanField,tkBool) : ');
Writeln(PropIsType(O.ClassType,'BooleanField',tkBool));
Write('PropIsType(O,ByteField,tkString) : ');
Writeln(PropisType(O,'ByteField',tkString));
Write('PropIsType(Class,ByteField,tkString) : ');
Writeln(PropIsType(O.ClassType,'ByteField',tkString));
O.Free;
end.

24
docs/typinfex/ex17.pp Normal file
View File

@ -0,0 +1,24 @@
program example17;
{ This program demonstrates the PropType function }
{$mode objfpc}
uses rttiobj,typinfo;
Var
O : TMyTestObject;
begin
O:=TMyTestObject.Create;
Writeln('Property tests : ');
Write('PropType(O,BooleanField) : ');
Writeln(TypeNames[PropType(O,'BooleanField')]);
Write('PropType(Class,BooleanField) : ');
Writeln(TypeNames[PropType(O.ClassType,'BooleanField')]);
Write('PropType(O,ByteField) : ');
Writeln(TypeNames[PropType(O,'ByteField')]);
Write('PropType(Class,ByteField) : ');
Writeln(TypeNames[PropType(O.ClassType,'ByteField')]);
O.Free;
end.

View File

@ -454,8 +454,7 @@ If the property \var{PropName} does not exist, \var{Nil} is returned.
\seep{GetPropInfos},\seef{GetPropList}
\end{function}
for an example, see most of the other functions.
For an example, see most of the other functions.
\begin{procedure}{GetPropInfos}
\Declaration
@ -596,6 +595,8 @@ in an \var{EPropertyError} exception.
\seef{IsStoredProp}, \seef{PropIsType}
\end{function}
\FPCexample{ex10}
\begin{function}{IsStoredProp}
\Declaration
Function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;\\
@ -619,6 +620,8 @@ Specifying an invalid property name in \var{PropName} will result in an
\seef{IsPublishedProp}, \seef{PropIsType}
\end{function}
\FPCexample{ex11}
\begin{function}{PropIsType}
\Declaration
Function PropIsType(AClass: TClass;
@ -641,6 +644,8 @@ in an \var{EPropertyError} exception.
\seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropType}
\end{function}
\FPCexample{ex16}
\begin{function}{PropType}
\Declaration
Function PropType(AClass: TClass; const PropName: string): TTypeKind;\\
@ -660,6 +665,8 @@ in an \var{EPropertyError} exception.
\seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropIsType}
\end{function}
\FPCexample{ex17}
\begin{procedure}{SetEnumProp}
\Declaration
Procedure SetEnumProp(Instance: TObject; const PropInfo: PPropInfo;
@ -680,6 +687,8 @@ in an \var{EPropertyError} exception.
\seep{SetInt64Prop},\seep{SetMethodProp}.
\end{procedure}
For an example, see \seef{GetEnumProp}.
\begin{procedure}{SetFloatProp}
\Declaration
Procedure SetFloatProp(Instance : TObject;
@ -701,6 +710,9 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetInt64Prop},\seep{SetMethodProp}
\end{procedure}
For an example, see \seef{GetFloatProp}.
\begin{procedure}{SetInt64Prop}
\Declaration
Procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo; const Value: Int64);\\
@ -719,6 +731,9 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetFloatProp}
\end{procedure}
For an example, see \seef{GetInt64Prop}.
\begin{procedure}{SetMethodProp}
\Declaration
Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value :
@ -747,6 +762,9 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetFloatProp}, \seep{SetInt64Prop}
\end{procedure}
For an example, see \seef{GetMethodProp}.
\begin{procedure}{SetObjectProp}
\Declaration
Procedure SetObjectProp(Instance: TObject;
@ -766,6 +784,8 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetFloatProp}, \seep{SetInt64Prop}, \seep{SetMethodProp}
\end{procedure}
For an example, see \seef{GetObjectProp}.
\begin{procedure}{SetOrdProp}
\Declaration
Procedure SetOrdProp(Instance : TObject; PropInfo : PPropInfo;
@ -798,11 +818,17 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetInt64Prop},\seep{SetMethodProp}
\end{procedure}
For an example, see \seef{GetOrdProp}.
\begin{procedure}{SetPropValue}
\Declaration
Procedure SetPropValue(Instance: TObject;
const PropName: string; const Value: Variant);
\Description
Due to missing Variant support, this function is not yet implemented;
it is provided for Delphi compatibility only.
\Errors
\SeeAlso
\end{procedure}
@ -814,10 +840,27 @@ Procedure SetSetProp(Instance: TObject;
Procedure SetSetProp(Instance: TObject;
const PropName: string; const Value: string);
\Description
\var{SetSetProp} sets the property specified by \var{PropInfo} or
\var{PropName} for object \var{Instance} to \var{Value}. \var{Value} is a
string which contains a comma-separated list of values, each value being a
string-representation of the enumerated value that should be included in
the set. The value should be accepted by the \seef{StringToSet} function.
The value can be formed using the \seef{SetToString} function.
\Errors
No checking is done whether \var{Instance} is non-nil, or whether
\var{PropInfo} describes a valid ordinal property of \var{Instance}.
No range checking is performed.
Specifying an invalid property name in \var{PropName} will result in an
\var{EPropertyError} exception.
\SeeAlso
\seef{GetSetProp}, \seep{SetOrdProp}, \seep{SetStrProp}, \seep{SetFloatProp},
\seep{SetInt64Prop},\seep{SetMethodProp}, \seef{SetToString},
\seef{StringToSet}
\end{procedure}
For an example, see \seef{GetSetProp}.
\begin{procedure}{SetStrProp}
\Declaration
procedure SetStrProp(Instance : TObject; PropInfo : PPropInfo;
@ -827,6 +870,7 @@ Procedure SetStrProp(Instance: TObject; const PropName: string;
\Description
\var{SetStrProp} assigns \var{Value} to the string property described by
\var{PropInfo} or with name \var{Propname} for object \var{Instance}.
\Errors
No checking is done whether \var{Instance} is non-nil, or whether
\var{PropInfo} describes a valid string property of \var{Instance}.
@ -837,6 +881,8 @@ Specifying an invalid property name in \var{PropName} will result in an
\seep{SetInt64Prop},\seep{SetMethodProp}
\end{procedure}
For an example, see \seef{GetStrProp}
\begin{function}{SetToString}
\Declaration
function SetToString(PropInfo: PPropInfo;
@ -844,6 +890,10 @@ function SetToString(PropInfo: PPropInfo;
function SetToString(PropInfo: PPropInfo;
Value: Integer; Brackets: Boolean) : String;
\Description
\var{SetToString} takes an integer representation of a set (as received e.g.
by \var{GetOrdProp}) and turns it into a string representing the elements in
the set, based on the type information found in the \var{PropInfo} property
information.
\Errors
\SeeAlso
\end{function}