line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This is free software, you may use it and distribute it under the same terms as |
4
|
|
|
|
|
|
|
# Perl itself. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package XML::LibXML::Number; |
11
|
66
|
|
|
66
|
|
473
|
use XML::LibXML::Boolean; |
|
66
|
|
|
|
|
138
|
|
|
66
|
|
|
|
|
2258
|
|
12
|
66
|
|
|
66
|
|
28599
|
use XML::LibXML::Literal; |
|
66
|
|
|
|
|
200
|
|
|
66
|
|
|
|
|
1812
|
|
13
|
66
|
|
|
66
|
|
418
|
use strict; |
|
66
|
|
|
|
|
139
|
|
|
66
|
|
|
|
|
1268
|
|
14
|
66
|
|
|
66
|
|
336
|
use warnings; |
|
66
|
|
|
|
|
168
|
|
|
66
|
|
|
|
|
3265
|
|
15
|
|
|
|
|
|
|
|
16
|
66
|
|
|
66
|
|
391
|
use vars qw ($VERSION); |
|
66
|
|
|
|
|
128
|
|
|
66
|
|
|
|
|
5040
|
|
17
|
|
|
|
|
|
|
$VERSION = "2.0207"; # VERSION TEMPLATE: DO NOT CHANGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use overload |
20
|
66
|
|
|
|
|
976
|
'""' => \&value, |
21
|
|
|
|
|
|
|
'0+' => \&value, |
22
|
66
|
|
|
66
|
|
464
|
'<=>' => \&cmp; |
|
66
|
|
|
|
|
146
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
27
|
|
|
27
|
1
|
69
|
my $class = shift; |
26
|
27
|
|
|
|
|
47
|
my $number = shift; |
27
|
27
|
50
|
|
|
|
342
|
if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { |
28
|
0
|
|
|
|
|
0
|
$number = undef; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
27
|
|
|
|
|
100
|
$number =~ s/\s+//g; |
32
|
|
|
|
|
|
|
} |
33
|
27
|
|
|
|
|
152
|
bless \$number, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub as_string { |
37
|
22
|
|
|
22
|
0
|
39
|
my $self = shift; |
38
|
22
|
50
|
|
|
|
150
|
defined $$self ? $$self : 'NaN'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub as_xml { |
42
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
43
|
0
|
0
|
|
|
|
0
|
return "" . (defined($$self) ? $$self : 'NaN') . "\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub value { |
47
|
3
|
|
|
3
|
1
|
897
|
my $self = shift; |
48
|
3
|
|
|
|
|
17
|
$$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub cmp { |
52
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
53
|
1
|
|
|
|
|
5
|
my ($other, $swap) = @_; |
54
|
1
|
50
|
|
|
|
4
|
if ($swap) { |
55
|
0
|
|
|
|
|
0
|
return $other <=> $$self; |
56
|
|
|
|
|
|
|
} |
57
|
1
|
|
|
|
|
8
|
return $$self <=> $other; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub evaluate { |
61
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
62
|
0
|
|
|
|
|
0
|
$self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub to_boolean { |
66
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
67
|
0
|
0
|
|
|
|
0
|
return $$self ? XML::LibXML::Boolean->True : XML::LibXML::Boolean->False; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
22
|
|
|
22
|
0
|
83
|
sub to_literal { XML::LibXML::Literal->new($_[0]->as_string); } |
71
|
0
|
|
|
0
|
0
|
|
sub to_number { $_[0]; } |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
0
|
|
sub string_value { return $_[0]->value } |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |