Changeset 12714 for trunk/Mars/mcore
- Timestamp:
- 12/11/11 16:33:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/fits.h
r12707 r12714 22 22 #include <iostream> 23 23 #define gLog cerr 24 #define ___err___ ""25 #define ___all___ ""24 #define ___err___ "" 25 #define ___all___ "" 26 26 #else 27 27 #include "MLog.h" 28 28 #include "MLogManip.h" 29 #define ___err___ err30 #define ___all___ all29 #define ___err___ err 30 #define ___all___ all 31 31 #endif 32 32 … … 389 389 size_t fRow; 390 390 391 vector<string>ReadBlock(vector<string> &vec)392 { 393 bool endtag = false;391 bool ReadBlock(vector<string> &vec) 392 { 393 int endtag = 0; 394 394 for (int i=0; i<36; i++) 395 395 { … … 400 400 break; 401 401 402 if (c[0]==0)403 return vector<string>();402 // if (c[0]==0) 403 // return vector<string>(); 404 404 405 405 string str(c); … … 408 408 // cout << setw(2) << i << "|" << str << "|" << (endtag?'-':'+') << endl; 409 409 410 if (str=="END ") 411 { 412 endtag = true; 413 414 // Make sure that no empty vector is returned 415 if (vec.size()%36==0) 416 vec.push_back(string("END = '' / ")); 417 } 418 else 419 { 420 char value = str[0]; 421 int valuei = (int)(value); 422 } 423 //Would have liked to do it with a string comparison, but could not figure out the character for value 32... 424 bool isNULL = true; 425 for (int j=0;j<80;j++) 426 if (int(str[j]) != 32) 427 isNULL = false; 428 if (isNULL) 429 { 430 if (!endtag) 431 cout << "WARNING: END keyword missing. Loaded data may be corrupted" << endl; 432 433 endtag = true; 434 435 if (vec.size()%36==0) 436 vec.push_back(string("END = '' / ")); 437 } 438 439 if (endtag) 410 if (endtag==2 || str=="END ") 411 { 412 endtag = 2; // valid END tag found 440 413 continue; 414 } 415 416 if (endtag==1 || str==" ") 417 { 418 endtag = 1; // end tag not found, but expected to be there 419 continue; 420 } 441 421 442 422 vec.push_back(str); 443 423 } 444 424 445 return vec; 425 // Make sure that no empty vector is returned 426 if (endtag && vec.size()%36==0) 427 vec.push_back(string("END = '' / ")); 428 429 return endtag==2; 446 430 } 447 431 … … 457 441 458 442 public: 459 fits(const string &fname ) : izstream(fname.c_str())443 fits(const string &fname, bool force=false) : izstream(fname.c_str()) 460 444 { 461 445 char simple[10]; … … 483 467 { 484 468 // FIXME: Set limit on memory consumption 485 ReadBlock(block);469 const int rc = ReadBlock(block); 486 470 if (!good()) 487 471 { … … 496 480 497 481 if (block.size()%36) 482 { 483 if (!rc && !force) 484 { 485 clear(rdstate()|ios::badbit); 486 #ifdef __EXCEPTIONS 487 throw runtime_error("END keyword missing in FITS header."); 488 #else 489 gLog << ___err__ << "ERROR - END keyword missing in FITS file... file might be corrupted." << endl; 490 return; 491 #endif 492 } 498 493 break; 494 } 499 495 } 500 496 … … 609 605 { 610 606 ostringstream str; 611 str << "SetPtrAddress('" << name << "') - Column not found." << endl;607 str << "SetPtrAddress('" << name << "') - Column not found." << endl; 612 608 #ifdef __EXCEPTIONS 613 609 throw runtime_error(str.str());
Note:
See TracChangeset
for help on using the changeset viewer.