line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMIL::XMLContainer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "0.898"; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use SMIL::XMLBase; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
922
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@ISA = qw( SMIL::XMLBase ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $contents = "_contents"; |
10
|
|
|
|
|
|
|
my $order = "_order"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub addTagContents { |
13
|
|
|
|
|
|
|
|
14
|
19
|
|
|
19
|
0
|
24
|
my $self = shift; |
15
|
19
|
|
|
|
|
23
|
my $push = shift; |
16
|
19
|
|
|
|
|
53
|
my %hash = @_; |
17
|
|
|
|
|
|
|
|
18
|
19
|
|
|
|
|
32
|
my $the_ref = ref( $self ); |
19
|
|
|
|
|
|
|
|
20
|
19
|
100
|
|
|
|
69
|
$self->{$order} = [] unless $self->{$order}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Build an order array, but make sure we don't reuse items |
23
|
19
|
|
|
|
|
20
|
my @ordering; |
24
|
19
|
|
|
|
|
23
|
my $toggle = 0; |
25
|
|
|
|
|
|
|
|
26
|
19
|
|
|
|
|
35
|
foreach $item ( @_ ) { |
27
|
38
|
100
|
|
|
|
103
|
if( $toggle = !$toggle ) { |
28
|
|
|
|
|
|
|
|
29
|
19
|
|
|
|
|
21
|
my $exists = 0; |
30
|
|
|
|
|
|
|
|
31
|
19
|
|
|
|
|
19
|
foreach $pretest_item ( @{$self->{$order}} ) { |
|
19
|
|
|
|
|
49
|
|
32
|
17
|
100
|
|
|
|
45
|
$exists = 1 if $item eq $pretest_item; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
19
|
100
|
|
|
|
46
|
if( !$exists ) { |
36
|
18
|
50
|
|
|
|
32
|
if( $push ) { |
37
|
18
|
|
|
|
|
20
|
push @{$self->{$order}}, $item; |
|
18
|
|
|
|
|
66
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
0
|
|
|
|
|
0
|
unshift @{$self->{$order}}, $item; |
|
0
|
|
|
|
|
0
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# The contents is a hash |
47
|
19
|
|
|
|
|
37
|
my $hash_ref = $self->{$contents}; |
48
|
19
|
100
|
|
|
|
37
|
if( !$hash_ref ) { |
49
|
9
|
|
|
|
|
14
|
$hash_ref = {}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Each item in contents can be a an object (a hash) |
53
|
|
|
|
|
|
|
# or an array, so that would likely be an array of hash refs |
54
|
19
|
|
|
|
|
77
|
foreach $item ( keys %hash ) { |
55
|
|
|
|
|
|
|
# See what the item is |
56
|
19
|
|
|
|
|
44
|
$type = ref( $hash{ $item } ); |
57
|
|
|
|
|
|
|
|
58
|
19
|
100
|
|
|
|
42
|
if( !$$hash_ref{ $item } ) { |
59
|
18
|
50
|
|
|
|
276
|
if( $type =~ /HASH/ ) { |
|
|
100
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
$$hash_ref{ $item } = []; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif( $type =~ /ARRAY/ ) { |
63
|
2
|
|
|
|
|
5
|
$$hash_ref{ $item } = []; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# It is setup, now put the item in there |
68
|
19
|
|
|
|
|
59
|
$hash_ref->{ $item } = $hash{ $item }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
19
|
|
|
|
|
172
|
$self->{$contents} = $hash_ref; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub unshiftTagContents { |
76
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
77
|
0
|
|
|
|
|
0
|
$self->addTagContents( 0, @_ ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub setTagContents { |
81
|
19
|
|
|
19
|
0
|
28
|
my $self = shift; |
82
|
19
|
|
|
|
|
70
|
$self->addTagContents( 1, @_ ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub getContentObjectNames { |
86
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
87
|
0
|
|
|
|
|
0
|
my $obj_ref = $self->{$contents}; |
88
|
0
|
|
|
|
|
0
|
return keys %$obj_ref; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub getContentObjectByName { |
92
|
17
|
|
|
17
|
0
|
27
|
my $self = shift; |
93
|
17
|
|
|
|
|
26
|
my $name = shift; |
94
|
|
|
|
|
|
|
|
95
|
17
|
|
|
|
|
19
|
my $create = shift; |
96
|
17
|
|
|
|
|
90
|
return $self->{$contents}->{$name}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub getAsString { |
100
|
9
|
|
|
9
|
0
|
13
|
my $self = shift; |
101
|
9
|
|
|
|
|
7
|
my $return_string; |
102
|
9
|
|
|
|
|
52
|
my $tab = $self->getTabBuffer(); |
103
|
|
|
|
|
|
|
|
104
|
9
|
|
|
|
|
71
|
$return_string .= |
105
|
|
|
|
|
|
|
"$tab<" . $self->getTag() . $self->_build_attributes() . ">\n"; |
106
|
9
|
|
|
|
|
61
|
$self->increaseTabBuffer(); |
107
|
|
|
|
|
|
|
|
108
|
9
|
|
|
|
|
15
|
my $contents_ref = $self->{$contents}; |
109
|
9
|
|
|
|
|
12
|
my $order_ref = $self->{$order}; |
110
|
9
|
|
|
|
|
18
|
foreach $item ( @$order_ref ) { |
111
|
|
|
|
|
|
|
|
112
|
18
|
|
|
|
|
28
|
my $obj = $$contents_ref{ $item }; |
113
|
18
|
|
|
|
|
30
|
my $type = ref $obj; |
114
|
|
|
|
|
|
|
|
115
|
18
|
100
|
|
|
|
39
|
if( $type =~ /ARRAY/ ) { |
116
|
2
|
|
|
|
|
4
|
foreach $nibble ( @$obj ) { |
117
|
5
|
50
|
|
|
|
28
|
$return_string .= $nibble->getAsString() . "\n" if $nibble; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
else { |
121
|
16
|
50
|
|
|
|
102
|
$return_string .= $obj->getAsString() . "\n" if $obj; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
9
|
|
|
|
|
58
|
$self->decreaseTabBuffer(); |
127
|
9
|
|
|
|
|
29
|
$return_string .= "$tab" . $self->getTag() . ">"; |
128
|
|
|
|
|
|
|
|
129
|
9
|
|
|
|
|
60
|
return $return_string; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|