Changeset 311 for cpp


Ignore:
Timestamp:
01/26/15 07:31:30 (10 years ago)
Author:
Maciej Komosinski
Message:

More fields and test cases

Location:
cpp/frams/_demos
Files:
2 edited

Legend:

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

    r308 r311  
    2121{
    2222public:
    23         SString text, longtext;
     23        SString text, longtext, deftext;
    2424        int i1, i2, i3;
    2525        float f1, f2, f3;
    2626        ExtValue x;
     27        int notchanged,notloaded,notsaved;
    2728};
    2829
     
    3031ParamEntry data_paramtab[] =
    3132{
    32         { "Data", 1, 8, "data", },
     33        { "Data", 1, 12, "data", },
    3334        { "text", 0, 0, "Text", "s 0 10", FIELD(text), }, // 10 = length limit
    3435        { "longtext", 0, 0, "Long text", "s 1", FIELD(longtext), }, // 1 = multiline, 0 = unlimited
     36        { "deftext", 0, 0, "Text with default value", "s 0 0 some text", FIELD(deftext), },
    3537        { "i1", 0, 0, "Integer 1", "d", FIELD(i1), },          // unrestricted integer
    3638        { "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())
     39        { "i3", 0, 0, "Integer 3", "d -1 3 0 ~Minus~Zero~One~Two~Three", FIELD(i3), }, // [0..3] + text labels (Param::getText())
    3840        { "f1", 0, 0, "Float 1", "d", FIELD(f1), },          // unrestricted float
    3941        { "f2", 0, 0, "Float 2", "f -100 100 -100", FIELD(f2), }, // [-100..100] float, default=-100
    4042        { "x", 0, 0, "Untyped", "x", FIELD(x), }, // any type (class ExtValue)
     43        { "notchanged", 0, PARAM_READONLY, "Read only field", "d", FIELD(notchanged), }, // neither load() nor setDefault() can change this
     44        { "notloaded", 0, PARAM_DONTLOAD, "Unloadable field", "d", FIELD(notloaded), }, // load() does not change this
     45        { "notsaved", 0, PARAM_DONTSAVE, "Unsaveable field", "d", FIELD(notsaved), }, // save() skips this field
    4146        { 0, 0, 0, },
    4247};
     
    5964        Data data;
    6065        Param param(data_paramtab, &data);
     66
     67        data.notchanged=100;
     68        data.notloaded=200;
    6169
    6270        loader.addObject(&param);
     
    8290                case MultiParamLoader::BeforeObject:
    8391                        fprintf(stderr, "----- object found, loading...\n");
     92                        data.notchanged++;
    8493                        param.setDefault(); //reset (initialize) struct contents
    8594                        break;
  • cpp/frams/_demos/loader_test_param.in

    r307 r311  
    99333\ \\
    10104444~
     11deftext:other
    1112i1:-12345
    1213i2:10
     
    1516f2:222
    1617x:3.14
     18notloaded:44
     19unchanged:444
     20notsaved:4444
    1721
    1822#all fields except x will have default values
     
    2529i2:-99999
    2630i3:99999
     31x:@Serialized:[1,2,3,1.00000,2e0,3.0,"x","]","\""]
    2732
     33data:
     34i1:0x100
     35i2:1e2
     36i3:-10
     37x:@Serialized:{"a":[1,2,3],"b":"abc","c":1.23}
Note: See TracChangeset for help on using the changeset viewer.