- Timestamp:
- 12/16/14 01:48:21 (10 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/multiparamload.cpp
r197 r268 103 103 else if (status==BeforeUnknown) 104 104 { 105 loadObjectNow(&emptyparam); 105 FMprintf("MultiParamLoader","go",FMLV_WARN,"Skipping object '%s'",(const char*)lastunknown); 106 loadObjectNow(&emptyparam,false); 106 107 continue; 107 108 } … … 141 142 break; 142 143 } 144 continue; 143 145 } 144 146 buf=trim(buf); … … 236 238 } 237 239 238 int MultiParamLoader::loadObjectNow(const ExtObject& o )240 int MultiParamLoader::loadObjectNow(const ExtObject& o,bool warn_unknown_fields) 239 241 { 240 242 Param tmp_param; 241 243 ParamInterface *pi=o.getParamInterface(tmp_param); 242 pi->load(file );244 pi->load(file,warn_unknown_fields); 243 245 status=AfterObject; 244 246 return 0; -
cpp/frams/param/multiparamload.h
r197 r268 12 12 13 13 /** This is the general "framsticks-format" file parser for loading multiple objects. 14 The loader can be configured to recognize multiple object types from object headers 14 http://www.framsticks.com/common/formatspec.html 15 The loader can be configured to recognize multiple object types from object headers 15 16 and automatically call ParamInterface::load for the matching class. 16 17 … … 123 124 const SString& getError() {return lasterror;} 124 125 /** Can be used BeforeObject and BeforeUnknown */ 125 int loadObjectNow(ParamInterface *pi ) {return loadObjectNow(ExtObject(pi));}126 int loadObjectNow(const ExtObject &o );126 int loadObjectNow(ParamInterface *pi,bool warn_unknown_fields=true) {return loadObjectNow(ExtObject(pi),warn_unknown_fields);} 127 int loadObjectNow(const ExtObject &o,bool warn_unknown_fields=true); 127 128 /** Can be used BeforeObject */ 128 129 int loadObjectNow() {return loadObjectNow(getObject());} 129 130 /** Can be used BeforeObject and BeforeUnknown. 130 131 Object data will not be loaded. */ 131 int skipObject() {return loadObjectNow(&emptyparam );}132 int skipObject() {return loadObjectNow(&emptyparam,false);} 132 133 /** @return 1 if no errors */ 133 134 int run(); -
cpp/frams/param/param.cpp
r253 r268 371 371 } 372 372 373 int ParamInterface::load(VirtFILE* f )373 int ParamInterface::load(VirtFILE* f,bool warn_unknown_fields) 374 374 { 375 375 SString buf; … … 384 384 p0 = t; while ((*p0 == ' ') || (*p0 == '\t')) p0++; 385 385 if (!*p0) break; 386 if (p0[0]=='#') continue; 386 387 p = strchr(p0, ':'); if (!p) continue; 387 388 p_len = (int)(p - p0); 388 389 loaded = false; 389 if (p_len && ((i = findIdn(p0, p_len)) >= 0) && (!(flags(i)&PARAM_DONTLOAD))) 390 { 390 if (p_len && ((i = findIdn(p0, p_len)) >= 0)) 391 { 392 if (!(flags(i)&PARAM_DONTLOAD)) 393 { 391 394 if (p0[p_len + 1] == '~') 392 395 { … … 404 407 fields_loaded++; 405 408 loaded = true; 406 } 409 } 410 } 411 else if (warn_unknown_fields) 412 { 413 SString name(p0,p_len); 414 FMprintf("ParamInterface","load",FMLV_WARN,"Unknown property '%s' while loading object '%s'",(const char*)name,getName()); 415 } 416 407 417 if ((!loaded) && (p0[p_len + 1] == '~')) 408 418 { // eat unrecognized multiline field -
cpp/frams/param/param.h
r253 r268 158 158 int save(VirtFILE*, const char* altname = NULL, bool force = 0); 159 159 int saveprop(VirtFILE*, int i, const char* p, bool force = 0); 160 int load(VirtFILE* );///< @return the number of fields loaded160 int load(VirtFILE*,bool warn_unknown_fields=true);///< @return the number of fields loaded 161 161 int load2(const SString &, int &);///< @return the number of fields loaded 162 162
Note: See TracChangeset
for help on using the changeset viewer.