NAME
Thrift::Parser::Type::Container - Container base class
DESCRIPTION
This class implements common behavior for Thrift::Parser::Type::list, Thrift::Parser::Type::map and Thrift::Parser::Type::set.
METHODS
This class inherits from Thrift::Parser::Type; see docs there for inherited methods.
compose
$map_class->define(..)->compose({ key => $value, ... });
$map_class->define(..)->compose([ $key => $value, ... ]);
$list_set_class->define(..)->compose([ $item, $item ]);
Call "define" first before using this method. If map, call with array or hashref. For set and list, call with arrayref. Creates a new object in this class. Throws Thrift::Parser::InvalidArgument.
define
my $list = $list_class->define('::string')->compose([ ... ]);
my $nested_list = $list_class->define('::list' => [ '::string' ])->compose([ ... ]);
my $map = $map_class->define('::i32', '::string')->compose([ ... ]);
Call define with a list of class names that define the structure of this container. In the case of map, pass two values, $key_class and $val_class. For set and list, just $val_class. If either the key or the value class are themselves containers, the next argument is expected to be an arrayref of arguments for the nested define()
call. Returns a new object which is ready for "compose" to be called.
keys
Valid only for map types. Returns a list of the keys.
values
Returns a list of the values.
size
Returns the number of values or key/value pairs (in the case of a map).
each
Sets up an iterator over all the elements of this object and returns the next value or key/value pair (as list). Returns undef or an empty list (in the case of a map). Does not auto-reset; call "each_reset" to reset the iterator.
each_reset
Resets the "reset" iterator.
index
my $value = $list->index(0);
my ($key, $value) = $map->index(0);
Returns the value at the index given (zero starting). Returns a list if a map type. Returns undef or () if not present. Throws Thrift::Parser::InvalidArgument.
COPYRIGHT
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.
The full text of the license can be found in the LICENSE file included with this module.
AUTHOR
Eric Waters <ewaters@gmail.com>