Changeset 323 for cpp/frams/_demos


Ignore:
Timestamp:
02/02/15 14:53:33 (5 years ago)
Author:
Maciej Komosinski
Message:

Example of skipping an unknown object

Location:
cpp/frams/_demos
Files:
2 edited

Legend:

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

    r316 r323  
    6969
    7070        loader.addObject(&param);
    71         loader.breakOn(MultiParamLoader::OnError + MultiParamLoader::BeforeObject + MultiParamLoader::AfterObject + MultiParamLoader::OnComment);
     71        loader.breakOn(MultiParamLoader::OnError + MultiParamLoader::BeforeObject + MultiParamLoader::AfterObject + MultiParamLoader::OnComment + MultiParamLoader::BeforeUnknown);
    7272
    7373        while (int status = loader.go())
     
    7777                case MultiParamLoader::OnComment:
    7878                        fprintf(stderr, "comment: '%s'\n", (const char*)loader.getComment());
     79                        break;
     80
     81                case MultiParamLoader::BeforeUnknown:
     82                        // At this point we could change our mind and load the unknown object using MultiParamLoader::loadObjectNow() functions.
     83                        // It is "unknown", so we would have to provide its ParamInterface.
     84                        // In fact, this method is used not just for truly unknown objects but also for
     85                        // dynamic objects that cannot be added using MultiParamLoader.addObject().
     86                        fprintf(stderr, "unknown object found: '%s' (will be skipped)\n", (const char*)loader.getObjectName());
    7987                        break;
    8088
  • cpp/frams/_demos/loader_test_param.in

    r316 r323  
    2424x:just x (string extvalue)
    2525
     26someotherdata:
     27this_object:will be ignored
     28because:we only load "data:" objects
     29
    2630data:
    2731text:abcdefghijklmnopqrstuvwxyz
Note: See TracChangeset for help on using the changeset viewer.