| 1 | #!/bin/false | ||||||||||||||||||||||||||||
| 2 | # PODNAME: BZ::Client::XMLRPC::Struct | ||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Event handler for parsing a single XML-RPC struct. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package BZ::Client::XMLRPC::Struct; | ||||||||||||||||||||||||||||
| 9 | 1 | $BZ::Client::XMLRPC::Struct::VERSION = '4.91'; | |||||||||||||||||||||||||||
| 10 | 1 | ▶ | use parent qw( BZ::Client::XMLRPC::Handler ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 0 | my ($self, $parser) = @_; | |||||||||||||||||||||||||||
| 14 | 0 | $self->SUPER::init($parser); | |||||||||||||||||||||||||||
| 15 | 0 | $self->{'result'} = {} | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub start { | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my($self,$name) = @_; | |||||||||||||||||||||||||||
| 20 | 0 | my $l = $self->inc_level(); | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($l == 0) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ('struct' ne $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | $self->error("Expected struct element, got $name"); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | elsif ($l == 1) { | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ('member' ne $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | $self->error("Expected struct/member element, got $name"); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 0 | $self->{'current_name'} = undef; | |||||||||||||||||||||||||||
| 31 | 0 | $self->{'parsing_name'} = undef; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | elsif ($l == 2) { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ('name' eq $name) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 35 | $self->error('Multiple name elements in struct/member') | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if defined $self->{'parsing_name'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $self->{'parsing_name'} = q(); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | elsif ('value' eq $name) { | ||||||||||||||||||||||||||||
| 40 | 0 | my $current_name = $self->{'current_name'}; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | $self->error('Expected struct/member/name element, got value') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | unless defined $current_name; | ||||||||||||||||||||||||||||
| 43 | $self->error('Multiple value elements in struct/member, or multiple members with the same name.') | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if defined $self->{'result'}->{$current_name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | my $handler = BZ::Client::XMLRPC::Value->new(); | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | $self->parser()->register($self, $handler, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 47 | 0 | $self->{'result'}->{$current_name} = $handler->result() | |||||||||||||||||||||||||||
| 48 | 0 | }); | |||||||||||||||||||||||||||
| 49 | 0 | $handler->start($name); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||
| 52 | 0 | $self->error("Expected name|value element in struct/member, got $name"); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||
| 56 | 0 | $self->error("Unexpected level $l with element $name"); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub end { | ||||||||||||||||||||||||||
|
Subroutine
end: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my($self,$name) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | my $l = $self->SUPER::end($name); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($l == 2 and defined($self->{'parsing_name'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$l == 2 and defined $self->{"parsing_name"}
MC/DC0%0/2
$l == 2 and defined $self->{"parsing_name"}
$l == 2
defined $self->{"parsing_name"}
Truth table0%0/3
A and B
A= $l == 2B= defined $self->{"parsing_name"}
| |||||||||||||||||||||||||||||
| 64 | 0 | $self->{'current_name'} = $self->{'parsing_name'}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 0 | return $l | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub characters { | ||||||||||||||||||||||||||
|
Subroutine
characters: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | 0 | my($self, $text) = @_; | |||||||||||||||||||||||||||
| 71 | 0 | my $l = $self->level(); | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($l == 3 and defined($self->{'parsing_name'})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$l == 3 and defined $self->{"parsing_name"}
MC/DC0%0/2
$l == 3 and defined $self->{"parsing_name"}
$l == 3
defined $self->{"parsing_name"}
Truth table0%0/3
A and B
A= $l == 3B= defined $self->{"parsing_name"}
| |||||||||||||||||||||||||||||
| 73 | 0 | $self->{'parsing_name'} .= $text; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||||||||
| 76 | 0 | $self->SUPER::characters($text); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub result { | ||||||||||||||||||||||||||
|
Subroutine
result: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 0 | return $self->{'result'} | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1 | 1; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||