Changeset 13000 for trunk/Mars/mcore
- Timestamp:
- 03/07/12 14:23:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/ofits.h
r12995 r13000 44 44 { 45 45 // Trim Both leading and trailing spaces 46 const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces47 const size_t end= str.find_last_not_of(' '); // Find the first character position from reverse af46 const size_t first = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces 47 const size_t last = str.find_last_not_of(' '); // Find the first character position from reverse af 48 48 49 49 // if all spaces or empty return an empty string 50 if (string::npos== start || string::npos==end)50 if (string::npos==first || string::npos==last) 51 51 return string(); 52 52 53 return str.substr( start, end-start+1);53 return str.substr(first, last-first+1); 54 54 } 55 55 … … 150 150 string Compile() 151 151 { 152 ostringstream out;153 out << std::left << setw(8) << key;152 ostringstream sout; 153 sout << std::left << setw(8) << key; 154 154 155 155 if (!delim) 156 156 { 157 out << " " << comment;158 return out.str();157 sout << " " << comment; 158 return sout.str(); 159 159 } 160 160 161 out << "= ";162 out << (value[0]=='\''?std::left:std::right);163 out << setw(20) << value << std::left;161 sout << "= "; 162 sout << (value[0]=='\''?std::left:std::right); 163 sout << setw(20) << value << std::left; 164 164 165 165 if (comment.size()>0) 166 out << " / " << comment;167 168 return out.str();166 sout << " / " << comment; 167 168 return sout.str(); 169 169 } 170 170 171 171 Checksum checksum; 172 172 173 void Out(ofstream & out)173 void Out(ofstream &fout) 174 174 { 175 175 if (!changed) … … 180 180 181 181 if (offset==0) 182 offset = out.tellp();182 offset = fout.tellp(); 183 183 184 184 //cout << "Write[" << offset << "]: " << key << "/" << value << endl; 185 185 186 out.seekp(offset);187 out << str;186 fout.seekp(offset); 187 fout << str; 188 188 189 189 checksum.reset(); … … 192 192 changed = false; 193 193 } 194 194 /* 195 195 void Out(ostream &out) 196 196 { … … 201 201 out << str; 202 202 changed = false; 203 } 203 }*/ 204 204 }; 205 205 … … 354 354 bool SetInt(const string &key, int64_t i, const string &comment="") 355 355 { 356 ostringstream out;357 out << i;358 359 return Set(key, true, out.str(), comment);356 ostringstream sout; 357 sout << i; 358 359 return Set(key, true, sout.str(), comment); 360 360 } 361 361 362 362 bool SetFloat(const string &key, double f, int p, const string &comment="") 363 363 { 364 ostringstream out;364 ostringstream sout; 365 365 366 366 if (p<0) 367 out << setprecision(-p) << fixed;367 sout << setprecision(-p) << fixed; 368 368 if (p>0) 369 out << setprecision(p);369 sout << setprecision(p); 370 370 if (p==0) 371 out << setprecision(f>1e-100 && f<1e100 ? 15 : 14);372 373 out << f;374 375 string str = out.str();371 sout << setprecision(f>1e-100 && f<1e100 ? 15 : 14); 372 373 sout << f; 374 375 string str = sout.str(); 376 376 377 377 replace(str.begin(), str.end(), 'e', 'E'); … … 390 390 bool SetHex(const string &key, uint64_t i, const string &comment="") 391 391 { 392 ostringstream out;393 out <<hex << "0x" << i;394 return SetStr(key, out.str(), comment);392 ostringstream sout; 393 sout << std::hex << "0x" << i; 394 return SetStr(key, sout.str(), comment); 395 395 } 396 396
Note:
See TracChangeset
for help on using the changeset viewer.