Changeset 640 for cpp/frams/param


Ignore:
Timestamp:
12/05/16 02:31:34 (8 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/param
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.