line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# PODNAME: BZ::Client::XMLRPC::Struct |
3
|
|
|
|
|
|
|
# ABSTRACT: Event handler for parsing a single XML-RPC struct. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package BZ::Client::XMLRPC::Struct; |
9
|
|
|
|
|
|
|
$BZ::Client::XMLRPC::Struct::VERSION = '4.4002'; |
10
|
1
|
|
|
1
|
|
5
|
use parent qw( BZ::Client::XMLRPC::Handler ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
0
|
|
|
0
|
0
|
|
my ($self, $parser) = @_; |
14
|
0
|
|
|
|
|
|
$self->SUPER::init($parser); |
15
|
0
|
|
|
|
|
|
$self->{'result'} = {} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub start { |
19
|
0
|
|
|
0
|
0
|
|
my($self,$name) = @_; |
20
|
0
|
|
|
|
|
|
my $l = $self->inc_level(); |
21
|
0
|
0
|
|
|
|
|
if ($l == 0) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ('struct' ne $name) { |
23
|
0
|
|
|
|
|
|
$self->error("Expected struct element, got $name"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($l == 1) { |
27
|
0
|
0
|
|
|
|
|
if ('member' ne $name) { |
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
|
0
|
|
|
|
|
if ('name' eq $name) { |
|
|
0
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->error('Multiple name elements in struct/member') |
36
|
0
|
0
|
|
|
|
|
if defined $self->{'parsing_name'}; |
37
|
0
|
|
|
|
|
|
$self->{'parsing_name'} = q(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ('value' eq $name) { |
40
|
0
|
|
|
|
|
|
my $current_name = $self->{'current_name'}; |
41
|
0
|
0
|
|
|
|
|
$self->error('Expected struct/member/name element, got value') |
42
|
|
|
|
|
|
|
unless defined $current_name; |
43
|
|
|
|
|
|
|
$self->error('Multiple value elements in struct/member, or multiple members with the same name.') |
44
|
0
|
0
|
|
|
|
|
if defined $self->{'result'}->{$current_name}; |
45
|
0
|
|
|
|
|
|
my $handler = BZ::Client::XMLRPC::Value->new(); |
46
|
|
|
|
|
|
|
$self->parser()->register($self, $handler, sub { |
47
|
0
|
|
|
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
|
|
|
|
|
|
|
sub end { |
61
|
0
|
|
|
0
|
0
|
|
my($self,$name) = @_; |
62
|
0
|
|
|
|
|
|
my $l = $self->SUPER::end($name); |
63
|
0
|
0
|
0
|
|
|
|
if ($l == 2 and defined($self->{'parsing_name'})) { |
64
|
0
|
|
|
|
|
|
$self->{'current_name'} = $self->{'parsing_name'}; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
return $l |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub characters { |
70
|
0
|
|
|
0
|
0
|
|
my($self, $text) = @_; |
71
|
0
|
|
|
|
|
|
my $l = $self->level(); |
72
|
0
|
0
|
0
|
|
|
|
if ($l == 3 and defined($self->{'parsing_name'})) { |
73
|
0
|
|
|
|
|
|
$self->{'parsing_name'} .= $text; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else { |
76
|
0
|
|
|
|
|
|
$self->SUPER::characters($text); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub result { |
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
return $self->{'result'} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
BZ::Client::XMLRPC::Struct - Event handler for parsing a single XML-RPC struct. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
version 4.4002 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHORS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Dean Hamstead <dean@bytefoundry.com.au> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Jochen Wiedmann <jochen.wiedmann@gmail.com> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Dean Hamstad. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |