Changeset 535 for cpp/frams


Ignore:
Timestamp:
07/20/16 14:57:12 (5 years ago)
Author:
Maciej Komosinski
Message:
  • More strict type description checking when adding a property in mutableparam
  • Error message when the param property could not be added for some reason
Location:
cpp/frams/param
Files:
5 edited

Legend:

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

    r523 r535  
    290290return 1;
    291291}
     292
     293SString MultiParamLoader::currentFilePathForErrorMessage()
     294{
     295const char* filename=getFile()->VgetPath();
     296if (filename)
     297        return SString::sprintf(" in '%s'",filename);
     298return SString::empty();
     299}
  • cpp/frams/param/multiparamload.h

    r382 r535  
    9090
    9191VirtFILE *getFile() {return file;}
     92SString currentFilePathForErrorMessage();
    9293
    9394/** Abort immediately and close the file if needed */
  • cpp/frams/param/mutableparam.cpp

    r478 r535  
    169169{
    170170if ((!id)&&(!type)) return -1;
     171if (!isValidTypeDescription(type)) return -1;
    171172ParamEntry *pe=new ParamEntry();
    172173pe->fun1=0; pe->fun2=0;
  • cpp/frams/param/param.cpp

    r533 r535  
    710710}
    711711
     712bool ParamInterface::isValidTypeDescription(const char* t)
     713{
     714if (t==NULL) return false;
     715if (*t==0) return false;
     716if (strchr("dfsoxp", *t)==NULL) return false;
     717return true;
     718}
    712719
    713720//////////////////////////////// PARAM ////////////////////////////////////
     
    721728        const char* err=NULL;
    722729
     730        if (!isValidTypeDescription(t))
     731                err="invalid type description";
    723732        if (*t=='p')
    724733        {
  • cpp/frams/param/param.h

    r483 r535  
    172172        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;
    173173
     174        static bool isValidTypeDescription(const char* t);
    174175#ifdef _DEBUG
    175176        virtual void sanityCheck(int i) {}
Note: See TracChangeset for help on using the changeset viewer.