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)
69 memset(headStr,
' ', 80);
74 if(strlen(keyword) > 8)
76 rpos += snprintf(headStr, 81,
"HIERARCH ");
78 rpos += snprintf(headStr + rpos, 81-rpos,
"%s =", keyword);
82 rpos += snprintf(headStr, 81,
"%-8s=", keyword);
85 if(strlen(value) < stdValWidth)
88 snprintf(fstr, 10,
"%%+%ds", stdValWidth);
89 rpos += snprintf(headStr + rpos, 81-rpos, fstr, value);
93 rpos += snprintf(headStr + rpos, 81-rpos,
"%s", value);
105 snprintf(headStr + rpos, 81-rpos,
"%s", comment);
109 int fits_write_key<char *>(fitsfile * fptr,
char * keyword,
void * value,
char * comment)
113 fits_write_key_longwarn(fptr, &fstatus);
116 fits_write_key_longstr(fptr, keyword, (
const char *) value, comment, &fstatus);
123 int fits_write_key<std::string>(fitsfile * fptr,
char * keyword,
void * value,
char * comment)
125 return fits_write_key<char *>(fptr, keyword, value, comment);
131 unsigned char bc = *((
bool *)value);
135 fits_write_key(fptr, fitsType<unsigned char>(), keyword, &bc, comment, &fstatus);
141 int fits_write_key<fitsUnknownType>(fitsfile * fptr,
char * keyword,
void * value,
char * comment)
146 char *vstr = (
char *) value;
153 fits_write_record(fptr, headStr, &fstatus);
157 int fits_write_comment(fitsfile *fptr,
char * comment)
161 fits_write_comment(fptr, comment, &fstatus);
166 int fits_write_history(fitsfile *fptr,
char * history)
170 fits_write_history(fptr, history, &fstatus);
176 const std::string & filename,
182 fits_get_errstatus(fstatus, emnem);
186 explan +=
". CFITSIO: ";
Declares and defines utilities to work with FITS files.
int fitsStripApost(std::string &s)
Strip the apostrophes from a FITS value string.
void fitsErrText(std::string &explan, const std::string &filename, int fstatus)
Generate a rich error meesage from a FITS status code.
int fits_write_key(fitsfile *fptr, char *keyword, void *value, char *comment)
Write a header card to a file.
void fitsPopulateCard(char headStr[81], char *keyword, char *value, char *comment)
Populate a fits header card with the value string copied verbatim.
int fits_write_key< bool >(fitsfile *fptr, char *keyword, void *value, char *comment)
Specialization to handle the case bool.
std::string convertToString(const typeT &value, int precision=0)
Convert a numerical value to a string.