… | |
… | |
118 | strings. All boolean flags described below are by default I<disabled>. |
118 | strings. All boolean flags described below are by default I<disabled>. |
119 | |
119 | |
120 | The mutators for flags all return the CBOR object again and thus calls can |
120 | The mutators for flags all return the CBOR object again and thus calls can |
121 | be chained: |
121 | be chained: |
122 | |
122 | |
123 | #TODO |
|
|
124 | my $cbor = CBOR::XS->new->encode ({a => [1,2]}); |
123 | my $cbor = CBOR::XS->new->encode ({a => [1,2]}); |
125 | |
124 | |
126 | =item $cbor = $cbor->max_depth ([$maximum_nesting_depth]) |
125 | =item $cbor = $cbor->max_depth ([$maximum_nesting_depth]) |
127 | |
126 | |
128 | =item $max_depth = $cbor->get_max_depth |
127 | =item $max_depth = $cbor->get_max_depth |
… | |
… | |
230 | exception when it encounters anything it cannot encode as CBOR. |
229 | exception when it encounters anything it cannot encode as CBOR. |
231 | |
230 | |
232 | This option does not affect C<decode> in any way - string references will |
231 | This option does not affect C<decode> in any way - string references will |
233 | always be decoded properly if present. |
232 | always be decoded properly if present. |
234 | |
233 | |
|
|
234 | =item $cbor = $cbor->filter ([$cb->($tag, $value)]) |
|
|
235 | |
|
|
236 | =item $cb_or_undef = $cbor->get_filter |
|
|
237 | |
|
|
238 | TODO |
|
|
239 | |
235 | =item $cbor_data = $cbor->encode ($perl_scalar) |
240 | =item $cbor_data = $cbor->encode ($perl_scalar) |
236 | |
241 | |
237 | Converts the given Perl data structure (a scalar value) to its CBOR |
242 | Converts the given Perl data structure (a scalar value) to its CBOR |
238 | representation. |
243 | representation. |
239 | |
244 | |
… | |
… | |
307 | C<Types:Serialiser::false> and C<Types::Serialiser::error>, |
312 | C<Types:Serialiser::false> and C<Types::Serialiser::error>, |
308 | respectively. They are overloaded to act almost exactly like the numbers |
313 | respectively. They are overloaded to act almost exactly like the numbers |
309 | C<1> and C<0> (for true and false) or to throw an exception on access (for |
314 | C<1> and C<0> (for true and false) or to throw an exception on access (for |
310 | error). See the L<Types::Serialiser> manpage for details. |
315 | error). See the L<Types::Serialiser> manpage for details. |
311 | |
316 | |
312 | =item CBOR tag 256 (perl object) |
317 | =item tagged values |
313 | |
318 | |
314 | The tag value C<256> (TODO: pending iana registration) will be used |
|
|
315 | to deserialise a Perl object serialised with C<FREEZE>. See L<OBJECT |
|
|
316 | SERIALISATION>, below, for details. |
|
|
317 | |
|
|
318 | =item CBOR tag 55799 (magic header) |
|
|
319 | |
|
|
320 | The tag 55799 is ignored (this tag implements the magic header). |
|
|
321 | |
|
|
322 | =item other CBOR tags |
|
|
323 | |
|
|
324 | Tagged items consists of a numeric tag and another CBOR value. Tags not |
319 | Tagged items consists of a numeric tag and another CBOR value. |
325 | handled internally are currently converted into a L<CBOR::XS::Tagged> |
|
|
326 | object, which is simply a blessed array reference consisting of the |
|
|
327 | numeric tag value followed by the (decoded) CBOR value. |
|
|
328 | |
320 | |
329 | In the future, support for user-supplied conversions might get added. |
321 | See L<TAG HANDLING AND EXTENSIONS> and the description of C<< ->filter >> |
|
|
322 | for details. |
330 | |
323 | |
331 | =item anything else |
324 | =item anything else |
332 | |
325 | |
333 | Anything else (e.g. unsupported simple values) will raise a decoding |
326 | Anything else (e.g. unsupported simple values) will raise a decoding |
334 | error. |
327 | error. |
… | |
… | |
377 | if you want. |
370 | if you want. |
378 | |
371 | |
379 | =item other blessed objects |
372 | =item other blessed objects |
380 | |
373 | |
381 | Other blessed objects are serialised via C<TO_CBOR> or C<FREEZE>. See |
374 | Other blessed objects are serialised via C<TO_CBOR> or C<FREEZE>. See |
382 | L<OBJECT SERIALISATION>, below, for details. |
375 | L<TAG HANDLING AND EXTENSIONS> for specific classes handled by this |
|
|
376 | module, and L<OBJECT SERIALISATION> for generic object serialisation. |
383 | |
377 | |
384 | =item simple scalars |
378 | =item simple scalars |
385 | |
379 | |
386 | TODO |
|
|
387 | Simple Perl scalars (any scalar that is not a reference) are the most |
380 | Simple Perl scalars (any scalar that is not a reference) are the most |
388 | difficult objects to encode: CBOR::XS will encode undefined scalars as |
381 | difficult objects to encode: CBOR::XS will encode undefined scalars as |
389 | CBOR null values, scalars that have last been used in a string context |
382 | CBOR null values, scalars that have last been used in a string context |
390 | before encoding as CBOR strings, and anything else as number value: |
383 | before encoding as CBOR strings, and anything else as number value: |
391 | |
384 | |
… | |
… | |
633 | and extensions. If a tag is not mentioned here and no additional filters |
626 | and extensions. If a tag is not mentioned here and no additional filters |
634 | are provided for it, then the default handling applies (creating a |
627 | are provided for it, then the default handling applies (creating a |
635 | CBOR::XS::Tagged object on decoding, and only encoding the tag when |
628 | CBOR::XS::Tagged object on decoding, and only encoding the tag when |
636 | explicitly requested). |
629 | explicitly requested). |
637 | |
630 | |
|
|
631 | Tags not handled specifically are currently converted into a |
|
|
632 | L<CBOR::XS::Tagged> object, which is simply a blessed array reference |
|
|
633 | consisting of the numeric tag value followed by the (decoded) CBOR value. |
|
|
634 | |
638 | Future versions of this module reserve the right to special case |
635 | Future versions of this module reserve the right to special case |
639 | additional tags (such as base64url). |
636 | additional tags (such as base64url). |
640 | |
637 | |
641 | =head2 ENFORCED TAGS |
638 | =head2 ENFORCED TAGS |
642 | |
639 | |
… | |
… | |
645 | |
642 | |
646 | =over 4 |
643 | =over 4 |
647 | |
644 | |
648 | =item <unassigned> (perl-object, L<http://cbor.schmorp.de/perl-object>) |
645 | =item <unassigned> (perl-object, L<http://cbor.schmorp.de/perl-object>) |
649 | |
646 | |
650 | These tags are automatically created for serialisable objects using the |
647 | These tags are automatically created (and decoded) for serialisable |
651 | C<FREEZE/THAW> methods (the L<Types::Serialier> object serialisation |
648 | objects using the C<FREEZE/THAW> methods (the L<Types::Serialier> object |
652 | protocol). |
649 | serialisation protocol). See L<OBJECT SERIALISATION> for details. |
653 | |
650 | |
654 | =item <unassigned>, <unassigned> (sharable, sharedref, L <http://cbor.schmorp.de/value-sharing>) |
651 | =item <unassigned>, <unassigned> (sharable, sharedref, L <http://cbor.schmorp.de/value-sharing>) |
655 | |
652 | |
656 | These tags are automatically decoded when encountered, resulting in |
653 | These tags are automatically decoded when encountered, resulting in |
657 | shared values in the decoded object. They are only encoded, however, when |
654 | shared values in the decoded object. They are only encoded, however, when |