Changeset 1157 in Sophya
- Timestamp:
- Aug 29, 2000, 6:11:42 PM (25 years ago)
- Location:
- trunk/SophyaLib/BaseTools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/dvlist.cc
r1080 r1157 195 195 /*! Returns the value corresponding to name \b key, converted to integer 196 196 Default value \b def is returned if name \b key not found */ 197 int_8 DVList::GetI(string const& key, int_8 def) 198 { 199 ValList:: iterator it = mvlist.find(key);197 int_8 DVList::GetI(string const& key, int_8 def) const 198 { 199 ValList::const_iterator it = mvlist.find(key); 200 200 if (it == mvlist.end()) return(def); 201 201 return((*it).second.elval.iv); … … 205 205 /*! Returns the value corresponding to name \b key, converted to double 206 206 Default value \b def is returned if name \b key not found */ 207 r_8 DVList::GetD(string const& key, r_8 def) 208 { 209 ValList:: iterator it = mvlist.find(key);207 r_8 DVList::GetD(string const& key, r_8 def) const 208 { 209 ValList::const_iterator it = mvlist.find(key); 210 210 if (it == mvlist.end()) return(def); 211 211 return((*it).second.elval.dv); … … 215 215 /*! Returns the value corresponding to name \b key, converted to complex 216 216 Default value \b def is returned if name \b key not found */ 217 complex<r_8> DVList::GetZ(string const& key, complex<r_8> def) 218 { 219 ValList:: iterator it = mvlist.find(key);217 complex<r_8> DVList::GetZ(string const& key, complex<r_8> def) const 218 { 219 ValList::const_iterator it = mvlist.find(key); 220 220 if (it == mvlist.end()) return(def); 221 221 return((*it).second.elval.dv); … … 225 225 /*! Returns the value corresponding to name \b key, converted to string 226 226 Default value \b def is returned if name \b key not found */ 227 string DVList::GetS(string const& key, char* def) 228 { 229 ValList:: iterator it = mvlist.find(key);227 string DVList::GetS(string const& key, char* def) const 228 { 229 ValList::const_iterator it = mvlist.find(key); 230 230 if (it == mvlist.end()) return(def); 231 231 return(*((*it).second.elval.strv)); … … 234 234 /* --Methode-- */ 235 235 /*! Returns the comment associated with name \b key */ 236 string DVList::GetComment(string const& key) 237 { 238 ValList:: iterator it = mvlist.find(key);236 string DVList::GetComment(string const& key) const 237 { 238 ValList::const_iterator it = mvlist.find(key); 239 239 if (it == mvlist.end()) return(""); 240 240 return((*it).second.elcomm); … … 259 259 260 260 /* --Methode-- */ 261 /*! Removes the definition and value associated with the name \b key. 262 Return \c true if the \b key is found in the list, \c false otherwise. */ 263 bool DVList::DeleteKey(string const& key) 264 { 265 ValList::iterator it = mvlist.find(key); 266 if (it == mvlist.end()) return(false); 267 mvlist.erase(it); 268 return(true); 269 } 270 271 /* --Methode-- */ 272 /*! Return \c true if the \b key is found in the list, \c false otherwise. */ 273 bool DVList::HasKey(string const& key) const 274 { 275 ValList::const_iterator it = mvlist.find(key); 276 if (it == mvlist.end()) return(false); 277 return(true); 278 } 279 280 281 /* --Methode-- */ 261 282 /*! Appends or sets the integer value \b val in the list with name \b key */ 262 283 void DVList::SetI(string const& key, int_8 val) … … 316 337 // Renvoie une référence sur le champ commentaire de l'objet. 317 338 //-- 339 340 /* --Methode-- */ 341 /*! Return the MuTyV value associated with name \b key . 342 Integer 0 is returned if \b key is not present in the list */ 343 MuTyV DVList::Get(string const& key) const 344 { 345 ValList::const_iterator it = mvlist.find(key); 346 if (it == mvlist.end()) return(MuTyV(0)); 347 else return((*it).second.elval); 348 } 318 349 319 350 /* --Methode-- */ -
trunk/SophyaLib/BaseTools/dvlist.h
r1080 r1157 34 34 DVList& Merge(const DVList&); 35 35 36 int_8 GetI(string const& key, int_8 def=-1); 37 r_8 GetD(string const& key, r_8 def=-9.e19); 38 complex<r_8> GetZ(string const& key, complex<r_8> def=-9.e19); 39 string GetS(string const& key, char* def=""); 40 string GetComment(string const& key); 36 int_8 GetI(string const& key, int_8 def=-1) const; 37 r_8 GetD(string const& key, r_8 def=-9.e19) const; 38 complex<r_8> GetZ(string const& key, complex<r_8> def=-9.e19) const; 39 string GetS(string const& key, char* def="") const; 40 string GetComment(string const& key) const; 41 42 bool DeleteKey(string const& key); 43 bool HasKey(string const& key) const; 41 44 42 45 void SetI(string const& key, int_8 val); … … 47 50 void SetComment(string const& key, string const& comm); 48 51 52 MuTyV Get(string const& key) const ; 49 53 MuTyV& Get(string const& key); 54 /*! Returns the value associated with the name \b key */ 55 inline MuTyV operator() (string const& key) const { return Get(key); } 56 /*! Returns the value associated with the name \b key */ 57 inline MuTyV operator[] (string const& key) const { return Get(key); } 58 /*! Returns the global comment string associated with the object */ 59 inline string Comment() const { return(comment); } 50 60 /*! Returns the value associated with the name \b key */ 51 61 inline MuTyV& operator() (string const& key) { return Get(key); } -
trunk/SophyaLib/BaseTools/machdefs.h
r1084 r1157 356 356 #endif 357 357 358 /* ---- La taille et les index des tableaux ---- */ 359 typedef int_4 sa_size_t ; 360 361 358 362 /* Compatibilite, avant de migrer tout le code en "PLANCK" */ 359 363 -
trunk/SophyaLib/BaseTools/mutyv.cc
r1080 r1157 32 32 33 33 34 static void mutyv_decodestr(const char * si, double& r, double& im); 35 34 36 /* --Methode-- */ 35 37 MuTyV::MuTyV(MuTyV const & a) … … 51 53 typ = 'S'; 52 54 strv = new string(s); 53 dv = dv_im = 0.; 54 sscanf(s, "%lg %lg", &dv, &dv_im); 55 mutyv_decodestr(s, dv, dv_im); 55 56 iv = (int_8)dv; 56 57 } … … 61 62 typ = 'S'; 62 63 strv = new string(s); 63 dv = dv_im = 0.; 64 sscanf(s.c_str(), "%lg %lg", &dv, &dv_im); 64 mutyv_decodestr(s.c_str(), dv, dv_im); 65 65 iv = (int_8)dv; 66 66 } … … 80 80 typ = 'S'; 81 81 strv = new string(s); 82 dv = dv_im = 0.; 83 sscanf(s, "%lg %lg", &dv, &dv_im); 82 mutyv_decodestr(s, dv, dv_im); 84 83 iv = (int_8)dv; 85 84 return(s); … … 91 90 typ = 'S'; 92 91 strv = new string(s); 93 dv = dv_im = 0.; 94 sscanf(s.c_str(), "%lg %lg", &dv, &dv_im); 92 mutyv_decodestr(s.c_str(), dv, dv_im); 95 93 iv = (int_8)dv; 96 94 return(s); … … 105 103 if (typ == 'I') sprintf(buff,"%ld", (long)iv); 106 104 else if (typ == 'D') sprintf(buff,"%.20g", dv); 107 else if (typ == 'Z') sprintf(buff," %.20g %.20g i", dv, dv_im);105 else if (typ == 'Z') sprintf(buff,"(%.20g , %.20g)", dv, dv_im); 108 106 else buff[0] = '\0'; 109 107 return(string(buff)); … … 112 110 113 111 112 static void mutyv_decodestr(const char * si, double& r, double& im) 113 // decodage d'une chaine contenant une ou deux valeurs 114 { 115 r = im = 0.; 116 string s = si; 117 size_t l = s.length(); 118 size_t p = s.find_first_not_of(" ()\t",0); 119 if (p >= l) return; 120 size_t q = s.find_first_of(" ()\t",p+1); 121 122 123 if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') ) 124 return; 125 r = atof(s.substr(p,q-p).c_str()); 126 127 p = s.find_first_not_of(" ()\t",q+1); 128 if (p >= l) return; 129 q = s.find_first_of(" ()\t",p+1); 130 if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') ) 131 return; 132 im = atof(s.substr(p,q-p).c_str()); 133 } 114 134 115 135 116 136 137 -
trunk/SophyaLib/BaseTools/sophyainit.cc
r913 r1157 144 144 return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); 145 145 } 146 147 double SOPHYA::SophyaVersion() 148 { 149 return(SOPHYA_VERSION + (SOPHYA_REVISION/1000.)); 150 } 146 151 147 152 // On met un objet initiator en statique, pour les loaders qui savent -
trunk/SophyaLib/BaseTools/sversion.h
r1130 r1157 3 3 4 4 #define SOPHYA_VERSION 0.9 5 #define SOPHYA_REVISION 856 #define SOPHYA_TAG "V_ Jul2000"5 #define SOPHYA_REVISION 90 6 #define SOPHYA_TAG "V_Aou2000" 7 7 8 8 #endif
Note:
See TracChangeset
for help on using the changeset viewer.