| 1 | package Thrift::Parser::Field; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Thrift::Parser::Field - A single field in a structure | ||
| 6 | |||
| 7 | =cut | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use warnings; | ||
| 11 | use base qw(Class::Accessor::Grouped); | ||
| 12 | __PACKAGE__->mk_group_accessors(inherited => qw(id name value)); | ||
| 13 | |||
| 14 | =head1 USAGE | ||
| 15 | |||
| 16 | =head2 id | ||
| 17 | |||
| 18 | Returns the id of this field in the structure. | ||
| 19 | |||
| 20 | =head2 name | ||
| 21 | |||
| 22 | Returns the name of the field. | ||
| 23 | |||
| 24 | =head2 value | ||
| 25 | |||
| 26 | Returns the L<Thrift::Parser::Type> object representing the value of this field. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | sub new { | ||
| 31 | my ($class, $self) = @_; | ||
| 32 | $self ||= {}; | ||
| 33 | return bless $self, $class; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub write { | ||
| 37 | my ($self, $output) = @_; | ||
| 38 | |||
| 39 | $output->writeFieldBegin($self->name, $self->value->type_id, $self->id); | ||
| 40 | $self->value->write($output); | ||
| 41 | $output->writeFieldEnd(); | ||
| 42 | } | ||
| 43 | |||
| 44 | =head1 COPYRIGHT | ||
| 45 | |||
| 46 | 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. | ||
| 47 | |||
| 48 | The full text of the license can be found in the LICENSE file included with this module. | ||
| 49 | |||
| 50 | =head1 AUTHOR | ||
| 51 | |||
| 52 | Eric Waters <ewaters@gmail.com> | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | 1; |