- Timestamp:
- 01/26/15 04:16:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/loader_test_param.cpp
r307 r308 3 3 // See LICENSE.txt for details. 4 4 5 #include "genotypeloader.h"5 #include <frams/param/multiparamload.h> 6 6 #include <frams/virtfile/stdiofile.h> 7 7 #include <frams/errmgr/stdouterr.h> … … 9 9 /** 10 10 @file 11 Sample code: Loading framsticks "objects" (well... structs) 11 Sample code: Loading Framsticks "objects" (structures). 12 13 After loading, objects are printed ("saved") to standard output. 14 Additional information and messages are printed to standard error. 15 You can redirect both streams if needed. 12 16 13 17 \include loader_test_param.cpp … … 30 34 { "longtext", 0, 0, "Long text", "s 1", FIELD(longtext), }, // 1 = multiline, 0 = unlimited 31 35 { "i1", 0, 0, "Integer 1", "d", FIELD(i1), }, // unrestricted integer 32 { "i2", 0, 0, "Integer 1", "d -5 5 1", FIELD(i2), }, // [-5..5] integer, default=133 { "i3", 0, 0, "Integer 1", "d 0 3 0 ~Zero~One~Two~Three", FIELD(i3), }, // [0..3] + text labels (Param::getText())36 { "i2", 0, 0, "Integer 2", "d -5 5 1", FIELD(i2), }, // [-5..5] integer, default=1 37 { "i3", 0, 0, "Integer 3", "d 0 3 0 ~Zero~One~Two~Three", FIELD(i3), }, // [0..3] + text labels (Param::getText()) 34 38 { "f1", 0, 0, "Float 1", "d", FIELD(f1), }, // unrestricted float 35 39 { "f2", 0, 0, "Float 2", "f -100 100 -100", FIELD(f2), }, // [-100..100] float, default=-100 … … 48 52 49 53 StdioFILEDontClose virt_stderr(stderr); 54 StdioFILEDontClose virt_stdout(stdout); 50 55 StdoutErrorHandler error_handler(0, &virt_stderr); 51 56 StdioFileSystem_autoselect stdiofilesys; … … 63 68 { 64 69 case MultiParamLoader::OnComment: 65 printf("comment: %s\n", (const char*)loader.getComment());70 fprintf(stderr, "comment: %s\n", (const char*)loader.getComment()); 66 71 break; 67 72 68 73 case MultiParamLoader::AfterObject: 69 printf("loaded:\n");74 fprintf(stderr, "loaded:\n"); 70 75 for (int i = 0; i < param.getPropCount(); i++) 71 printf("%s=%s\n", param.id(i), (const char*)param.getText(i)); 72 printf("type of 'x' is: %s\n", (const char*)data.x.typeDescription()); 73 printf("-----\n\n"); 76 fprintf(stderr, "%s=%s\n", param.id(i), (const char*)param.getText(i)); 77 fprintf(stderr, "type of 'x' is: %s\n", (const char*)data.x.typeDescription()); 78 fprintf(stderr, "-----\n\n"); 79 param.save(&virt_stdout); 74 80 break; 75 81 76 82 case MultiParamLoader::BeforeObject: 77 printf("----- object found, loading...\n");83 fprintf(stderr, "----- object found, loading...\n"); 78 84 param.setDefault(); //reset (initialize) struct contents 79 85 break; 80 86 81 case M iniGenotypeLoader::OnError:87 case MultiParamLoader::OnError: 82 88 fprintf(stderr, "Error: %s", (const char*)loader.getError()); 83 89 } 84 90 } 91 return 0; 85 92 }
Note: See TracChangeset
for help on using the changeset viewer.