Forráskód Böngészése

+ Added ex16 and ex17

michael 24 éve
szülő
commit
6497cd43b7
4 módosított fájl, 103 hozzáadás és 3 törlés
  1. 3 1
      docs/typinfex/README
  2. 24 0
      docs/typinfex/ex16.pp
  3. 24 0
      docs/typinfex/ex17.pp
  4. 52 2
      docs/typinfo.tex

+ 3 - 1
docs/typinfex/README

@@ -21,4 +21,6 @@ ex11.pp This program demonstrates the IsStoredProp function
 ex12.pp This program demonstrates the GetPropInfos function 
 ex12.pp This program demonstrates the GetPropInfos function 
 ex13.pp This program demonstrates the GetPropList function 
 ex13.pp This program demonstrates the GetPropList function 
 ex14.pp This program demonstrates the FindPropInfo 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 - 0
docs/typinfex/ex16.pp

@@ -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 - 0
docs/typinfex/ex17.pp

@@ -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.

+ 52 - 2
docs/typinfo.tex

@@ -454,8 +454,7 @@ If the property \var{PropName} does not exist, \var{Nil} is returned.
 \seep{GetPropInfos},\seef{GetPropList}
 \seep{GetPropInfos},\seef{GetPropList}
 \end{function}
 \end{function}
 
 
-for an example, see most of the other functions.
-
+For an example, see most of the other functions.
 
 
 \begin{procedure}{GetPropInfos}
 \begin{procedure}{GetPropInfos}
 \Declaration
 \Declaration
@@ -596,6 +595,8 @@ in an \var{EPropertyError} exception.
 \seef{IsStoredProp}, \seef{PropIsType}
 \seef{IsStoredProp}, \seef{PropIsType}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex10}
+
 \begin{function}{IsStoredProp}
 \begin{function}{IsStoredProp}
 \Declaration
 \Declaration
 Function IsStoredProp(Instance : TObject;PropInfo : PPropInfo) : Boolean;\\
 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}
 \seef{IsPublishedProp}, \seef{PropIsType}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex11}
+
 \begin{function}{PropIsType}
 \begin{function}{PropIsType}
 \Declaration
 \Declaration
 Function PropIsType(AClass: TClass; 
 Function PropIsType(AClass: TClass; 
@@ -641,6 +644,8 @@ in an \var{EPropertyError} exception.
 \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropType}
 \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropType}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex16}
+
 \begin{function}{PropType}
 \begin{function}{PropType}
 \Declaration
 \Declaration
 Function PropType(AClass: TClass; const PropName: string): TTypeKind;\\
 Function PropType(AClass: TClass; const PropName: string): TTypeKind;\\
@@ -660,6 +665,8 @@ in an \var{EPropertyError} exception.
 \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropIsType}
 \seef{IsPublishedProp}, \seef{IsStoredProp}, \seef{PropIsType}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex17}
+
 \begin{procedure}{SetEnumProp}
 \begin{procedure}{SetEnumProp}
 \Declaration
 \Declaration
 Procedure SetEnumProp(Instance: TObject; const PropInfo: PPropInfo;
 Procedure SetEnumProp(Instance: TObject; const PropInfo: PPropInfo;
@@ -680,6 +687,8 @@ in an \var{EPropertyError} exception.
 \seep{SetInt64Prop},\seep{SetMethodProp}.
 \seep{SetInt64Prop},\seep{SetMethodProp}.
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetEnumProp}.
+
 \begin{procedure}{SetFloatProp}
 \begin{procedure}{SetFloatProp}
 \Declaration
 \Declaration
 Procedure SetFloatProp(Instance : TObject;
 Procedure SetFloatProp(Instance : TObject;
@@ -701,6 +710,9 @@ Specifying an invalid property name in \var{PropName} will result in an
 \seep{SetInt64Prop},\seep{SetMethodProp}
 \seep{SetInt64Prop},\seep{SetMethodProp}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetFloatProp}.
+
+
 \begin{procedure}{SetInt64Prop}
 \begin{procedure}{SetInt64Prop}
 \Declaration
 \Declaration
 Procedure SetInt64Prop(Instance: TObject; PropInfo: PPropInfo; const Value: Int64);\\
 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}
 \seep{SetFloatProp}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetInt64Prop}.
