Changeset 640 for cpp/frams


Ignore:
Timestamp:
12/05/16 02:31:34 (7 years ago)
Author:
Maciej Komosinski
Message:

Introduced a separate function to provide a human-friendly description of a given param-item type

Location:
cpp/frams
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/modelparts.cpp

    r637 r640  
    159159                {
    160160                if (i) t+="\n";
    161                 t+="   "; t+=p.name(i); t+=" ("; t+=p.id(i); t+=")";
    162                 switch(*p.type(i))
    163                         {
    164                         case 'd': t+=" integer";
    165                         {paInt a,b,c; int n=p.getMinMax(i,a,b,c); if (n>=2) t+=SString::sprintf(" %d..%d",a,b); if (n>=3) t+=SString::sprintf(" (default %d)",c);}
    166                                 break;
    167                         case 'f': t+=" float";
    168                         {double a,b,c; int n=p.getMinMax(i,a,b,c); if (n>=2) t+=SString::sprintf(" %g..%g",a,b); if (n>=3) t+=SString::sprintf(" (default %g)",c);}
    169                                 break;
    170                         case 's': t+=" string";
    171                         {int a,b; SString c; int n=p.getMinMax(i,a,b,c); if ((n>=2)&&(b>0)) t+=SString::sprintf(", max %d chars",b); if (n>=3) t+=SString::sprintf(" (default \"%s\")",c.c_str());}
    172                                 break;
    173                         case 'x': t+=" anything"; break;
    174                         }
     161                t+="   "; t+=p.name(i); t+=" ("; t+=p.id(i); t+=") ";
     162                t+=p.describeType(i);
    175163                if (h=p.help(i)) if (*h) {t+=" - "; t+=h;}
    176164                }
  • cpp/frams/param/param.cpp

    r574 r640  
    739739}
    740740
     741SString ParamInterface::describeType(const char* type)
     742{
     743SString t;
     744switch(type[0])
     745        {
     746        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);}
     748        break;
     749        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);}
     751        break;
     752        case 's': t+="string";
     753        {int a,b; SString c; int n=getMinMax(type,a,b,c); if ((n>=2)&&(b>0)) t+=SString::sprintf(", max %d chars",b); if (n>=3) t+=SString::sprintf(" (default \"%s\")",c.c_str());}
     754        break;
     755        case 'x': t+="untyped value"; break;
     756        case 'p': t+="function"; break;
     757        case 'o': t+="object"; if (type[1]) {t+=" of class "; t+=type+1;} break;
     758        default: return "unknown type";
     759        }
     760return t;
     761}
     762
    741763//////////////////////////////// PARAM ////////////////////////////////////
    742764
  • cpp/frams/param/param.h

    r574 r640  
    155155        void setMax(int i);
    156156
     157        /** return the human readable description of the given type */
     158        static SString describeType(const char* type);
     159        SString describeType(int i) {return describeType(type(i));}
     160       
    157161        /** copy all property values from other ParamInterface object */
    158162        void copyFrom(ParamInterface *src);
Note: See TracChangeset for help on using the changeset viewer.