Ignore:
Timestamp:
02/06/15 05:58:34 (9 years ago)
Author:
Maciej Komosinski
Message:

More examples of Param loader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/loader_test_param.cpp

    r323 r329  
    1313 After loading, objects are printed ("saved") to standard output.
    1414 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 
    1721 \include loader_test_param.cpp
    1822 */
     
    2226public:
    2327        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;
    2832};
    2933
     
    3135ParamEntry data_paramtab[] =
    3236{
    33         { "Data", 1, 12, "data", },
     37        { "Data", 1, 16, "data", },
    3438        { "text", 0, 0, "Text", "s 0 10", FIELD(text), }, // 10 = length limit
    3539        { "longtext", 0, 0, "Long text", "s 1", FIELD(longtext), }, // 1 = multiline, 0 = unlimited
     
    3842        { "i2", 0, 0, "Integer 2", "d -5 5 1", FIELD(i2), }, // [-5..5] integer, default=1
    3943        { "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
    4045        { "f1", 0, 0, "Float 1", "d", FIELD(f1), },          // unrestricted float
    4146        { "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)
    4351        { "notchanged", 0, PARAM_READONLY, "Read only field", "d", FIELD(notchanged), }, // neither load() nor setDefault() can change this
    4452        { "notloaded", 0, PARAM_DONTLOAD, "Unloadable field", "d", FIELD(notloaded), }, // load() does not change this
     
    6573        Param param(data_paramtab, &data);
    6674
    67         data.notchanged=100;
    68         data.notloaded=200;
     75        data.notchanged = 100;
     76        data.notloaded = 200;
    6977
    7078        loader.addObject(&param);
     
    9199                        for (int i = 0; i < param.getPropCount(); i++)
    92100                                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());
    94103                        fprintf(stderr, "-----\n\n");
    95104                        param.save(&virt_stdout);
Note: See TracChangeset for help on using the changeset viewer.