Changeset 645 for cpp/frams/param


Ignore:
Timestamp:
12/31/16 20:35:12 (6 years ago)
Author:
Maciej Komosinski
Message:

f0 is strict now, will not accept float when int is expected

Location:
cpp/frams/param
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r640 r645  
    574574}
    575575
    576 int ParamInterface::setInt(int i, const char* str)
     576int ParamInterface::setInt(int i, const char* str, bool strict)
    577577{
    578578        paInt value;
    579         if (!ExtValue::parseInt(str, value, false, true))
     579        if (!ExtValue::parseInt(str, value, strict, true))
    580580        {
    581581                paInt mn, mx, def;
     
    645645}
    646646
    647 int ParamInterface::set(int i, const char *v)
     647int ParamInterface::set(int i, const char *v, bool strict)
    648648{
    649649        char typ = type(i)[0];
    650650        switch (typ)
    651651        {
    652         case 'd': return setInt(i, v);
     652        case 'd': return setInt(i, v, strict);
    653653        case 'f': return setDouble(i, v);
    654654        case 's': { SString t(v); return setString(i, t); }
     
    745745        {
    746746        case 'd': t+="integer";
    747         {paInt a,b,c; int n=getMinMax(type,a,b,c); if (n>=2) t+=SString::sprintf(" %d..%d",a,b); if (n>=3) t+=SString::sprintf(" (default %d)",c);}
     747        {paInt a,b,c; int n=getMinMax(type,a,b,c); if ((n>=2)&&(b>=a)) t+=SString::sprintf(" %d..%d",a,b); if (n>=3) t+=SString::sprintf(" (default %d)",c);}
    748748        break;
    749749        case 'f': t+="float";
    750         {double a,b,c; int n=getMinMax(type,a,b,c); if (n>=2) t+=SString::sprintf(" %g..%g",a,b); if (n>=3) t+=SString::sprintf(" (default %g)",c);}
     750        {double a,b,c; int n=getMinMax(type,a,b,c); if ((n>=2)&&(b>=a)) t+=SString::sprintf(" %g..%g",a,b); if (n>=3) t+=SString::sprintf(" (default %g)",c);}
    751751        break;
    752752        case 's': t+="string";
     
    12021202                        remember = *valstop;
    12031203                        *(char*)valstop = 0;
    1204                         ret = set(i, value);
     1204                        ret = set(i, value, true);
    12051205                        fields_loaded++;
    12061206                        if (ret&(PSET_HITMAX | PSET_HITMIN))
  • cpp/frams/param/param.h

    r640 r645  
    118118        ExtValue getById(const char* prop);
    119119
    120         int setInt(int i, const char* str);
     120        int setInt(int i, const char* str, bool strict=false);
    121121        int setDouble(int i, const char* str);
    122122        virtual int setInt(int, paInt) = 0;             ///< set long value, you can only use this for "d" type prop
     
    128128        int set(int, const ExtValue &);///< most universal set, can be used for every datatype
    129129
    130         int set(int, const char*);              ///< oldstyle set, can convert string to long or double
     130        int set(int, const char*, bool strict=false);           ///< oldstyle set, can convert string to long or double
    131131
    132132        int setIntById(const char* prop, paInt);///< set long value, you can only use this for "d" type prop
Note: See TracChangeset for help on using the changeset viewer.