Changeset 144 for cpp/frams/param
- Timestamp:
- 02/26/14 20:04:49 (11 years ago)
- Location:
- cpp/frams/param
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/param/param.cpp
r124 r144 331 331 } 332 332 333 voidParamInterface::load(VirtFILE* f)333 int ParamInterface::load(VirtFILE* f) 334 334 { 335 335 SString buf; … … 338 338 int p_len; 339 339 bool loaded; 340 int fields_loaded=0; 340 341 while(loadSStringLine(f,buf)) 341 342 { … … 361 362 set(i,p0+p_len+1); 362 363 } 364 fields_loaded++; 363 365 loaded=true; 364 366 } … … 370 372 } 371 373 } 374 return fields_loaded; 372 375 } 373 376 … … 444 447 } 445 448 else 446 return setInt(i, atol(str));449 return setInt(i,ExtValue::getInt(str)); 447 450 } 448 451 … … 458 461 } 459 462 else 460 return setDouble(i, atof(str));463 return setDouble(i,ExtValue::getDouble(str)); 461 464 } 462 465 … … 465 468 switch(type(i)[0]) 466 469 { 467 case 'd': if (v.type!=TObj) return setInt(i,v.getInt()); else return setInt(i,(const char*)v.getString()); 468 case 'f': if (v.type!=TObj) return setDouble(i,v.getDouble()); else return setDouble(i,(const char*)v.getString()); 470 case 'd': 471 if ((v.type==TInt)||(v.type==TDouble)) return setInt(i,v.getInt()); 472 else 473 { 474 if (v.type==TObj) 475 FMprintf("ParamInterface","set",FMLV_WARN,"Getting integer value from object reference (%s)",(const char*)v.getString()); 476 return setInt(i,(const char*)v.getString()); 477 } 478 case 'f': 479 if ((v.type==TInt)||(v.type==TDouble)) return setDouble(i,v.getDouble()); 480 else 481 { 482 if (v.type==TObj) 483 FMprintf("ParamInterface","set",FMLV_WARN,"Getting floating point value from object reference (%s)",(const char*)v.getString()); 484 return setDouble(i,(const char*)v.getString()); 485 } 469 486 case 's': { SString t=v.getString(); return setString(i,t); } 470 487 case 'o': return setObject(i,v.getObject()); 471 488 case 'x': return setExtValue(i,v); 472 default: FMprintf("ParamInterface"," get",FMLV_ERROR,"'%s.%s' is not a field",getName(),id(i));489 default: FMprintf("ParamInterface","set",FMLV_ERROR,"'%s.%s' is not a field",getName(),id(i)); 473 490 } 474 491 return 0; … … 826 843 } 827 844 828 voidParamInterface::load2(const SString &s,int &poz)845 int ParamInterface::load2(const SString &s,int &poz) 829 846 { 830 847 int i; // numer akt. parametru … … 832 849 int len; 833 850 int ret; 851 int fields_loaded=0; 834 852 const char *t,*lin,*end; 835 853 const char *rownasie,*przecinek; … … 838 856 const char *value,*valstop; 839 857 SString tmpvalue; 840 if (poz>=s.len()) return ;858 if (poz>=s.len()) return fields_loaded; 841 859 t=(const char*)s+poz; 842 860 843 861 // na razie wszystko musi byc w jednej linii... 844 862 lin=getline(s,poz,len); 845 if (!len) return ; // pusta linia = koniec863 if (!len) return fields_loaded; // pusta linia = koniec 846 864 i=0; 847 865 end=lin+len; … … 849 867 { 850 868 // przetwarzanie jednego par 851 while (strchr(" \n\r\t",*t)) if (t<end) t++; else return ;869 while (strchr(" \n\r\t",*t)) if (t<end) t++; else return fields_loaded; 852 870 853 871 przecinek=strchrlimit(t,',',end); if (!przecinek) przecinek=end; … … 908 926 *(char*)valstop=0; 909 927 ret=set(i,value); 928 fields_loaded++; 910 929 if (ret&(PSET_HITMAX|PSET_HITMIN)) 911 930 FMprintf("Param","load2",FMLV_WARN,"Adjusted '%s' in '%s' (was too %s)", … … 916 935 if (i>=0) i++; 917 936 #ifdef __CODEGUARD__ 918 if (przecinek<end-1) t=przecinek+1; else return ;937 if (przecinek<end-1) t=przecinek+1; else return fields_loaded; 919 938 #else 920 939 t=przecinek+1; 921 940 #endif 922 941 } 923 return ;942 return fields_loaded; 924 943 } 925 944 -
cpp/frams/param/param.h
r124 r144 154 154 int save(VirtFILE*,const char* altname=NULL,bool force=0); 155 155 int saveprop(VirtFILE*,int i,const char* p,bool force=0); 156 void load(VirtFILE*); 157 void load2(const SString &,int &); 156 int load(VirtFILE*);///< @return number of fields loaded 157 int load2(const SString &,int &);///< @return number of fields loaded 158 158 159 159 static const char* SERIALIZATION_PREFIX;
Note: See TracChangeset
for help on using the changeset viewer.