| 1 |
root |
1.1 |
=head1 REGISTRATION INFORMATION |
| 2 |
|
|
|
| 3 |
root |
1.2 |
Tag 26 |
| 4 |
root |
1.1 |
Data Item array [classname, constructargs...] |
| 5 |
|
|
Semantics Serialised Perl object with classname and constructor arguments |
| 6 |
|
|
Reference http://cbor.schmorp.de/perl-object |
| 7 |
|
|
Contact Marc A. Lehmann <cbor@schmorp.de> |
| 8 |
|
|
|
| 9 |
|
|
=head1 DESCRIPTION |
| 10 |
|
|
|
| 11 |
|
|
The perl-object tag in CBOR can be used to serialise Perl 5 objects into |
| 12 |
|
|
CBOR. |
| 13 |
|
|
|
| 14 |
|
|
The tagged value must be a CBOR array with at least one element. The first |
| 15 |
root |
1.2 |
element specifies a classname to use in Perl (it can, but does not need to |
| 16 |
|
|
be a string - the stringified form will be used as classname). |
| 17 |
root |
1.1 |
|
| 18 |
|
|
The encoder and decoder should serialise/deserialise the object using the |
| 19 |
|
|
Types::Serialiser object serialisation protocol. For this, the object's |
| 20 |
|
|
class must have FREEZE and THAW methods that are called like this: |
| 21 |
|
|
|
| 22 |
|
|
@constructargs = $object->FREEZE ("CBOR"); |
| 23 |
|
|
$object = $class->THAW ("CBOR", @constructargs); |
| 24 |
|
|
|
| 25 |
|
|
If the class or method is currently not available, the decoder may try to |
| 26 |
|
|
load a Perl module of the same name and retry the method call. |
| 27 |
|
|
|
| 28 |
|
|
=head1 EXAMPLES |
| 29 |
|
|
|
| 30 |
|
|
Example of a hypothetical My::DateTime representation using a unix |
| 31 |
|
|
timestamp: |
| 32 |
|
|
|
| 33 |
root |
1.2 |
26(["My::DateTime", 12345678]) |
| 34 |
|
|
|
| 35 |
|
|
d8 1a # tag(26) |
| 36 |
|
|
82 # array(2) |
| 37 |
|
|
6c # text(12) |
| 38 |
|
|
4d793a3a4461746554696d65 # "My::DateTime" |
| 39 |
|
|
1a 00bc614e # unsigned(12345678) |
| 40 |
root |
1.1 |
|
| 41 |
|
|
Example of the corresponding FREEZE method: |
| 42 |
|
|
|
| 43 |
|
|
sub My::DateTime::FREEZE { |
| 44 |
|
|
my ($self, $model) = @_; |
| 45 |
|
|
|
| 46 |
|
|
$self->as_seconds |
| 47 |
|
|
} |
| 48 |
|
|
|
| 49 |
|
|
Example of the corresponding THAW method: |
| 50 |
|
|
|
| 51 |
|
|
sub My::DateTime::THAW { |
| 52 |
|
|
my ($class, $model, $seconds) = @_; |
| 53 |
|
|
|
| 54 |
|
|
$class->new_from_seconds ($seconds) |
| 55 |
|
|
} |
| 56 |
|
|
|
| 57 |
root |
1.3 |
=head1 IMPLEMENTATIONS |
| 58 |
|
|
|
| 59 |
|
|
This section lists known implementations of this extension (L<drop me a |
| 60 |
|
|
mail|mailto:cbor@schmorp.de?Subject=CBOR-perl-object> if you want to be |
| 61 |
|
|
listed here). |
| 62 |
|
|
|
| 63 |
|
|
=over 4 |
| 64 |
|
|
|
| 65 |
|
|
=item * [Perl] L<CBOR::XS|http://software.schmorp.de/pkg/CBOR-XS.html> (reference implementation) |
| 66 |
|
|
|
| 67 |
|
|
=back |
| 68 |
|
|
|