File Coverage

blib/lib/Astro/STSDAS/Table/Constants.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod n/a
total 44 44 100.0


line stmt bran cond sub pod time code
1             package Astro::STSDAS::Table::Constants;
2              
3             require 5.005_62;
4 7     7   1106 use strict;
  7         15  
  7         292  
5 7     7   41 use warnings;
  7         11  
  7         639  
6              
7             require Exporter;
8              
9             our @ISA = qw(Exporter);
10              
11             our @EXPORT = qw(
12             TT_ROW_ORDER
13             TT_COL_ORDER
14             CHAR_SZ
15             TY_REAL
16             TY_DOUBLE
17             TY_INT
18             TY_SHORT
19             TY_BOOL
20             TY_STRING
21             %TypeSize
22             %TypeUPack
23             %TypeIndef
24             %HdrType
25             %Types
26             );
27              
28             our $VERSION = '0.01';
29              
30 7     7   45 use constant TT_ROW_ORDER => 11;
  7         27  
  7         633  
31 7     7   34 use constant TT_COL_ORDER => 12;
  7         14  
  7         435  
32              
33 7     7   34 use constant CHAR_SZ => 2;
  7         12  
  7         321  
34              
35             # column data representation types; from IRAF unix/hlib/iraf.h
36 7     7   34 use constant TY_BOOL => 1;
  7         10  
  7         376  
37 7     7   33 use constant TY_SHORT => 3;
  7         16  
  7         327  
38 7     7   31 use constant TY_INT => 4;
  7         12  
  7         394  
39 7     7   32 use constant TY_REAL => 6;
  7         12  
  7         1432  
40 7     7   46 use constant TY_DOUBLE => 7;
  7         31  
  7         337  
41             # special to STSDAS tables
42 7     7   35 use constant TY_STRING => -1;
  7         10  
  7         3687  
43              
44             our @Types = ( TY_BOOL, TY_SHORT, TY_INT, TY_REAL, TY_DOUBLE, TY_STRING );
45             our %Types = map { $_ => 1 } @Types;
46              
47             # from IRAF unix/hlib/iraf.h
48             our %TypeSize = (
49             TY_BOOL() => 2 * CHAR_SZ,
50             TY_SHORT() => 1 * CHAR_SZ,
51             TY_INT() => 2 * CHAR_SZ,
52             TY_REAL() => 2 * CHAR_SZ,
53             TY_DOUBLE() => 4 * CHAR_SZ,
54             );
55              
56              
57             # use Perl pack types which have as exact a length as possible
58             our %TypeUPack = (
59             TY_BOOL() => 'l',
60             TY_SHORT() => 's',
61             TY_INT() => 'l',
62             TY_REAL() => 'f',
63             TY_DOUBLE() => 'd',
64             TY_STRING() => 'a',
65             );
66              
67              
68             # values that indicate the data are undefined.
69             # these are taken from the IRAF unix/hlib/iraf.h file,
70             # except for the TY_DOUBLE value, which is from the STSDAS Table
71             # tbtables.h file.
72             our %TypeIndef = (
73             TY_BOOL() => '', # not possible
74             TY_SHORT() => -32767,
75             TY_INT() => -2147483647,
76             # since Perl is double precision, do this to get
77             # single precision value of 1.6e38
78             TY_REAL() => unpack('f', pack('f', 1.6e38)),
79             TY_DOUBLE() => 1.6e38,
80             TY_STRING() => '' # not meaningful
81             );
82              
83             our %HdrType = (
84             b => TY_BOOL,
85             i => TY_INT,
86             r => TY_REAL,
87             d => TY_DOUBLE,
88             t => TY_STRING,
89             );
90              
91             1;
92