.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Text::Bidi::Array 3pm" .TH Text::Bidi::Array 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Text::Bidi::Array \- Base class for dual life arrays .SH VERSION .IX Header "VERSION" version 2.18 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 5 \& use Text::Bidi::Array::Byte; \& my $a = new Text::Bidi::Array::Byte "abc"; \& say $a\->[1]; # says 98 \& say $$a; # says abc \& say "$a"; # also says abc .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This is an abstract base class for objects that function as ``dual\-life'' arrays: When viewed as an array reference, it functions as a usual array of numbers. When used as a scalar reference, it returns the same array as a packed string. The packing specification depends on the sub-class. These classes are used in Text::Bidi to conveniently pass arrays to the underlying fribidi library, but could be of independent interest. .SH "OVERLOADED OPERATORS" .IX Header "OVERLOADED OPERATORS" An object of this type can be dereferenced either as a scalar or as an array. In the first case, it returns the packed (string) representation of the array. In the second, it returns the unpacked array of numbers. .PP The packed representation is also returned when the object is used as a string. .SH CONSTRUCTION .IX Header "CONSTRUCTION" .Vb 1 \& $a = new Text::Bidi::Array:: $data .Ve .PP Create a new array of the given \fBType\fR, and initialise it with \fR\f(CI$data\fR\fI\fR. \&\fI\fR\f(CI$data\fR\fI\fR can be either a string, which the new object then view as an array of the given type, or an array reference (more precisely, anything that can be dereferenced as an array), which is then packed according to the rules of \&\fBType\fR. If no \fI\fR\f(CI$data\fR\fI\fR is given, it defaults to 0. .SH "SEE ALSO" .IX Header "SEE ALSO" Text::Bidi::Array::Byte, Text::Bidi::Array::Long .SH "FOR IMPLEMENTORS" .IX Header "FOR IMPLEMENTORS" The rest of this documentation is for writing specific derived classes. The object is represented internally as a hashref. To implement a particular instance, the following methods should be implemented. Each of these should manipulate the field \f(CW\*(C`data\*(C'\fR, which is the string that stores the actual value. Unimplemented methods will lead to croaking. See Text::Bidi::Array::Byte and Text::Bidi::Array::Long for examples. .ie n .IP $self\->pack(@data) 4 .el .IP \f(CW$self\fR\->pack(@data) 4 .IX Item "$self->pack(@data)" Convert (pack) an array of numbers into a string according to the format of the current class (this will probably be a class method). Returns the string. .PP The following methods should behave as described in Tie::Array. .ie n .IP "$self\->STORE($index, $value)" 4 .el .IP "\f(CW$self\fR\->STORE($index, \f(CW$value\fR)" 4 .IX Item "$self->STORE($index, $value)" Store the \fR\f(CI$value\fR\fI\fR in the part of \f(CW\*(C`$self\->{\*(Aqdata\*(Aq}\*(C'\fR corresponding to \&\fI\fR\f(CI$index\fR\fI\fR. .ie n .IP $self\->FETCH($index) 4 .el .IP \f(CW$self\fR\->FETCH($index) 4 .IX Item "$self->FETCH($index)" Fetch the value at \fR\f(CI$index\fR\fI\fR from the correct part of \f(CW\*(C`$self\->{\*(Aqdata\*(Aq}\*(C'\fR. .ie n .IP $self\->STORESIZE($count) 4 .el .IP \f(CW$self\fR\->STORESIZE($count) 4 .IX Item "$self->STORESIZE($count)" Modify \f(CW\*(C`$self\->{\*(Aqdata\*(Aq}\*(C'\fR to represent an array of size \fR\f(CI$count\fR\fI\fR. .ie n .IP $self\->\fBFETCHSIZE()\fR 4 .el .IP \f(CW$self\fR\->\fBFETCHSIZE()\fR 4 .IX Item "$self->FETCHSIZE()" Return the size of the array represented by \f(CW\*(C`$self\->{\*(Aqdata\*(Aq}\*(C'\fR. .SH AUTHOR .IX Header "AUTHOR" Moshe Kamensky .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2015 by Moshe Kamensky. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.