Changeset 796
- Timestamp:
- 06/06/18 00:45:50 (7 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r754 r796 422 422 } 423 423 424 void SimpleAbstractParam::messageOnExceedRangeExtValue(int i, int setflags, ExtValue& valuetoset) ///< prints a warning when setflags indicates that allowed param range has been exceeded during set 425 { 426 if (setflags & (PSET_HITMIN | PSET_HITMAX)) 427 { 428 SString svaluetoset = valuetoset.getString(); //converts any type to SString 429 SString actual = get(i); 430 bool s_type = type(i)[0] == 's'; 431 bool show_length = valuetoset.getType() == TString; 432 const char* quote = (valuetoset.getType() == TString) ? "\"" : "'"; 433 logPrintf("Param", "set", LOG_WARN, "Setting %s.%s = %s exceeded allowed range (too %s). %s to %s.", 434 getName(), id(i), 435 ::sstringDelimitAndShorten(svaluetoset, 30, show_length, quote, quote).c_str(), 436 (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", 437 ::sstringDelimitAndShorten(actual, 30, show_length, quote, quote).c_str() 438 ); 439 } 440 } 441 424 442 int ParamInterface::load(FileFormat format, VirtFILE* f, LoadOptions *options) 425 443 { … … 526 544 fileinfo += SString::sprintf(" (line %d)", *options.linenum); 527 545 } 528 logPrintf("ParamInterface", "load", LOG_WARN, "Multiple '%s.%s' fields found%s", getName(), id(i), fileinfo.c_str());546 logPrintf("ParamInterface", "load", LOG_WARN, "Multiple '%s.%s' properties found%s", getName(), id(i), fileinfo.c_str()); 529 547 } 530 548 else … … 564 582 { 565 583 SString name(p0, p_len); 566 logPrintf("ParamInterface", "load", LOG_WARN, "Ignored unknown property '%s ' while reading object '%s'", name.c_str(), getName());584 logPrintf("ParamInterface", "load", LOG_WARN, "Ignored unknown property '%s.%s'", getName(), name.c_str()); 567 585 } 568 586 … … 640 658 case 'o': ret.setObject(getObject(i)); break; 641 659 case 'x': ret = getExtValue(i); break; 642 default: logPrintf("ParamInterface", "get", LOG_ERROR, "'%s.%s' is not a field", getName(), id(i));660 default: logPrintf("ParamInterface", "get", LOG_ERROR, "'%s.%s' is not a property", getName(), id(i)); 643 661 } 644 662 } … … 710 728 break; 711 729 case 'x': return setExtValue(i, v); 712 default: logPrintf("ParamInterface", "set", LOG_ERROR, "'%s.%s' is not a field", getName(), id(i));730 default: logPrintf("ParamInterface", "set", LOG_ERROR, "'%s.%s' is not a property", getName(), id(i)); 713 731 } 714 732 return 0; … … 1267 1285 { 1268 1286 SString name(t, (int)(equals_sign - t)); 1269 logPrintf("Param", "load 2", LOG_WARN, "Unknown property '%s' while reading object '%s' (ignored)", name.c_str(), getName());1287 logPrintf("Param", "loadSingleLine", LOG_WARN, "Unknown property '%s.%s' (ignored)", getName(), name.c_str()); 1270 1288 } 1271 1289 t = equals_sign + 1; // t=value … … 1278 1296 { 1279 1297 if (id(i)) 1280 logPrintf("Param", "load 2", LOG_WARN, "Missing property name in '%s' (assuming '%s')", getName(), id(i));1298 logPrintf("Param", "loadSingleLine", LOG_WARN, "Missing property name in '%s' (assuming '%s')", getName(), id(i)); 1281 1299 else 1282 logPrintf("Param", "load 2", LOG_WARN, "Value after the last property of '%s'", getName());1300 logPrintf("Param", "loadSingleLine", LOG_WARN, "Value after the last property of '%s'", getName()); 1283 1301 } 1284 1302 #endif … … 1300 1318 ret = setFromString(i, value, true); 1301 1319 fields_loaded++; 1302 if (ret&(PSET_HITMAX | PSET_HITMIN))1303 logPrintf("Param", "load2", LOG_WARN, "Adjusted '%s' in '%s' (was too %s)",1304 id(i), getName(), (ret&PSET_HITMAX) ? "big" : "small");1305 1320 if (ret&PSET_PARSEFAILED) 1306 1321 parse_failed = true; -
cpp/frams/param/param.h
r786 r796 252 252 }; 253 253 254 template<typename T> struct quote_in_messages { constexpr static const char* value = "'"; };255 template<> struct quote_in_messages < SString > { constexpr static const char* value = "\""; };256 template<typename T> struct length_in_messages { static const bool value = false; };257 template<> struct length_in_messages < SString > { static const bool value = true; };258 259 254 class SimpleAbstractParam : public virtual ParamInterface 260 255 { … … 300 295 if (setflags & (PSET_HITMIN | PSET_HITMAX)) 301 296 { 302 SString svaluetoset = SString::valueOf(valuetoset); //converts any type to SString 303 SString actual = get(i); 304 bool s_type = type(i)[0] == 's'; 305 logPrintf("Param", "set", LOG_WARN, "Setting %s.%s = %s exceeded allowed range (too %s). %s to %s.", 306 getName(), id(i), 307 ::sstringDelimitAndShorten(svaluetoset, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str(), 308 (setflags&PSET_HITMAX) ? (s_type ? "long" : "big") : "small", s_type ? "Truncated" : "Adjusted", 309 ::sstringDelimitAndShorten(actual, 30, length_in_messages<T>::value, quote_in_messages<T>::value, quote_in_messages<T>::value).c_str() 310 ); 297 ExtValue v(valuetoset); 298 messageOnExceedRangeExtValue(i, setflags, v); 311 299 } 312 300 } 301 void messageOnExceedRangeExtValue(int i, int setflags, ExtValue& valuetoset); ///< used by messageOnExceedRange() internally 313 302 314 303 int setInt(int, paInt);
Note: See TracChangeset
for help on using the changeset viewer.