Changeset 393 for cpp/frams/param
- Timestamp:
- 06/03/15 17:57:46 (9 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r375 r393 529 529 paInt mn, mx, def; 530 530 if (getMinMax(i, mn, mx, def) >= 3) 531 return setInt(i, def) ;531 return setInt(i, def) | PSET_PARSEFAILED; 532 532 else 533 return setInt(i, (paInt)0) ;533 return setInt(i, (paInt)0) | PSET_PARSEFAILED; 534 534 } 535 535 else … … 544 544 double mn, mx, def; 545 545 if (getMinMax(i, mn, mx, def) >= 3) 546 return setDouble(i, def) ;546 return setDouble(i, def) | PSET_PARSEFAILED; 547 547 else 548 return setDouble(i, (double)0) ;548 return setDouble(i, (double)0) | PSET_PARSEFAILED; 549 549 } 550 550 else … … 1013 1013 const char *value, *valstop; 1014 1014 SString tmpvalue; 1015 bool parse_failed=false; 1015 1016 if (poz >= s.len()) return fields_loaded; 1016 1017 t = s.c_str() + poz; … … 1038 1039 { 1039 1040 field_end = strchrlimit(quote2 + 1, ',', end); 1040 if (!field_end) next_field = field_end = end; 1041 if (!field_end) field_end = end; 1042 next_field = field_end; 1041 1043 } 1042 1044 equals_sign = strchrlimit(t, '=', quote); … … 1094 1096 logPrintf("Param", "load2", LOG_WARN, "Adjusted '%s' in '%s' (was too %s)", 1095 1097 id(i), getName(), (ret&PSET_HITMAX) ? "big" : "small"); 1098 if (ret&PSET_PARSEFAILED) 1099 parse_failed=true; 1096 1100 *(char*)valstop = remember; 1097 1101 } … … 1104 1108 #endif 1105 1109 } 1106 return fields_loaded ;1110 return fields_loaded | (parse_failed ? LOAD2_PARSE_FAILED : 0); 1107 1111 } 1108 1112 -
cpp/frams/param/param.h
r382 r393 50 50 #define PSET_HITMAX 8 51 51 52 #define PSET_NOPROPERTY 16 53 54 #define PSET_PARSEFAILED 32 55 52 56 // useful combination: need to get and display the value so that a user knows that the value they tried to set has been rejected or changed 53 #define PSET_WARN (PSET_RONLY | PSET_HITMIN | PSET_HITMAX) 54 55 #define PSET_NOPROPERTY 16 57 #define PSET_WARN (PSET_RONLY | PSET_HITMIN | PSET_HITMAX | PSET_PARSEFAILED) 58 56 59 57 60 struct ParamEntry; … … 162 165 int saveprop(VirtFILE*, int i, const char* p, bool force = 0); 163 166 int load(VirtFILE*, bool warn_unknown_fields = true, bool *abortable = NULL, int *linenum = NULL);///< @return the number of fields loaded 164 int load2(const SString &, int &);///< @return the number of fields loaded 167 int load2(const SString &, int &);///< @return the number of fields loaded (or'ed with LOAD2_PARSE_FAILED if a parsing error was detected) 165 168 166 169 static const char* SERIALIZATION_PREFIX; 170 static const int LOAD2_PARSE_FAILED=(1<<30); ///< this bit is set in return value from load2 if a parse error was detected while loading. usage: if (load2(...) & LOAD2_PARSE_FAILED) ... 171 static const int LOAD2_IGNORE_PARSE_FAILED=(~LOAD2_PARSE_FAILED); ///< bitmask to be used if the parsing error is to be ignored. usage: int number_of_loaded_fields=load2(...) & LOAD2_IGNORE_PARSE_FAILED; 167 172 168 173 #ifdef DEBUG
Note: See TracChangeset
for help on using the changeset viewer.