| 1 | package XML::XPath::NodeSet; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | $VERSION = '1.26'; | |||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use XML::XPath::Boolean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | use overload | ||||||||||
| 10 | 1 | '""' => \&to_literal, | |||||||||
| 11 | 'eq' => \&string_value, | ||||||||||
| 12 | 'ne' => \&string_value, | ||||||||||
| 13 | 'lt' => \&string_value, | ||||||||||
| 14 | 'le' => \&string_value, | ||||||||||
| 15 | 'gt' => \&string_value, | ||||||||||
| 16 | 'ge' => \&string_value, | ||||||||||
| 17 | 'bool' => \&to_boolean, | ||||||||||
| 18 | '==' => \&to_number, | ||||||||||
| 19 | '!=' => \&to_number, | ||||||||||
| 20 | '>' => \&to_number, | ||||||||||
| 21 | '<' => \&to_number, | ||||||||||
| 22 | '>=' => \&to_number, | ||||||||||
| 23 | '<=' => \&to_number, | ||||||||||
| 24 | 1 | ▶ | ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | sub new { | ||||||||||
| 27 | 0 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | 0 | bless [], $class; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | sub sort { | ||||||||||
| 32 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
sort: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 33 | 0 | @$self = CORE::sort { $a->get_global_pos <=> $b->get_global_pos } @$self; | |||||||||
| 34 | 0 | $self->remove_duplicates; | |||||||||
| 35 | 0 | return $self; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub remove_duplicates { | ||||||||||
| 39 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
remove_duplicates: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 40 | 0 | my @unique; | |||||||||
| 41 | 0 | my $last_node=0; | |||||||||
| 42 | 0 | foreach my $node (@$self) { | |||||||||
| 43 | 0 | ▶ | push @unique, $node unless( $node == $last_node); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | $last_node= $node; | |||||||||
| 45 | } | ||||||||||
| 46 | 0 | @$self= @unique; | |||||||||
| 47 | 0 | return $self; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub pop { | ||||||||||
| 51 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
pop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | 0 | CORE::pop @$self; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub push { | ||||||||||
| 56 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
push: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | 0 | my (@nodes) = @_; | |||||||||
| 58 | 0 | CORE::push @$self, @nodes; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub append { | ||||||||||
| 62 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
append: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 63 | 0 | my ($nodeset) = @_; | |||||||||
| 64 | 0 | CORE::push @$self, $nodeset->get_nodelist; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | sub shift { | ||||||||||
| 68 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
shift: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 69 | 0 | CORE::shift @$self; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | sub unshift { | ||||||||||
| 73 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
unshift: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 0 | my (@nodes) = @_; | |||||||||
| 75 | 0 | CORE::unshift @$self, @nodes; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | sub prepend { | ||||||||||
| 79 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
prepend: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 80 | 0 | my ($nodeset) = @_; | |||||||||
| 81 | 0 | CORE::unshift @$self, $nodeset->get_nodelist; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | sub size { | ||||||||||
| 85 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 86 | 0 | scalar @$self; | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | sub get_node { # uses array index starting at 1, not 0 | ||||||||||
| 90 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
get_node: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 91 | 0 | my ($pos) = @_; | |||||||||
| 92 | 0 | $self->[$pos - 1]; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | sub getRootNode { | ||||||||||
| 96 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
getRootNode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 97 | 0 | return $self->[0]->getRootNode; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | sub get_nodelist { | ||||||||||
| 101 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
get_nodelist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 102 | 0 | @$self; | |||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | sub to_boolean { | ||||||||||
| 106 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
to_boolean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 107 | 0 | ▶ | return (@$self > 0) ? XML::XPath::Boolean->True : XML::XPath::Boolean->False; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | sub string_value { | ||||||||||
| 111 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
string_value: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 112 | 0 | ▶ | return '' unless @$self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 0 | return $self->[0]->string_value; | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | sub to_literal { | ||||||||||
| 117 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
to_literal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 118 | return XML::XPath::Literal->new( | ||||||||||
| 119 | 0 | join('', map { $_->string_value } @$self) | |||||||||
| 120 | ); | ||||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | sub to_number { | ||||||||||
| 124 | 0 | ▶ | my $self = CORE::shift; | ||||||||
|
Subroutine
to_number: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 125 | 0 | return XML::XPath::Number->new( | |||||||||
| 126 | $self->to_literal | ||||||||||
| 127 | ); | ||||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 1 | 1; | |||||||||
| 131 | __END__ | ||||||||||