28 # if !defined(AIPS_FITS) 32 # include <casacore/casa/aips.h> 35 # include <casacore/casa/iostream.h> 36 # include <casacore/casa/BasicSL/Complex.h> 37 # include <casacore/casa/BasicSL/IComplex.h> 38 # include <casacore/fits/FITS/FITSError.h> 48 class ReservedFitsKeywordCollection;
50 class FitsValueResult;
97 v = x.
v;
return *
this; }
99 v = (x ==
True ?
'T' :
'F');
return *
this; }
125 operator unsigned char() {
return bit_array; }
139 no_elements(x.no_elements), rel_offset(x.rel_offset) { }
144 void set(
int n,
int o) { no_elements = n; rel_offset = o; }
145 int num()
const {
return no_elements; }
146 int offset()
const {
return rel_offset; }
172 NOVALUE = 0, LOGICAL = 1, BIT = 2, CHAR = 3, BYTE = 4,
173 SHORT = 5, LONG = 6, FLOAT = 7, DOUBLE = 8, COMPLEX = 9,
174 ICOMPLEX = 10, DCOMPLEX = 11, VADESC = 12,
212 static void f2l(
FitsBit *,
void *,
int);
213 static void l2f(
void *,
FitsBit *,
int);
214 static void f2l(
char *,
void *,
int);
215 static void l2f(
void *,
char *,
int);
216 static void f2l(
unsigned char *,
void *,
int);
217 static void l2f(
void *,
unsigned char *,
int);
218 static void f2l(
short *,
void *,
int);
219 static void l2f(
void *,
short *,
int);
220 static void f2l(
Int *,
void *,
int);
221 static void l2f(
void *,
Int *,
int);
222 static void f2l(
long *,
void *,
int);
223 static void l2f(
void *,
long *,
int);
224 static void f2l(
float *,
void *,
int);
225 static void l2f(
void *,
float *,
int);
226 static void f2l(
double *,
void *,
int);
227 static void l2f(
void *,
double *,
int);
228 static void f2l(
Complex *,
void *,
int);
229 static void l2f(
void *,
Complex *,
int);
230 static void f2l(
IComplex *,
void *,
int);
231 static void l2f(
void *,
IComplex *,
int);
232 static void f2l(
DComplex *,
void *,
int);
233 static void l2f(
void *,
DComplex *,
int);
236 static void swap2(
void *,
void *,
int);
237 static void swap4(
void *,
void *,
int);
238 static void swap8(
void *,
void *,
int);
244 BUNIT, BZERO, CDELT, COMMENT, CROTA,
CRPIX,
246 END, EPOCH, EQUINOX, EXTEND, EXTLEVEL,
EXTNAME,
247 EXTVER, GCOUNT, GROUPS, HISTORY, INSTRUME,
NAXIS,
248 OBJECT, OBSERVER, ORIGIN, PCOUNT, PSCAL,
PTYPE,
249 PZERO_FITS, REFERENC, SIMPLE, SPACES, TBCOL,
TDIM,
250 TDISP, TELESCOP, TFIELDS, TFORM, THEAP,
TNULL,
277 static void valstr(ostream &o,
const ValueType &ty,
const void *val);
278 static Bool isa_digit(
char c);
279 static int digit2bin(
char c);
280 static Bool isa_text(
char c);
281 static Bool isa_letter(
char);
282 static int letter2bin(
char);
283 static void fstr2str(
char *,
const char *,
int);
284 static int str2fstr(
char *,
const char *,
int);
285 static void get_name(
const char *s,
int len,
FitsNameResult &result);
286 static int get_value_id(
const char *s,
int l,
int &pos);
287 static void get_value(
const char *s,
int len,
FitsValueResult &result);
288 static int trim_comment(
const char *s,
int len);
289 static int chk_comment(
const char *s,
int len);
290 static int get_comment(
const char *s,
int len,
int &begpos);
291 static void get_numeric(
const char *s,
int len,
FitsValueResult &result);
310 static double tenpowerD[309];
311 static float tenpowerF[39];
319 static double tenD(
Int,
int);
320 static float tenF(
Int,
int);
321 static int ckaccum(
double &,
Int,
int);
322 static int ckaccum(
float &,
Int,
int);
335 return (pow > 0) ? (((double)numb) * tenpowerD[
pow]) :
336 ((pow < 0) ? (((double)numb) / tenpowerD[-
pow]) : ((
double)numb));
339 return (pow > 0) ? (((float)numb) * tenpowerF[
pow]) :
340 ((pow < 0) ? (((float)numb) / tenpowerF[-
pow]) : ((
float)numb));
349 const char *aname()
const;
351 int namesize()
const;
353 Bool isindexed()
const;
354 Bool isessential()
const;
355 # if defined(TURBOCPP) 375 return isessential_; }
386 const void *, int,
const char *&)
const;
388 const void *, int,
const char *&)
const;
389 const char *aname(FITS::ReservedName)
const;
390 int essential_name(
const char *,
int)
const;
392 const void *,
int,
const char *&)
const;
393 int isreserved(
const char *,
int)
const;
394 Bool isunique(
int)
const;
395 Bool requires_value(
int)
const;
403 FITS::ValueType,
const void *,
int,
const char *&)
const;
413 static const int resalpha[26];
415 FITS::ValueType,
const void *,
int,
const char *&)
const;
423 return (
Bool)(resword[i + 1].name() != resword[i].name()); }
425 const {
return user_def_item; }
427 const {
return error_item; }
429 const {
return end__item; }
431 const {
return spaces_item; }
433 const {
return comment_item; }
435 const {
return history_item; }
496 const char *err(
int)
const;
503 int seterr(
const char *);
511 return no_errs_ < max_errs ? ( err_[no_errs_++] = s, 0) : -1; }
534 const char *name()
const;
536 Bool isreserved()
const;
537 Bool isindexed()
const;
544 const char *comm()
const;
557 const char *asString()
const;
558 int valStrlen()
const;
560 float asFloat()
const;
561 double asDouble()
const;
565 const void *
value()
const;
581 void comm(
const char *);
584 void name(
const char *);
624 void setcomm(
const char *,
int);
627 static void memchk(
void *);
648 name_(0), kw_(0), comm_(0), val(0) {
init(k); }
675 return vallen ? (
const char *)
val :
""; }
679 cerr <<
"Unexpected keyword type in FitsKeyword::asInt()\n";
692 cerr <<
"Unexpected keyword type in asFloat()\n";
705 cerr <<
"Unexpected keyword type in asDouble()\n";
786 void mk(
const char *n,
Bool v,
const char *
c = 0);
787 void mk(
const char *n,
const char *v = 0,
const char *
c = 0);
788 void mk(
const char *n,
Int v,
const char *
c = 0);
789 void mk(
const char *n,
long v,
const char *
c = 0);
790 void mk(
const char *n,
float v,
const char *
c = 0);
791 void mk(
const char *n,
double v,
const char *
c = 0);
792 void mk(
const char *n,
Int r,
Int i,
const char *
c = 0);
793 void mk(
const char *n,
float r,
float i,
const char *
c = 0);
794 void mk(
const char *n,
double r,
double i,
const char *
c = 0);
798 void spaces(
const char *n = 0,
const char *
c = 0);
801 void comment(
const char *n = 0,
const char *
c = 0);
804 void history(
const char *
c = 0);
825 Bool isempty()
const;
843 void parse(
const char *,
int);
844 int no_parse_errs()
const;
845 const char *parse_err(
int)
const;
868 const void *
val,
const char *errmsg);
875 total(0), cursor(0) { }
884 int ndx) {
first();
return next(n,ndx); }
967 return kw.next(x,n); }
997 const char *err(
int)
const;
998 int err_cardno(
int)
const;
1013 delete [] err_;
delete [] err_cardno_;
delete [] blanks; }
1017 return err_cardno_[i]; }
1029 static Bool isFP(
const float *);
1030 static Bool isFP(
const double *);
1031 static Bool isFP(
const void *);
1037 static void setNaN(
double &val);
1038 static void setNaN(
float &val);
static const ReservedFitsKeyword & user_def_item
FitsVADesc(const FitsVADesc &x)
const ReservedFitsKeyword & operator[](int i) const
static FITS::ValueType getfitstype(NoConvert< DComplex > x)
static int digit2bin(char c)
static const int no_items
FitsBit(const FitsBit &x)
FitsKeyword & operator=(const FitsKeyword &)
static const int minfltexp
int no_parse_errs() const
const ReservedFitsKeyword & comment() const
FITS templated helper class.
void parse(const char *, int)
For parsing a single string.
int err() const
access the error status
const char * parse_err(int) const
friend class FitsKeywordList
std::complex< Float > Complex
static const ReservedFitsKeyword & error_item
void mk(FITS::ReservedName k, Bool v, const char *c=0)
Add (make) a reserved keyword with the given value and optional comment The comment will be truncated...
const FitsKeyword * next(const FITS::ReservedName &x, int n)
IComplex asIComplex() const
const char * err(int) const
void comment(const char *n=0, const char *c=0)
add a comment card
Bool asBool() const
access the value of the keyword
void insert(FitsKeyword &)
FitsKeyword(const FitsKeyword &)
A word about friends: FitsKeywordList accesses the next and prev pointers and the FitsKeyword constru...
const char * asString() const
FitsLogical(const FitsLogical &x)
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
static functions and enumerations
void init(const FitsKeyword &)
static FITS::ValueType getfitstype(NoConvert< IComplex > x)
FITS::ValueType type_
the keyword value
static FITS::ValueType getfitstype(NoConvert< char > x)
static const ReservedFitsKeyword & history_item
static Bool isa_letter(char)
helper class for FITS Binary Tables
static const int maxdblexp
HDUType
Types of FITS Header-Data Units.
FITS::ValueType type() const
ValueType
FITS I/O Error message types.
const ReservedFitsKeyword & userdef_item() const
const ReservedFitsKeyword & spaces() const
const char * name() const
get info about the name
static double tenD(Int, int)
static FITS::ValueType getfitstype(NoConvert< Int > x)
static const int maxfltexp
analyse the value of a header card
const FitsKeyword * next()
static float tenF(Int, int)
static FITS::ValueType getfitstype(NoConvert< double > x)
static Bool isa_digit(char c)
FitsDevice
Supported FITS Physical Devices.
void end()
add the end card.
std::complex< Double > DComplex
collection of reserved FITS keywords
Utility functions for floating point values.
FitsKeyword & parse(const char *, int)
const FitsKeyword * next(const char *x)
String toString(const SubScanKey &subScanKey)
static FITS::ValueType getfitstype(NoConvert< FitsBit > x)
static FITS::ValueType getfitstype(NoConvert< short > x)
const FitsKeyword * prev()
static const ReservedFitsKeyword & end__item
const FitsKeyword * curr()
static const float minfloat
FITS::ValueType type() const
the datatype of the keyword
static const double mindouble
bool Bool
Define the standard types used by Casacore.
FitsRecType
Types of FITS Records.
list of read-only FITS keywords
DComplex asDComplex() const
static FITS::ValueType getfitstype(NoConvert< FitsVADesc > x)
static FITS::ValueType getfitstype(NoConvert< long > x)
const ReservedFitsKeyword & kw() const
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
void history(const char *c=0)
add a history card
char * comm_
the keyword comment if comm_ is 0, there is no comment
static ReservedFitsKeywordCollection & ResWord
static int letter2bin(char)
char * name_
the keyword name if name_ is 0, keyword is not a user defined name if ndx is 0, there is no index ...
static const ReservedFitsKeyword & spaces_item
const char * comm() const
access the keyword comment
FitsKeyword & make(const char *nm, FITS::ValueType t, const void *v, const char *c)
static const int maxsigdigits
static FITS::ValueType getfitstype(NoConvert< float > x)
static Bool isa_text(char c)
FitsKeyword * operator()(int)
Retrieve specific keywords – these also set the current mark.
const ReservedFitsKeyword * kw_
static const float maxfloat
linked list of FITS keywords
static FITS::ValueType getfitstype(NoConvert< Complex > x)
FitsArrayOption
Options on FITS array manipulations.
const Double c
Fundamental physical constants (SI units):
static FITS::ValueType getfitstype(NoConvert< unsigned char > x)
const ReservedFitsKeyword & err_item() const
const ReservedFitsKeyword & end_item() const
analyse the name of a header card
int err_cardno(int) const
const FitsKeyword * next(const FITS::ReservedName &x)
ConstFitsKeywordList(FitsKeywordList &x)
static const int mindblexp
static const int maxexpdig
static const double maxdouble
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
translator between Keyword lists and fixed FITS cars
const ReservedFitsKeyword & history() const
Variable Length Array Descriptor.
const char * err(int) const
Complex asComplex() const
this file contains all the compiler specific defines
static const ReservedFitsKeyword & comment_item
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void spaces(const char *n=0, const char *c=0)
add a spaces line
ReservedName
FITS Reserved Names.
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.
const char * aname() const
static FITS::ValueType getfitstype(NoConvert< FitsLogical > x)
STRING and FSTRING are used internally in parsing keywords.