line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/Number.pm 17 2006-02-12T08:00:01.814064Z mrodrigu $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Tree::XPathEngine::Number; |
4
|
5
|
|
|
5
|
|
26
|
use Tree::XPathEngine::Boolean; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
177
|
|
5
|
5
|
|
|
5
|
|
3758
|
use Tree::XPathEngine::Literal; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
141
|
|
6
|
5
|
|
|
5
|
|
38
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
299
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
5
|
|
|
|
|
39
|
'""' => \&value, |
10
|
|
|
|
|
|
|
'0+' => \&value, |
11
|
5
|
|
|
5
|
|
26
|
'<=>' => \&xpath_cmp; |
|
5
|
|
|
|
|
10
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
318
|
|
|
318
|
1
|
1733
|
my $class = shift; |
15
|
318
|
|
|
|
|
481
|
my $number = shift; |
16
|
318
|
100
|
|
|
|
1813
|
if ($number !~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) { |
17
|
25
|
|
|
|
|
36
|
$number = undef; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
else { |
20
|
293
|
|
|
|
|
1654
|
$number =~ s/^\s*(.*)\s*$/$1/; |
21
|
|
|
|
|
|
|
} |
22
|
318
|
|
|
|
|
1990
|
bless \$number, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub as_string { |
26
|
7
|
|
|
7
|
1
|
13
|
my $self = shift; |
27
|
7
|
50
|
|
|
|
53
|
defined $$self ? $$self : 'NaN'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub as_xml { |
31
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
32
|
0
|
0
|
|
|
|
0
|
return "" . (defined($$self) ? $$self : 'NaN') . "\n"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub value { |
36
|
559
|
|
|
559
|
1
|
979
|
my $self = shift; |
37
|
559
|
|
|
|
|
2938
|
$$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub xpath_cmp { |
41
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
42
|
0
|
|
|
|
|
0
|
my ($other, $swap) = @_; |
43
|
0
|
0
|
|
|
|
0
|
if ($swap) { |
44
|
0
|
|
|
|
|
0
|
return $other <=> $$self; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
0
|
return $$self <=> $other; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub evaluate { |
50
|
325
|
|
|
325
|
1
|
434
|
my $self = shift; |
51
|
325
|
|
|
|
|
793
|
$self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub xpath_to_boolean { |
55
|
2
|
|
|
2
|
1
|
158
|
my $self = shift; |
56
|
2
|
100
|
|
|
|
12
|
return $$self ? Tree::XPathEngine::Boolean->_true : Tree::XPathEngine::Boolean->_false; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
7
|
1
|
32
|
sub xpath_to_literal { Tree::XPathEngine::Literal->new($_[0]->as_string); } |
60
|
282
|
|
|
282
|
1
|
1171
|
sub xpath_to_number { $_[0]; } |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
|
sub xpath_string_value { return $_[0]->value } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |