Changeset 81 for cpp/gdk/param.cpp
- Timestamp:
- 02/08/13 03:29:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/gdk/param.cpp
r66 r81 283 283 } 284 284 285 void SimpleAbstractParam::save2(SString& f,void *defdata, int addcr)285 void SimpleAbstractParam::save2(SString& f,void *defdata,bool addcr,bool all_names) 286 286 { // defdata!=NULL -> nie zapisuje wartosci domyslnych 287 287 const char *p; … … 303 303 #ifndef SAVE_ALL_NAMES 304 304 #ifdef SAVE_SELECTED_NAMES 305 if (needlabel || !(fl & PARAM_CANOMITNAME))305 if (needlabel || all_names || !(fl & PARAM_CANOMITNAME)) 306 306 #else 307 307 if (needlabel) … … 312 312 { // string - special case 313 313 SString str=getString(i); 314 if (strContainsOneOf(str,", \\\n\r\t "))314 if (strContainsOneOf(str,", \\\n\r\t\"")) 315 315 { 316 316 t+="\""; … … 439 439 } 440 440 441 static bool stringIsNumeric(const char* str) 442 {// /-?.?[0-9]+/ 443 if (!str) return false; 444 if (*str=='-') str++; 445 if (*str=='.') str++; 446 return isdigit(*str); 447 } 448 449 int ParamInterface::setInt(int i,const char* str) 450 { 451 if (!stringIsNumeric(str)) 452 { 453 long a,b,c; 454 if (getMinMax(i,a,b,c)>=3) 455 return setInt(i,c); 456 else 457 return setInt(i,(long)0); 458 } 459 else 460 return setInt(i,atol(str)); 461 } 462 463 int ParamInterface::setDouble(int i,const char* str) 464 { 465 if (!stringIsNumeric(str)) 466 { 467 double a,b,c; 468 if (getMinMax(i,a,b,c)>=3) 469 return setDouble(i,c); 470 else 471 return setDouble(i,(double)0); 472 } 473 else 474 return setDouble(i,atof(str)); 475 } 476 441 477 int ParamInterface::set(int i,const ExtValue &v) 442 478 { 443 479 switch(type(i)[0]) 444 480 { 445 case 'd': return setInt(i,v.getInt());446 case 'f': return setDouble(i,v.getDouble());481 case 'd': if ((v.type==TInt)||(v.type==TDouble)) return setInt(i,v.getInt()); else return setInt(i,(const char*)v.getString()); 482 case 'f': if ((v.type==TInt)||(v.type==TDouble)) return setDouble(i,v.getDouble()); else return setDouble(i,(const char*)v.getString()); 447 483 case 's': { SString t=v.getString(); return setString(i,t); } 448 484 case 'o': return setObject(i,v.getObject()); … … 457 493 switch(type(i)[0]) 458 494 { 459 case 'd': return setInt(i, atol(v));460 case 'f': return setDouble(i, atof(v));495 case 'd': return setInt(i,v); 496 case 'f': return setDouble(i,v); 461 497 case 's': { SString t(v); return setString(i,t); } 462 498 case 'x':
Note: See TracChangeset
for help on using the changeset viewer.