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> 45 # if (defined(__alpha) || defined(__sgi) || defined(__x86_64__)) 53 class ReservedFitsKeywordCollection;
55 class FitsValueResult;
102 v = x.
v;
return *
this; }
104 v = (x ==
True ?
'T' :
'F');
return *
this; }
130 operator unsigned char() {
return bit_array; }
144 no_elements(x.no_elements), rel_offset(x.rel_offset) { }
149 void set(
int n,
int o) { no_elements = n; rel_offset = o; }
150 int num()
const {
return no_elements; }
151 int offset()
const {
return rel_offset; }
177 NOVALUE = 0, LOGICAL = 1, BIT = 2, CHAR = 3, BYTE = 4,
178 SHORT = 5, LONG = 6, FLOAT = 7, DOUBLE = 8, COMPLEX = 9,
179 ICOMPLEX = 10, DCOMPLEX = 11, VADESC = 12,
217 static void f2l(
FitsBit *,
void *,
int);
218 static void l2f(
void *,
FitsBit *,
int);
219 static void f2l(
char *,
void *,
int);
220 static void l2f(
void *,
char *,
int);
221 static void f2l(
unsigned char *,
void *,
int);
222 static void l2f(
void *,
unsigned char *,
int);
223 static void f2l(
short *,
void *,
int);
224 static void l2f(
void *,
short *,
int);
225 static void f2l(
Int *,
void *,
int);
226 static void l2f(
void *,
Int *,
int);
227 static void f2l(
long *,
void *,
int);
228 static void l2f(
void *,
long *,
int);
229 static void f2l(
float *,
void *,
int);
230 static void l2f(
void *,
float *,
int);
231 static void f2l(
double *,
void *,
int);
232 static void l2f(
void *,
double *,
int);
233 static void f2l(
Complex *,
void *,
int);
234 static void l2f(
void *,
Complex *,
int);
235 static void f2l(
IComplex *,
void *,
int);
236 static void l2f(
void *,
IComplex *,
int);
237 static void f2l(
DComplex *,
void *,
int);
238 static void l2f(
void *,
DComplex *,
int);
241 static void swap2(
void *,
void *,
int);
242 static void swap4(
void *,
void *,
int);
243 static void swap8(
void *,
void *,
int);
249 BUNIT, BZERO, CDELT, COMMENT, CROTA,
CRPIX,
251 END, EPOCH, EQUINOX, EXTEND, EXTLEVEL,
EXTNAME,
252 EXTVER, GCOUNT, GROUPS, HISTORY, INSTRUME,
NAXIS,
253 OBJECT, OBSERVER, ORIGIN, PCOUNT, PSCAL,
PTYPE,
254 PZERO_FITS, REFERENC, SIMPLE, SPACES, TBCOL,
TDIM,
255 TDISP, TELESCOP, TFIELDS, TFORM, THEAP,
TNULL,
282 static void valstr(ostream &o,
const ValueType &ty,
const void *val);
283 static Bool isa_digit(
char c);
284 static int digit2bin(
char c);
285 static Bool isa_text(
char c);
286 static Bool isa_letter(
char);
287 static int letter2bin(
char);
288 static void fstr2str(
char *,
const char *,
int);
289 static int str2fstr(
char *,
const char *,
int);
290 static void get_name(
const char *s,
int len,
FitsNameResult &result);
291 static int get_value_id(
const char *s,
int l,
int &pos);
292 static void get_value(
const char *s,
int len,
FitsValueResult &result);
293 static int trim_comment(
const char *s,
int len);
294 static int chk_comment(
const char *s,
int len);
295 static int get_comment(
const char *s,
int len,
int &begpos);
296 static void get_numeric(
const char *s,
int len,
FitsValueResult &result);
315 static double tenpowerD[309];
316 static float tenpowerF[39];
324 static double tenD(
Int,
int);
325 static float tenF(
Int,
int);
326 static int ckaccum(
double &,
Int,
int);
327 static int ckaccum(
float &,
Int,
int);
340 return (pow > 0) ? (((double)numb) * tenpowerD[
pow]) :
341 ((pow < 0) ? (((double)numb) / tenpowerD[-
pow]) : ((
double)numb));
344 return (pow > 0) ? (((float)numb) * tenpowerF[
pow]) :
345 ((pow < 0) ? (((float)numb) / tenpowerF[-
pow]) : ((
float)numb));
354 const char *aname()
const;
356 int namesize()
const;
358 Bool isindexed()
const;
359 Bool isessential()
const;
360 # if defined(TURBOCPP) 380 return isessential_; }
391 const void *, int,
const char *&)
const;
393 const void *, int,
const char *&)
const;
394 const char *aname(FITS::ReservedName)
const;
395 int essential_name(
const char *,
int)
const;
397 const void *,
int,
const char *&)
const;
398 int isreserved(
const char *,
int)
const;
399 Bool isunique(
int)
const;
400 Bool requires_value(
int)
const;
408 FITS::ValueType,
const void *,
int,
const char *&)
const;
418 static const int resalpha[26];
420 FITS::ValueType,
const void *,
int,
const char *&)
const;
428 return (
Bool)(resword[i + 1].name() != resword[i].name()); }
430 const {
return user_def_item; }
432 const {
return error_item; }
434 const {
return end__item; }
436 const {
return spaces_item; }
438 const {
return comment_item; }
440 const {
return history_item; }
501 const char *err(
int)
const;
508 int seterr(
const char *);
516 return no_errs_ < max_errs ? ( err_[no_errs_++] = s, 0) : -1; }
539 const char *name()
const;
541 Bool isreserved()
const;
542 Bool isindexed()
const;
549 const char *comm()
const;
562 const char *asString()
const;
563 int valStrlen()
const;
565 float asFloat()
const;
566 double asDouble()
const;
570 const void *
value()
const;
586 void comm(
const char *);
589 void name(
const char *);
629 void setcomm(
const char *,
int);
632 static void memchk(
void *);
653 name_(0), kw_(0), comm_(0), val(0) {
init(k); }
680 return vallen ? (
const char *)
val :
""; }
684 cerr <<
"Unexpected keyword type in FitsKeyword::asInt()\n";
697 cerr <<
"Unexpected keyword type in asFloat()\n";
710 cerr <<
"Unexpected keyword type in asDouble()\n";
791 void mk(
const char *n,
Bool v,
const char *
c = 0);
792 void mk(
const char *n,
const char *v = 0,
const char *
c = 0);
793 void mk(
const char *n,
Int v,
const char *
c = 0);
794 void mk(
const char *n,
long v,
const char *
c = 0);
795 void mk(
const char *n,
float v,
const char *
c = 0);
796 void mk(
const char *n,
double v,
const char *
c = 0);
797 void mk(
const char *n,
Int r,
Int i,
const char *
c = 0);
798 void mk(
const char *n,
float r,
float i,
const char *
c = 0);
799 void mk(
const char *n,
double r,
double i,
const char *
c = 0);
803 void spaces(
const char *n = 0,
const char *
c = 0);
806 void comment(
const char *n = 0,
const char *
c = 0);
809 void history(
const char *
c = 0);
830 Bool isempty()
const;
848 void parse(
const char *,
int);
849 int no_parse_errs()
const;
850 const char *parse_err(
int)
const;
873 const void *
val,
const char *errmsg);
880 total(0), cursor(0) { }
889 int ndx) {
first();
return next(n,ndx); }
972 return kw.next(x,n); }
1001 int no_errs()
const;
1002 const char *err(
int)
const;
1003 int err_cardno(
int)
const;
1018 delete [] err_;
delete [] err_cardno_;
delete [] blanks; }
1022 return err_cardno_[i]; }
1034 static Bool isFP(
const float *);
1035 static Bool isFP(
const double *);
1036 static Bool isFP(
const void *);
1042 static void setNaN(
double &val);
1043 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
Float pow(Float f1, Float f2)
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
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.