| 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<Thrift::Parser::Type::Container>. See the docs there for all the usage details. | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 6 | ▶ | use base qw(Thrift::Parser::Type::Container); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 6 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub read { | ||||||||
|
Subroutine
read: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 19 | 0 | 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 | ▶ | $val_meta{idl}{type} = $parser->resolve_idl_type( $meta->{idl}{type} )->val_type if $meta->{idl}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | my @list; | |||||||||
| 25 | 0 | ▶ | for (my $i = 0; $i < $meta->{size}; $i++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 0 | ▶ | sub write { | ||||||||
|
Subroutine
write: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 37 | 0 | my ($self, $output) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 0 | my @list = @{ $self->value }; | |||||||||
| 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 <ewaters@gmail.com> | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | |||||||||||
| 57 | 6 | 1; | |||||||||