Changeset 1559 in Sophya for trunk/SophyaLib/BaseTools
- Timestamp:
- Jul 2, 2001, 6:14:58 PM (24 years ago)
- Location:
- trunk/SophyaLib/BaseTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/mutyv.cc
r1310 r1559 32 32 33 33 34 static void mutyv_decodestr(const char * si, double& r, double& im); 34 static void mutyv_decodestr(string const &, double& r, double& im); 35 static inline void mutyv_decodestr_cp(const char * si, double& r, double& im) 36 { 37 r = im = 0.; 38 string s = si; 39 mutyv_decodestr(s, r, im); 40 } 35 41 36 42 /* --Methode-- */ … … 106 112 char buff[96]; 107 113 if (typ == MTVInteger) sprintf(buff,"%ld", (long)iv); 108 else if (typ == MTVFloat) sprintf(buff,"% .20g", dv);109 else if (typ == MTVComplex) sprintf(buff,"(% .20g , %.20g)", dv, dv_im);114 else if (typ == MTVFloat) sprintf(buff,"%g", dv); 115 else if (typ == MTVComplex) sprintf(buff,"(%g,%g)", dv, dv_im); 110 116 else buff[0] = '\0'; 111 117 return(string(buff)); … … 114 120 115 121 116 static void mutyv_decodestr(const char * si, double& r, double& im) 122 123 static void mutyv_decodestr(string const & s, double& r, double& im) 117 124 // decodage d'une chaine contenant une ou deux valeurs 118 125 { 119 126 r = im = 0.; 120 string s = si;121 127 size_t l = s.length(); 122 size_t p = s.find_first_not_of(" ()\t",0); 128 size_t p = s.find_first_not_of(" \t",0); 129 size_t q,q2; 123 130 if (p >= l) return; 124 size_t q = s.find_first_of(" ()\t",p+1); 125 126 131 if (s[p] == '(') { // C'est un complexe 132 if ((q2=s.find(')',p)) >= l) return; 133 size_t pz = s.find_first_not_of(" \t",p+1); 134 size_t qz = q2; 135 if ((q=s.find(',',pz)) < q2) qz = q; 136 if (isdigit(s[pz]) || !(s[pz] == '+') || (s[pz] == '-') ) 137 r = atof(s.substr(pz,qz-pz).c_str()); 138 else return; 139 if (qz == q) { 140 pz = s.find_first_not_of(" \t",qz+1); 141 if (isdigit(s[pz]) || (s[pz] == '+') || (s[pz] == '-') ) 142 im = atof(s.substr(pz,q2-pz).c_str()); 143 } 144 } 145 146 q = s.find_first_of(" \t",p+1); 127 147 if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') ) 128 148 return; 129 149 r = atof(s.substr(p,q-p).c_str()); 130 131 p = s.find_first_not_of(" ()\t",q+1); 132 if (p >= l) return; 133 q = s.find_first_of(" ()\t",p+1); 134 if (!isdigit(s[p]) && !(s[p] == '+') && !(s[p] == '-') ) 135 return; 136 im = atof(s.substr(p,q-p).c_str()); 150 im = 0.; 137 151 } 138 152 -
trunk/SophyaLib/BaseTools/sversion.h
r1555 r1559 3 3 4 4 #define SOPHYA_VERSION 1.1 5 #define SOPHYA_REVISION 4 25 #define SOPHYA_REVISION 44 6 6 #define SOPHYA_TAG "V_Jun2001" 7 7
Note:
See TracChangeset
for help on using the changeset viewer.