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
|
67
|
|
|
67
|
|
479
|
use XML::LibXML::Boolean; |
|
67
|
|
|
|
|
151
|
|
|
67
|
|
|
|
|
2316
|
|
12
|
67
|
|
|
67
|
|
28785
|
use XML::LibXML::Literal; |
|
67
|
|
|
|
|
201
|
|
|
67
|
|
|
|
|
1829
|
|
13
|
67
|
|
|
67
|
|
434
|
use strict; |
|
67
|
|
|
|
|
155
|
|
|
67
|
|
|
|
|
1268
|
|
14
|
67
|
|
|
67
|
|
366
|
use warnings; |
|
67
|
|
|
|
|
171
|
|
|
67
|
|
|
|
|
3652
|
|
15
|
|
|
|
|
|
|
|
16
|
67
|
|
|
67
|
|
538
|
use vars qw ($VERSION); |
|
67
|
|
|
|
|
120
|
|
|
67
|
|
|
|
|
5167
|
|
17
|
|
|
|
|
|
|
$VERSION = "2.0209"; # VERSION TEMPLATE: DO NOT CHANGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use overload |
20
|
67
|
|
|
|
|
512
|
'""' => \&value, |
21
|
|
|
|
|
|
|
'0+' => \&value, |
22
|
67
|
|
|
67
|
|
473
|
'<=>' => \&cmp; |
|
67
|
|
|
|
|
177
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
27
|
|
|
27
|
1
|
66
|
my $class = shift; |
26
|
27
|
|
|
|
|
57
|
my $number = shift; |
27
|
27
|
50
|
|
|
|
318
|
if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { |
28
|
0
|
|
|
|
|
0
|
$number = undef; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
27
|
|
|
|
|
106
|
$number =~ s/\s+//g; |
32
|
|
|
|
|
|
|
} |
33
|
27
|
|
|
|
|
146
|
bless \$number, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub as_string { |
37
|
22
|
|
|
22
|
0
|
33
|
my $self = shift; |
38
|
22
|
50
|
|
|
|
134
|
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
|
578
|
my $self = shift; |
48
|
3
|
|
|
|
|
15
|
$$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub cmp { |
52
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
53
|
1
|
|
|
|
|
3
|
my ($other, $swap) = @_; |
54
|
1
|
50
|
|
|
|
3
|
if ($swap) { |
55
|
0
|
|
|
|
|
0
|
return $other <=> $$self; |
56
|
|
|
|
|
|
|
} |
57
|
1
|
|
|
|
|
6
|
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
|
58
|
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__ |