| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::STSDAS::Table::Column; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005_62; |
|
4
|
4
|
|
|
4
|
|
40127
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
132
|
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
97
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
17
|
use Carp; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
373
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
1187
|
use Astro::STSDAS::Table::Constants; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
2225
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Column attributes |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# All tables: |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# name - the column name |
|
18
|
|
|
|
|
|
|
# units - the units string |
|
19
|
|
|
|
|
|
|
# format - the format string |
|
20
|
|
|
|
|
|
|
# idx - the column number (unary based) |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
# Binary Tables: |
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
# offset - the byte offset from the start of the row |
|
25
|
|
|
|
|
|
|
# (for row ordered tables) |
|
26
|
|
|
|
|
|
|
# |
|
27
|
|
|
|
|
|
|
# type - the data representation type (TY_REAL, |
|
28
|
|
|
|
|
|
|
# TY_DOUBLE, TY_INT, etc.) see the constants defined |
|
29
|
|
|
|
|
|
|
# above |
|
30
|
|
|
|
|
|
|
# |
|
31
|
|
|
|
|
|
|
# nelem - the number of elements in the cell. if the data type |
|
32
|
|
|
|
|
|
|
# is TY_STRING, this is the maximum number of |
|
33
|
|
|
|
|
|
|
# characters. if not a string, and if greater than |
|
34
|
|
|
|
|
|
|
# one, it indicates a vector. |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# fmt - the pack() compatible format to parse this column |
|
37
|
|
|
|
|
|
|
# (taking into account vectors) |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# size - # bytes in the data type |
|
40
|
|
|
|
|
|
|
# ifmt - pack() compatible format for this type (doesn't take |
|
41
|
|
|
|
|
|
|
# into account vectors) |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @colkeys = qw { name units format idx offset type nelem }; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
9
|
|
|
9
|
1
|
111534
|
my $class = shift; |
|
48
|
9
|
|
66
|
|
|
48
|
$class = ref($class) || $class; |
|
49
|
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
32
|
my $self = bless {}, $class; |
|
51
|
|
|
|
|
|
|
|
|
52
|
9
|
|
|
|
|
22
|
@{$self}{@colkeys} = @_; |
|
|
9
|
|
|
|
|
82
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
9
|
50
|
|
|
|
37
|
$self->{nelem} = 1 unless defined $self->{nelem}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
9
|
50
|
|
|
|
31
|
if ( defined $self->{type} ) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
9
|
50
|
|
|
|
40
|
croak( __PACKAGE__, '->new: illegal column type' ) |
|
59
|
|
|
|
|
|
|
unless exists $Types{$self->{type}}; |
|
60
|
9
|
|
|
|
|
37
|
$self->{size} = $TypeSize{$self->{type}}; |
|
61
|
9
|
|
|
|
|
35
|
$self->{fmt} = $self->{ifmt} = $TypeUPack{$self->{type}}; |
|
62
|
9
|
50
|
|
|
|
38
|
$self->{fmt} .= $self->{nelem} if $self->{nelem} > 1; |
|
63
|
9
|
|
|
|
|
26
|
$self->{indef} = $TypeIndef{$self->{type}}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
44
|
$self; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _access_rw |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
12
|
|
|
12
|
|
25
|
my $what = shift; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub { |
|
74
|
22
|
|
|
22
|
|
814
|
my $self = shift; |
|
75
|
22
|
100
|
|
|
|
70
|
$self->{$what} = $_[0] if @_; |
|
76
|
22
|
|
|
|
|
218
|
$self->{$what}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
12
|
|
|
|
|
92
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _access_ro |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
24
|
|
|
24
|
|
37
|
my $what = shift; |
|
83
|
29
|
100
|
|
29
|
|
3062
|
sub { croak( __PACKAGE__, "->$what: attempt to write to RO attribute" ) |
|
84
|
|
|
|
|
|
|
if @_ > 1; |
|
85
|
24
|
|
|
|
|
328
|
$_[0]->{$what} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
24
|
|
|
|
|
171
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
{ |
|
90
|
4
|
|
|
4
|
|
28
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
1372
|
|
|
91
|
|
|
|
|
|
|
*$_ = _access_rw( $_ ) |
|
92
|
|
|
|
|
|
|
foreach qw( name units format ); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
*$_ = _access_ro( $_ ) |
|
95
|
|
|
|
|
|
|
foreach qw ( idx offset type fmt size ifmt ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub is_string |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
2
|
100
|
|
2
|
1
|
456
|
defined $_[0]->{type} ? ($_[0]->{type} == TY_STRING ? 1 : 0) : undef; |
|
|
|
50
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub is_indef |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
2
|
50
|
|
2
|
1
|
24
|
$_[0]->{type} != TY_STRING && $_[0]->{indef} == $_[1]; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub is_vector |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
0
|
0
|
|
0
|
1
|
0
|
$_[0]->{type} != TY_STRING && $_[0]->{nelem} > 1; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub nelem |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
2
|
100
|
|
2
|
1
|
643
|
croak( __PACKAGE__, "->nelem: attempt to write to RO attribute" ) |
|
116
|
|
|
|
|
|
|
if @_ > 1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
50
|
33
|
|
|
13
|
defined $_[0]->{type} && $_[0]->{type} == TY_STRING ? |
|
119
|
|
|
|
|
|
|
1 : $_[0]->{nelem}; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub copy |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
3
|
|
|
3
|
1
|
8
|
$_[0]->new( @{$_[0]}{@colkeys} ); |
|
|
3
|
|
|
|
|
20
|
|
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
|
128
|
|
|
|
|
|
|
__END__ |