+
+
 \begin{procedure}{SetMethodProp}
 \begin{procedure}{SetMethodProp}
 \Declaration
 \Declaration
 Procedure SetMethodProp(Instance : TObject;PropInfo : PPropInfo; const Value :
 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}
 \seep{SetFloatProp}, \seep{SetInt64Prop}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetMethodProp}.
+
+
 \begin{procedure}{SetObjectProp}
 \begin{procedure}{SetObjectProp}
 \Declaration
 \Declaration
 Procedure SetObjectProp(Instance: TObject; 
 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}
 \seep{SetFloatProp}, \seep{SetInt64Prop}, \seep{SetMethodProp}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetObjectProp}.
+
 \begin{procedure}{SetOrdProp}
 \begin{procedure}{SetOrdProp}
 \Declaration
 \Declaration
 Procedure SetOrdProp(Instance : TObject; PropInfo : PPropInfo; 
 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}
 \seep{SetInt64Prop},\seep{SetMethodProp}
 \end{procedure}
 \end{procedure}
 
 
+
+For an example, see \seef{GetOrdProp}.
+
+
 \begin{procedure}{SetPropValue}
 \begin{procedure}{SetPropValue}
 \Declaration
 \Declaration
 Procedure SetPropValue(Instance: TObject; 
 Procedure SetPropValue(Instance: TObject; 
                        const PropName: string; const Value: Variant);                   
                        const PropName: string; const Value: Variant);                   
 \Description
 \Description
+Due to missing Variant support, this function is not yet implemented;
+it is provided for Delphi compatibility only.
 \Errors
 \Errors
 \SeeAlso
 \SeeAlso
 \end{procedure}
 \end{procedure}
@@ -814,10 +840,27 @@ Procedure SetSetProp(Instance: TObject;
 Procedure SetSetProp(Instance: TObject;
 Procedure SetSetProp(Instance: TObject;
                      const PropName: string; const Value: string);                      
                      const PropName: string; const Value: string);                      
 \Description
 \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
 \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
 \SeeAlso
+\seef{GetSetProp}, \seep{SetOrdProp}, \seep{SetStrProp}, \seep{SetFloatProp},
+\seep{SetInt64Prop},\seep{SetMethodProp}, \seef{SetToString},
+\seef{StringToSet}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetSetProp}.
+
 \begin{procedure}{SetStrProp}
 \begin{procedure}{SetStrProp}
 \Declaration
 \Declaration
 procedure SetStrProp(Instance : TObject; PropInfo : PPropInfo; 
 procedure SetStrProp(Instance : TObject; PropInfo : PPropInfo; 
@@ -827,6 +870,7 @@ Procedure SetStrProp(Instance: TObject; const PropName: string;
 \Description
 \Description
 \var{SetStrProp} assigns \var{Value} to the string property described by
 \var{SetStrProp} assigns \var{Value} to the string property described by
 \var{PropInfo} or with name \var{Propname} for object \var{Instance}. 
 \var{PropInfo} or with name \var{Propname} for object \var{Instance}. 
+
 \Errors
 \Errors
 No checking is done whether \var{Instance} is non-nil, or whether
 No checking is done whether \var{Instance} is non-nil, or whether
 \var{PropInfo} describes a valid string property of \var{Instance}.
 \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}
 \seep{SetInt64Prop},\seep{SetMethodProp}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see \seef{GetStrProp}
+
 \begin{function}{SetToString}
 \begin{function}{SetToString}
 \Declaration
 \Declaration
 function SetToString(PropInfo: PPropInfo; 
 function SetToString(PropInfo: PPropInfo; 
@@ -844,6 +890,10 @@ function SetToString(PropInfo: PPropInfo;
 function SetToString(PropInfo: PPropInfo; 
 function SetToString(PropInfo: PPropInfo; 
                      Value: Integer; Brackets: Boolean) : String;
                      Value: Integer; Brackets: Boolean) : String;
 \Description
 \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
 \Errors
 \SeeAlso
 \SeeAlso
 \end{function}
 \end{function}