Changeset 329 for cpp/frams/_demos
- Timestamp:
- 02/06/15 05:58:34 (10 years ago)
- Location:
- cpp/frams/_demos
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/loader_test_param.cpp
r323 r329 13 13 After loading, objects are printed ("saved") to standard output. 14 14 Additional information and messages are printed to standard error. 15 You can redirect both streams if needed. 16 15 You can redirect one or both streams if needed. 16 17 A sample input file for this program is "loader_test_param.in", 18 so you can run this program from the "cpp" directory as 19 ./loader_test_param frams/_demos/loader_test_param.in 20 17 21 \include loader_test_param.cpp 18 22 */ … … 22 26 public: 23 27 SString text, longtext, deftext; 24 int i1, i2, i3;25 float f1, f2, f3;26 ExtValue x ;27 int notchanged, notloaded,notsaved;28 paInt i1, i2, i3, i4; 29 double f1, f2, f3, f4; 30 ExtValue x1, x2; 31 int notchanged, notloaded, notsaved; 28 32 }; 29 33 … … 31 35 ParamEntry data_paramtab[] = 32 36 { 33 { "Data", 1, 1 2, "data", },37 { "Data", 1, 16, "data", }, 34 38 { "text", 0, 0, "Text", "s 0 10", FIELD(text), }, // 10 = length limit 35 39 { "longtext", 0, 0, "Long text", "s 1", FIELD(longtext), }, // 1 = multiline, 0 = unlimited … … 38 42 { "i2", 0, 0, "Integer 2", "d -5 5 1", FIELD(i2), }, // [-5..5] integer, default=1 39 43 { "i3", 0, 0, "Integer 3", "d -1 3 0 ~Minus~Zero~One~Two~Three", FIELD(i3), }, // [0..3] + text labels (Param::getText()) 44 { "i4", 0, 0, "Integer 4", "d 0 10 15", FIELD(i4), }, // invalid default 40 45 { "f1", 0, 0, "Float 1", "d", FIELD(f1), }, // unrestricted float 41 46 { "f2", 0, 0, "Float 2", "f -100 100 -100", FIELD(f2), }, // [-100..100] float, default=-100 42 { "x", 0, 0, "Untyped", "x", FIELD(x), }, // any type (class ExtValue) 47 { "f3", 0, 0, "Float 3", "f -10 10", FIELD(f3), }, // [-10..10] float 48 { "f4", 0, 0, "Float 4", "f 1 -1 404", FIELD(f4), }, // unrestricted float (invalid min>max), default=44 49 { "x1", 0, 0, "Untyped 1", "x", FIELD(x1), }, // any type (class ExtValue) 50 { "x2", 0, 0, "Untyped 2", "x", FIELD(x2), }, // any type (class ExtValue) 43 51 { "notchanged", 0, PARAM_READONLY, "Read only field", "d", FIELD(notchanged), }, // neither load() nor setDefault() can change this 44 52 { "notloaded", 0, PARAM_DONTLOAD, "Unloadable field", "d", FIELD(notloaded), }, // load() does not change this … … 65 73 Param param(data_paramtab, &data); 66 74 67 data.notchanged =100;68 data.notloaded =200;75 data.notchanged = 100; 76 data.notloaded = 200; 69 77 70 78 loader.addObject(¶m); … … 91 99 for (int i = 0; i < param.getPropCount(); i++) 92 100 fprintf(stderr, "%s=%s\n", param.id(i), (const char*)param.getText(i)); 93 fprintf(stderr, "type of 'x' is: %s\n", (const char*)data.x.typeDescription()); 101 fprintf(stderr, "type of 'x1' is: %s\n", (const char*)data.x1.typeDescription()); 102 fprintf(stderr, "type of 'x2' is: %s\n", (const char*)data.x2.typeDescription()); 94 103 fprintf(stderr, "-----\n\n"); 95 104 param.save(&virt_stdout); -
cpp/frams/_demos/loader_test_param.in
r323 r329 6 6 Long multiline text 7 7 1\\~ 8 22\~ 8 22\~\n 9 9 333\ \\ 10 10 4444~ 11 11 deftext:other 12 12 i1:-12345 13 i2: 1013 i2:-0X10 14 14 i3:2 15 f4:22222 16 f3:2222 17 f2:222 15 18 f1:22 16 f2:222 17 x:3.14 19 f4:2 20 x1:3.14 21 x2:314 18 22 notloaded:44 19 unchanged:44423 notchanged:444 20 24 notsaved:4444 25 nosuchfield:value 21 26 22 #all fields except x will have default values27 #all fields except x1 will have default values 23 28 data: 24 x :just x (string extvalue)29 x1:just x (string extvalue) 25 30 26 31 someotherdata: … … 30 35 data: 31 36 text:abcdefghijklmnopqrstuvwxyz 32 i1: uu37 i1:notanumber 33 38 i2:-99999 34 i3:99999 35 x:@Serialized:[1,2,3,1.00000,2e0,3.0,"x","]","\""] 39 i3:+99999 40 i4:notanumber_with_default 41 f1:-0x100 42 f2:-1e 43 f3:+1e1 44 f4:1ee 45 x1:@Serialized:[1,2,3,1.00000,2e0,3.0,"x","]","\""] 46 x2:@Serialized:{"a":[1,2,3],"b":"abc","c":1.23} 36 47 37 48 data: 38 i1: 0x10049 i1:+0X10 39 50 i2:1e2 40 51 i3:-10 41 x:@Serialized:{"a":[1,2,3],"b":"abc","c":1.23} 52 x1:next line will overwrite this 53 x1:@Serialized:{"a":[1,2,3],"b":^1,"c":^1} 54 x2:@Serialized:[[100,^1],["abc"],[300,^2]] 55 i3:5
Note: See TracChangeset
for help on using the changeset viewer.