line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::MPD::Response; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
112
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
465
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
0
|
|
my ($class, $response, @lines) = @_; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
my $self = bless { |
10
|
|
|
|
|
|
|
lines => [ @lines ], |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
|
|
|
|
if (my @args = $response =~ /^ACK \[(\d+)@(\d+)\] {(\w*)} (.*)$/) { |
14
|
0
|
|
|
|
|
|
$self->{error} = $args[0]; |
15
|
0
|
|
|
|
|
|
$self->{line} = $args[1]; |
16
|
0
|
|
|
|
|
|
$self->{command} = $args[2]; |
17
|
0
|
|
|
|
|
|
$self->{message} = $args[3]; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub is_ok { |
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
25
|
0
|
0
|
|
|
|
|
return $self->{error} ? undef : 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub is_error { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
0
|
|
|
|
|
return $self->{error} ? 1 : undef; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub error { |
34
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
return $self->{error}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub line { |
39
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
40
|
0
|
|
|
|
|
|
return $self->{line}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub command { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
return $self->{command}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub message { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
|
0
|
|
|
|
return $self->{message} || ''; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub lines { |
54
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
55
|
0
|
|
|
|
|
|
return @{$self->{lines}}; |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_hash { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $hash = {}; |
61
|
0
|
|
|
|
|
|
foreach my $line (@{$self->{lines}}) { |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my ($name, $value) = split /: /, $line, 2; |
63
|
0
|
|
|
|
|
|
$hash->{$name} = $value; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
return $hash; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |