diff options
| author | fukachan <fukachan> | 2001-01-28 07:00:24 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-28 07:00:24 +0000 |
| commit | 5395a27f92f0d66d6276c687a02ebf3fc5c68cfb (patch) | |
| tree | 698edac8e4b7c4cf9a6e84f74f62e2f04132d2b6 /fml/lib/IO/Adapter/Array.pm | |
| parent | a073e7b6028b475043bea203892eba1e8cfe48b1 (diff) | |
| download | fml8-5395a27f92f0d66d6276c687a02ebf3fc5c68cfb.tar.gz fml8-5395a27f92f0d66d6276c687a02ebf3fc5c68cfb.tar.bz2 fml8-5395a27f92f0d66d6276c687a02ebf3fc5c68cfb.zip | |
clean up codes as an adapter for array reference.
Diffstat (limited to 'fml/lib/IO/Adapter/Array.pm')
| -rw-r--r-- | fml/lib/IO/Adapter/Array.pm | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/fml/lib/IO/Adapter/Array.pm b/fml/lib/IO/Adapter/Array.pm index 4caaee1d..7bfea79b 100644 --- a/fml/lib/IO/Adapter/Array.pm +++ b/fml/lib/IO/Adapter/Array.pm @@ -8,7 +8,7 @@ # $FML$ # -package IO::MapAdapter::Array; +package IO::Adapter::Array; use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; @@ -26,6 +26,57 @@ sub new } +sub open +{ + my ($self, $args) = @_; + my $flag = $args->{ flag } || 'r'; + my $r_array = $self->{ _array_reference}; + + # malloc() + my @members = @$r_array; + $self->{_members} = $r_array; + $self->{_num_members} = $#members; + $self->{_counter} = 0; + return defined @members ? \@members : undef; +} + + +sub get_next_value +{ + my ($self, $args) = @_; + my $i = $self->{_counter}++; + my $ra = $self->{_members}; + defined $$ra[ $i ] ? $$ra[ $i ] : undef; +} + + +sub getpos +{ + my ($self) = @_; + return $self->{_counter}; +} + + +sub setpos +{ + my ($self, $pos) = @_; + $self->{_counter} = $pos; +} + + +sub eof +{ + my ($self) = @_; + $self->{_counter} > $self->{_num_members} ? 1 : 0; +} + + +sub close +{ + my ($self) = @_; +} + + ##### ##### This is just a dummy yet now. ##### |
