line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tags::Output::Structure; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
89759
|
use base qw(Tags::Output); |
|
9
|
|
|
|
|
72
|
|
|
9
|
|
|
|
|
5370
|
|
4
|
9
|
|
|
9
|
|
305832
|
use strict; |
|
9
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
200
|
|
5
|
9
|
|
|
9
|
|
49
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
279
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
49
|
use Error::Pure qw(err); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
1200
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.06; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Flush. |
12
|
|
|
|
|
|
|
sub flush { |
13
|
15
|
|
|
15
|
1
|
153
|
my ($self, $reset_flag) = @_; |
14
|
15
|
|
|
|
|
32
|
my $ouf = $self->{'output_handler'}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Text output. |
17
|
15
|
|
|
|
|
40
|
my $ret_ar; |
18
|
15
|
50
|
|
|
|
45
|
if ($ouf) { |
19
|
0
|
|
|
|
|
0
|
foreach my $line_ar (@{$self->{'flush_code'}}) { |
|
0
|
|
|
|
|
0
|
|
20
|
0
|
|
|
|
|
0
|
my $line = "['"; |
21
|
0
|
|
|
|
|
0
|
$line .= join "', '", @{$line_ar}; |
|
0
|
|
|
|
|
0
|
|
22
|
0
|
|
|
|
|
0
|
$line .= "']".$self->{'output_sep'}; |
23
|
9
|
|
|
9
|
|
82
|
no warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
5137
|
|
24
|
0
|
0
|
|
|
|
0
|
print {$ouf} $line |
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
or err 'Cannot write to output handler.'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Structure. |
29
|
|
|
|
|
|
|
} else { |
30
|
15
|
|
|
|
|
24
|
$ret_ar = $self->{'flush_code'}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Reset. |
34
|
15
|
50
|
|
|
|
54
|
if ($reset_flag) { |
35
|
0
|
|
|
|
|
0
|
$self->reset; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
15
|
|
|
|
|
53
|
return $ret_ar; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Attributes. |
42
|
|
|
|
|
|
|
sub _put_attribute { |
43
|
9
|
|
|
9
|
|
222
|
my ($self, $attr, $value) = @_; |
44
|
9
|
|
|
|
|
40
|
$self->_put_structure('a', $attr, $value); |
45
|
9
|
|
|
|
|
19
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Begin of tag. |
49
|
|
|
|
|
|
|
sub _put_begin_of_tag { |
50
|
15
|
|
|
15
|
|
13169
|
my ($self, $tag) = @_; |
51
|
15
|
|
|
|
|
48
|
$self->_put_structure('b', $tag); |
52
|
15
|
|
|
|
|
25
|
unshift @{$self->{'printed_tags'}}, $tag; |
|
15
|
|
|
|
|
35
|
|
53
|
15
|
|
|
|
|
34
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# CData. |
57
|
|
|
|
|
|
|
sub _put_cdata { |
58
|
1
|
|
|
1
|
|
207
|
my ($self, @cdata) = @_; |
59
|
1
|
|
|
|
|
7
|
$self->_put_structure('cd', @cdata); |
60
|
1
|
|
|
|
|
3
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Comment. |
64
|
|
|
|
|
|
|
sub _put_comment { |
65
|
2
|
|
|
2
|
|
240
|
my ($self, @comments) = @_; |
66
|
2
|
|
|
|
|
8
|
$self->_put_structure('c', @comments); |
67
|
2
|
|
|
|
|
5
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Data. |
71
|
|
|
|
|
|
|
sub _put_data { |
72
|
6
|
|
|
6
|
|
77
|
my ($self, @data) = @_; |
73
|
6
|
|
|
|
|
16
|
$self->_put_structure('d', @data); |
74
|
6
|
|
|
|
|
13
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# End of tag. |
78
|
|
|
|
|
|
|
sub _put_end_of_tag { |
79
|
15
|
|
|
15
|
|
282
|
my ($self, $tag) = @_; |
80
|
15
|
|
|
|
|
22
|
my $printed = shift @{$self->{'printed_tags'}}; |
|
15
|
|
|
|
|
31
|
|
81
|
15
|
100
|
|
|
|
63
|
if ($printed ne $tag) { |
82
|
1
|
|
|
|
|
10
|
err "Ending bad tag: '$tag' in block of tag '$printed'."; |
83
|
|
|
|
|
|
|
} |
84
|
14
|
|
|
|
|
37
|
$self->_put_structure('e', $tag); |
85
|
14
|
|
|
|
|
30
|
return; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Instruction. |
89
|
|
|
|
|
|
|
sub _put_instruction { |
90
|
2
|
|
|
2
|
|
602
|
my ($self, $target, $code) = @_; |
91
|
2
|
|
|
|
|
6
|
my @instruction = ('i', $target); |
92
|
2
|
100
|
|
|
|
6
|
if ($code) { |
93
|
1
|
|
|
|
|
3
|
push @instruction, $code; |
94
|
|
|
|
|
|
|
} |
95
|
2
|
|
|
|
|
8
|
$self->_put_structure(@instruction); |
96
|
2
|
|
|
|
|
6
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Raw data. |
100
|
|
|
|
|
|
|
sub _put_raw { |
101
|
1
|
|
|
1
|
|
192
|
my ($self, @raw_data) = @_; |
102
|
1
|
|
|
|
|
5
|
$self->_put_structure('r', @raw_data); |
103
|
1
|
|
|
|
|
2
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Put common structure. |
107
|
|
|
|
|
|
|
sub _put_structure { |
108
|
50
|
|
|
50
|
|
119
|
my ($self, @struct) = @_; |
109
|
50
|
|
|
|
|
72
|
push @{$self->{'flush_code'}}, \@struct; |
|
50
|
|
|
|
|
112
|
|
110
|
50
|
|
|
|
|
91
|
return; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |