line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Thrift::Parser::Type::map; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Thrift::Parser::Type::map - map type |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This class inherits from L. See the docs there for all the usage details. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
188
|
|
14
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
146
|
|
15
|
6
|
|
|
6
|
|
29
|
use base qw(Thrift::Parser::Type::Container); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
2676
|
|
16
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(key_type)); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub read { |
19
|
0
|
|
|
0
|
1
|
|
my ($self, $parser, $input, $meta) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my @map; |
22
|
0
|
|
|
|
|
|
$input->readMapBegin(\$meta->{key_type}, \$meta->{val_type}, \$meta->{size}); |
23
|
0
|
|
|
|
|
|
my %val_meta = ( type => $meta->{val_type} ); |
24
|
0
|
|
|
|
|
|
my %key_meta = ( type => $meta->{key_type} ); |
25
|
0
|
0
|
|
|
|
|
$val_meta{idl}{type} = $parser->resolve_idl_type( $meta->{idl}{type} )->val_type if $meta->{idl}; |
26
|
0
|
0
|
|
|
|
|
$key_meta{idl}{type} = $parser->resolve_idl_type( $meta->{idl}{type} )->key_type if $meta->{idl}; |
27
|
0
|
|
|
|
|
|
for (my $i = 0; $i < $meta->{size}; $i++) { |
28
|
0
|
|
|
|
|
|
my $key = $parser->parse_type($input, { %key_meta }); |
29
|
0
|
|
|
|
|
|
my $val = $parser->parse_type($input, { %val_meta }); |
30
|
0
|
|
|
|
|
|
push @map, [ $key => $val ]; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
$input->readMapEnd(); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->value(\@map); |
35
|
0
|
|
|
|
|
|
$self->val_type($meta->{val_type}); |
36
|
0
|
|
|
|
|
|
$self->key_type($meta->{key_type}); |
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub write { |
41
|
0
|
|
|
0
|
1
|
|
my ($self, $output) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my @map = @{ $self->value }; |
|
0
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$output->writeMapBegin($self->key_type, $self->val_type, int @map); |
45
|
0
|
|
|
|
|
|
foreach my $pair (@map) { |
46
|
0
|
|
|
|
|
|
$_->write($output) foreach @$pair; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
$output->writeMapEnd(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 COPYRIGHT |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with this module. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 AUTHOR |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Eric Waters |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |