37 int p = s.find_first_not_of(
" \t\n\t" );
44 p = s.find_last_not_of(
" \t\n\t" );
53 while( s[p] ==
' ' && p >= 0 )
65 memset( headStr,
' ', 80 );
70 if( strlen( keyword ) > 8 )
72 rpos += snprintf( headStr, 81,
"HIERARCH " );
74 rpos += snprintf( headStr + rpos, 81 - rpos,
"%s =", keyword );
78 rpos += snprintf( headStr, 81,
"%-8s=", keyword );
85 rpos += snprintf( headStr + rpos, 81 - rpos, fstr, value );
89 rpos += snprintf( headStr + rpos, 81 - rpos,
"%s", value );
101 snprintf( headStr + rpos, 81 - rpos,
"%s", comment );
105mx::error_t fits_write_key<char *>( fitsfile *fptr,
char *keyword,
void *value,
char *comment )
109 fits_write_key_longwarn( fptr, &fstatus );
116 fits_write_key_longstr( fptr, keyword, (
const char *)value, comment, &fstatus );
122mx::error_t fits_write_key<std::string>( fitsfile *fptr,
char *keyword,
void *value,
char *comment )
124 return fits_write_key<char *>( fptr, keyword, value, comment );
130 unsigned char bc = *( (
bool *)value );
134 fits_write_key( fptr, fitsType<unsigned char>(), keyword, &bc, comment, &fstatus );
140mx::error_t fits_write_key<fitsUnknownType>( fitsfile *fptr,
char *keyword,
void *value,
char *comment )
145 char *vstr = (
char *)value;
152 fits_write_record( fptr, headStr, &fstatus );
157mx::error_t fits_write_comment( fitsfile *fptr,
char *comment )
161 fits_write_comment( fptr, comment, &fstatus );
166mx::error_t fits_write_history( fitsfile *fptr,
char *history )
170 fits_write_history( fptr, history, &fstatus );
Declares and defines utilities to work with FITS files.
#define stdValWidth
The standard width of the value entry in a header card.
error_t
The mxlib error codes.
int fitsStripApost(std::string &s)
Strip the apostrophes from a FITS value string.
mx::error_t fits_write_key< bool >(fitsfile *fptr, char *keyword, void *value, char *comment)
Specialization to handle the case bool.
static constexpr error_t fits_status2error_t(const int &err)
Convert a FITS status code to error_t.
void fitsPopulateCard(char headStr[81], char *keyword, char *value, char *comment)
Populate a fits header card with the value string copied verbatim.
mx::error_t fits_write_key(fitsfile *fptr, char *keyword, void *value, char *comment)
Write a header card to a file.