| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PGObject::Type::BigFloat; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
74643
|
use 5.010; |
|
|
4
|
|
|
|
|
14
|
|
|
4
|
4
|
|
|
4
|
|
21
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
71
|
|
|
5
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
101
|
|
|
6
|
4
|
|
|
4
|
|
19
|
use base qw(Math::BigFloat); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
3217
|
|
|
7
|
4
|
|
|
4
|
|
69369
|
use PGObject; |
|
|
4
|
|
|
|
|
7575
|
|
|
|
4
|
|
|
|
|
21
|
|
|
8
|
4
|
|
|
4
|
|
104
|
use Carp; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
1113
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
PGObject::Type::BigFloat - Math::BigFloat wrappers for PGObject classes |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 2 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = 2.000000; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use PGObject::Type::BigFloat; |
|
26
|
|
|
|
|
|
|
PGObject::Type::BigFloat->register(); # Get all numeric and float types |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $self->{foo} = PGObject::Type::BigFloat->new(0); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$self->call_dbmethod(funcname => 'bar'); # will use this as a numeric |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 register(registry => 'default', types => ['float4', 'float8', 'numeric']) |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub register{ |
|
41
|
5
|
|
|
5
|
1
|
760
|
my $self = shift @_; |
|
42
|
5
|
|
|
|
|
17
|
my %args = @_; |
|
43
|
5
|
50
|
|
|
|
13
|
croak "Can't pass reference to register \n". |
|
44
|
|
|
|
|
|
|
"Hint: use the class instead of the object" if ref $self; |
|
45
|
5
|
|
|
|
|
12
|
my $registry = $args{registry}; |
|
46
|
5
|
|
100
|
|
|
20
|
$registry ||= 'default'; |
|
47
|
5
|
|
|
|
|
10
|
my $types = $args{types}; |
|
48
|
5
|
100
|
66
|
|
|
26
|
$types = ['float4', 'float8', 'numeric'] unless defined $types and @$types; |
|
49
|
5
|
|
|
|
|
14
|
for my $type (@$types){ |
|
50
|
11
|
50
|
|
|
|
38
|
if ($PGObject::VERSION =~ /^1\./){ |
|
51
|
11
|
|
|
|
|
32
|
my $ret = |
|
52
|
|
|
|
|
|
|
PGObject->register_type(registry => $registry, pg_type => $type, |
|
53
|
|
|
|
|
|
|
perl_class => $self); |
|
54
|
11
|
50
|
|
|
|
173
|
return $ret unless $ret; |
|
55
|
|
|
|
|
|
|
} else { |
|
56
|
0
|
|
|
|
|
0
|
PGObject::Type::Registry->register_type( |
|
57
|
|
|
|
|
|
|
registry => $registry, dbtype => $type, apptype => $self |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
5
|
|
|
|
|
21
|
return 1; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 to_db |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This serializes this into a simple db-friendly form. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub to_db { |
|
71
|
8
|
|
|
8
|
1
|
6787
|
my $self = shift @_; |
|
72
|
8
|
100
|
|
|
|
20
|
return undef if $self->is_undef; |
|
73
|
7
|
|
|
|
|
24
|
return $self->bstr; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 from_db |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
take simple normalized db floats and turn them into numeric representations. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub from_db { |
|
83
|
8
|
|
|
8
|
1
|
5741
|
my ($self, $value) = @_; |
|
84
|
8
|
|
|
|
|
32
|
my $obj = "$self"->new($value); |
|
85
|
8
|
100
|
|
|
|
1257
|
$obj->is_undef(1) if ! defined $value; |
|
86
|
8
|
|
|
|
|
17
|
return $obj; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 is_undef(optionally $set); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Return undef to the db or user interface. Can be set through apps. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub is_undef { |
|
96
|
9
|
|
|
9
|
1
|
17
|
my ($self, $set) = @_; |
|
97
|
9
|
100
|
|
|
|
24
|
$self->{_pgobject_undef} = $set if defined $set; |
|
98
|
9
|
|
|
|
|
25
|
return $self->{_pgobject_undef}; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Chris Travers, C<< >> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 BUGS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
108
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
109
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
perldoc PGObject::Type::BigFloat |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
You can also look for information at: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * Search CPAN |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright 2013-2014 Chris Travers. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This program is released under the following license: BSD |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; # End of PGObject::Type::BigFloat |