File Coverage

blib/lib/Thrift/Parser/Type/list.pm
Criterion Covered Total %
statement 12 30 40.0
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 2 2 100.0
total 18 40 45.0


line stmt bran cond sub pod time code
1             package Thrift::Parser::Type::list;
2              
3             =head1 NAME
4              
5             Thrift::Parser::Type::list - list 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   33 use strict;
  6         11  
  6         197  
14 6     6   36 use warnings;
  6         11  
  6         217  
15 6     6   31 use base qw(Thrift::Parser::Type::Container);
  6         9  
  6         506  
16 6     6   34 use Data::Dumper;
  6         15  
  6         1768  
17              
18             sub read {
19 0     0 1   my ($self, $parser, $input, $meta) = @_;
20              
21 0           $input->readListBegin(\$meta->{val_type}, \$meta->{size});
22 0           my %val_meta = ( type => $meta->{val_type} );
23 0 0         $val_meta{idl}{type} = $parser->resolve_idl_type( $meta->{idl}{type} )->val_type if $meta->{idl};
24 0           my @list;
25 0           for (my $i = 0; $i < $meta->{size}; $i++) {
26 0           my $val = $parser->parse_type($input, { %val_meta });
27 0           push @list, $val;
28             }
29 0           $input->readListEnd();
30              
31 0           $self->value(\@list);
32 0           $self->val_type($meta->{val_type});
33 0           return $self;
34             }
35              
36             sub write {
37 0     0 1   my ($self, $output) = @_;
38              
39 0           my @list = @{ $self->value };
  0            
40 0           $output->writeListBegin($self->val_type, int @list);
41 0           $_->write($output) foreach @list;
42 0           $output->writeListEnd();
43             }
44              
45             =head1 COPYRIGHT
46              
47             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.
48              
49             The full text of the license can be found in the LICENSE file included with this module.
50              
51             =head1 AUTHOR
52              
53             Eric Waters
54              
55             =cut
56              
57             1;