Changeset 827 in Sophya
- Timestamp:
- Apr 6, 2000, 6:39:00 PM (25 years ago)
- Location:
- trunk/SophyaLib/BaseTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/dvlist.cc
r802 r827 284 284 { 285 285 case 'I' : 286 sprintf(buff, "%s = % d (int) %s\n", (*it).first.substr(0,64).c_str(),287 ( *it).second.elval.mtv.iv, (*it).second.elcomm.substr(0,128).c_str());286 sprintf(buff, "%s = %ld (int) %s\n", (*it).first.substr(0,64).c_str(), 287 (long)((*it).second.elval.mtv.iv), (*it).second.elcomm.substr(0,128).c_str()); 288 288 break; 289 289 case 'D' : … … 359 359 switch ((*it).second.elval.typ) { 360 360 case 'I' : 361 sprintf(buf,"I %s % d", (*it).first.substr(0,64).c_str(), (*it).second.elval.mtv.iv);361 sprintf(buf,"I %s %ld", (*it).first.substr(0,64).c_str(), (long)((*it).second.elval.mtv.iv) ); 362 362 sfw = buf; s.PutStr(sfw); 363 363 break; -
trunk/SophyaLib/BaseTools/dvlist.h
r754 r827 25 25 int_8 iv; 26 26 r_8 dv; 27 char strv[3 1];27 char strv[39]; 28 28 } mtv; 29 29 char typ; … … 32 32 33 33 inline MuTyV() { typ = 'I'; mtv.iv = 0; mtv.dv = 0.; mtv.strv[0] ='\0'; } 34 inline MuTyV(MuTyV const & a) { typ = a.typ; mtv = a.mtv; } 34 35 inline MuTyV(int_4 i) { typ = 'I'; mtv.iv = (int_8)i; mtv.dv = 0.; mtv.strv[0] ='\0'; } 35 36 inline MuTyV(int_8 i) { typ = 'I'; mtv.iv = i; mtv.dv = 0.; mtv.strv[0] ='\0'; } 36 37 inline MuTyV(r_4 f) { typ = 'D'; mtv.dv = (r_8)f; mtv.iv = 0; mtv.strv[0] ='\0'; } 37 38 inline MuTyV(r_8 d) { typ = 'D'; mtv.dv = d; mtv.iv = 0; mtv.strv[0] ='\0'; } 38 inline MuTyV(char const* s) { typ = 'S'; strncpy(mtv.strv, s, 31); mtv.strv[30] = '\0'; } 39 inline MuTyV(string const& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 31); mtv.strv[30] = '\0'; } 39 inline MuTyV(char const* s) { typ = 'S'; strncpy(mtv.strv, s, 39); mtv.strv[38] = '\0'; } 40 inline MuTyV(string const& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 39); mtv.strv[38] = '\0'; } 41 inline MuTyV & operator= (MuTyV const & a) { typ = a.typ; mtv = a.mtv; return(*this); } 40 42 inline int_4 operator= (int_4 v) { typ = 'I'; mtv.iv = (int_8)v; return(v); } 41 43 inline int_8 operator= (int_8 v) { typ = 'I'; mtv.iv = v; return(v); } 42 44 inline r_4 operator= (r_4 v) { typ = 'D'; mtv.dv = (r_8)v; return(v); } 43 45 inline r_8 operator= (r_8 v) { typ = 'D'; mtv.dv = v; return(v); } 44 inline char* operator= (char* s) { typ = 'S'; strncpy(mtv.strv, s, 3 1);45 mtv.strv[3 0] = '\0'; return(s); }46 inline string& operator= (string& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 3 1);47 mtv.strv[3 0] = '\0'; return(s); }46 inline char* operator= (char* s) { typ = 'S'; strncpy(mtv.strv, s, 39); 47 mtv.strv[38] = '\0'; return(s); } 48 inline string& operator= (string& s) { typ = 'S'; strncpy(mtv.strv, s.c_str(), 39); 49 mtv.strv[38] = '\0'; return(s); } 48 50 49 51 inline operator int_4() { if (typ == 'I') return((int_4)mtv.iv); … … 60 62 else return(atof(mtv.strv)); } 61 63 inline operator string() { char *ss=myStrBuf; 62 if (typ == 'I') sprintf(ss,"%ld", mtv.iv);64 if (typ == 'I') sprintf(ss,"%ld", (long)mtv.iv); 63 65 else if (typ == 'D') sprintf(ss,"%.20g", mtv.dv); 64 66 else ss = mtv.strv;
Note:
See TracChangeset
for help on using the changeset viewer.