1Text::Bidi::Array(3)  User Contributed Perl Documentation Text::Bidi::Array(3)
2
3
4

NAME

6       Text::Bidi::Array - Base class for dual life arrays
7

VERSION

9       version 2.15
10

SYNOPSIS

12           use Text::Bidi::Array::Byte;
13           my $a = new Text::Bidi::Array::Byte "abc";
14           say $a->[1]; # says 98
15           say $$a; # says abc
16           say "$a"; # also says abc
17

DESCRIPTION

19       This is an abstract base class for objects that function as
20       ``dual-life'' arrays: When viewed as an array reference, it functions
21       as a usual array of numbers. When used as a scalar reference, it
22       returns the same array as a packed string. The packing specification
23       depends on the sub-class. These classes are used in Text::Bidi to
24       conveniently pass arrays to the underlying fribidi library, but could
25       be of independent interest.
26

OVERLOADED OPERATORS

28       An object of this type can be dereferenced either as a scalar or as an
29       array.  In the first case, it returns the packed (string)
30       representation of the array. In the second, it returns the unpacked
31       array of numbers.
32
33       The packed representation is also returned when the object is used as a
34       string.
35

CONSTRUCTION

37           $a = new Text::Bidi::Array::<Type> $data
38
39       Create a new array of the given Type, and initialise it with $data.
40       $data can be either a string, which the new object then view as an
41       array of the given type, or an array reference (more precisely,
42       anything that can be dereferenced as an array), which is then packed
43       according to the rules of Type. If no $data is given, it defaults to 0.
44

SEE ALSO

46       Text::Bidi::Array::Byte, Text::Bidi::Array::Long
47

FOR IMPLEMENTORS

49       The rest of this documentation is for writing specific derived classes.
50       The object is represented internally as a hashref. To implement a
51       particular instance, the following methods should be implemented.  Each
52       of these should manipulate the field "data", which is the string that
53       stores the actual value. Unimplemented methods will lead to croaking.
54       See Text::Bidi::Array::Byte and Text::Bidi::Array::Long for examples.
55
56       $self->pack(@data)
57           Convert (pack) an array of numbers into a string according to the
58           format of the current class (this will probably be a class method).
59           Returns the string.
60
61       The following methods should behave as described in Tie::Array.
62
63       $self->STORE($index, $value)
64           Store the $value in the part of "$self->{'data'}" corresponding to
65           $index.
66
67       $self->FETCH($index)
68           Fetch the value at $index from the correct part of
69           "$self->{'data'}".
70
71       $self->STORESIZE($count)
72           Modify "$self->{'data'}" to represent an array of size $count.
73
74       $self->FETCHSIZE()
75           Return the size of the array represented by "$self->{'data'}".
76

AUTHOR

78       Moshe Kamensky <kamensky@cpan.org>
79
81       This software is copyright (c) 2015 by Moshe Kamensky.
82
83       This is free software; you can redistribute it and/or modify it under
84       the same terms as the Perl 5 programming language system itself.
85
86
87
88perl v5.34.0                      2021-07-23              Text::Bidi::Array(3)
Impressum