瀏覽代碼

+ Added SetToString example

michael 24 年之前
父節點
當前提交
e111767081
共有 3 個文件被更改,包括 35 次插入3 次删除
  1. 1 3
      docs/typinfex/Makefile
  2. 1 0
      docs/typinfex/README
  3. 33 0
      docs/typinfex/ex18.pp

+ 1 - 3
docs/typinfex/Makefile

@@ -33,9 +33,7 @@ endif
 .PHONY: all tex clean
 
 OBJECTS=rttiobj trtti1 trtti2 trtti3 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 \
-        ex10 ex11 ex12 ex13 
-# ex14 
-#        ex15 ex16
+        ex10 ex11 ex12 ex13  ex14 ex15 ex16 ex17 ex18
 
 TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
 

+ 1 - 0
docs/typinfex/README

@@ -24,3 +24,4 @@ ex14.pp This program demonstrates the FindPropInfo 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
+ex18.pp This program demonstrates the SetToString function

+ 33 - 0
docs/typinfex/ex18.pp

@@ -0,0 +1,33 @@
+program example18;
+
+{ This program demonstrates the SetToString function }
+
+{$mode objfpc}
+
+uses rttiobj,typinfo;
+
+Var
+  O : TMyTestObject;
+  PI : PPropInfo;
+  I : longint;    
+  
+begin
+  O:=TMyTestObject.Create;
+  PI:=GetPropInfo(O,'SetField');
+  O.SetField:=[mefirst,meSecond,meThird];
+  I:=GetOrdProp(O,PI);
+  Writeln('Set property to string : ');
+  Writeln('Value  : ',SetToString(PI,I,False));
+  O.SetField:=[mefirst,meSecond];
+  I:=GetOrdProp(O,PI);
+  Writeln('Value  : ',SetToString(PI,I,True));
+  I:=StringToSet(PI,'mefirst');
+  SetOrdProp(O,PI,I);
+  I:=GetOrdProp(O,PI);
+  Writeln('Value  : ',SetToString(PI,I,False));
+  I:=StringToSet(PI,'[mesecond,methird]');
+  SetOrdProp(O,PI,I);
+  I:=GetOrdProp(O,PI);
+  Writeln('Value  : ',SetToString(PI,I,True));
+  O.Free;
+end.