fits.cc
// Reads an integer keyword and returns its value or default_value if not found.
Reads an integer keyword and returns its value or default_value if not found.
Reads an integer keyword and returns its value or default_value if not found .
int Fits::HeaderReadKeywordInt(const string &header,
                               const string &keyword,
                               int default_value) {
  CHECK_LTE(static_cast<int>(keyword.size()), FITS_KEYWORD_SIZE)
      << "Invalid FITS keyword '" << keyword << "' (too long)";
  for (int i = 0; i < static_cast<int>(header.size()); i += FITS_CARD_SIZE) {
    string card_name = header.substr(i, FITS_KEYWORD_SIZE);
    int last_space_index = card_name.find_last_not_of(" ");
    if (last_space_index == static_cast<int>(string::npos)) {
      last_space_index = FITS_KEYWORD_SIZE - 1;
    }
    card_name = card_name.substr(0, last_space_index + 1);
    if (card_name == keyword) {
      string card = header.substr(i, FITS_CARD_SIZE);
      string value_str = card.substr(9, 21);
      return atoi(value_str.c_str());
    }
  }
  return default_value;
}
int Fits :: HeaderReadKeywordInt ( const string & header , const string & keyword , int default_value ) { CHECK_LTE ( static_cast < int > ( keyword . size ( ) ) , FITS_KEYWORD_SIZE ) << " " << keyword << " " ; for ( int i = 0 ; i < static_cast < int > ( header . size ( ) ) ; i += FITS_CARD_SIZE ) { string card_name = header . substr ( i , FITS_KEYWORD_SIZE ) ; int last_space_index = card_name . find_last_not_of ( " " ) ; if ( last_space_index == static_cast < int > ( string :: npos ) ) { last_space_index = FITS_KEYWORD_SIZE - 1 ; } card_name = card_name . substr ( 0 , last_space_index + 1 ) ; if ( card_name == keyword ) { string card = header . substr ( i , FITS_CARD_SIZE ) ; string value_str = card . substr ( 9 , 21 ) ; return atoi ( value_str . c_str ( ) ) ; } } return default_value ; }
Reads an integer keyword and returns its value or default_value if not found.
Reads an integer keyword and returns its value or default_value if not found .
// Remove trailing space. // Value lies between characters 9 and 29 inclusive in this FITS card.