… | |
… | |
64 | |
64 | |
65 | package CBOR::XS; |
65 | package CBOR::XS; |
66 | |
66 | |
67 | use common::sense; |
67 | use common::sense; |
68 | |
68 | |
69 | our $VERSION = 1.84; |
69 | our $VERSION = 1.86; |
70 | our @ISA = qw(Exporter); |
70 | our @ISA = qw(Exporter); |
71 | |
71 | |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
73 | |
73 | |
74 | use Exporter; |
74 | use Exporter; |
… | |
… | |
216 | communication partner supports the value sharing extensions to CBOR |
216 | communication partner supports the value sharing extensions to CBOR |
217 | (L<http://cbor.schmorp.de/value-sharing>), as without decoder support, the |
217 | (L<http://cbor.schmorp.de/value-sharing>), as without decoder support, the |
218 | resulting data structure might be unusable. |
218 | resulting data structure might be unusable. |
219 | |
219 | |
220 | Detecting shared values incurs a runtime overhead when values are encoded |
220 | Detecting shared values incurs a runtime overhead when values are encoded |
221 | that have a reference counter large than one, and might unnecessarily |
221 | that have a reference counter larger than one, and might unnecessarily |
222 | increase the encoded size, as potentially shared values are encoded as |
222 | increase the encoded size, as potentially shared values are encoded as |
223 | shareable whether or not they are actually shared. |
223 | shareable whether or not they are actually shared. |
224 | |
224 | |
225 | At the moment, only targets of references can be shared (e.g. scalars, |
225 | At the moment, only targets of references can be shared (e.g. scalars, |
226 | arrays or hashes pointed to by a reference). Weirder constructs, such as |
226 | arrays or hashes pointed to by a reference). Weirder constructs, such as |
… | |
… | |
473 | Perl data structure in memory at one time, it does allow you to parse a |
473 | Perl data structure in memory at one time, it does allow you to parse a |
474 | CBOR stream incrementally, using a similar to using "decode_prefix" to see |
474 | CBOR stream incrementally, using a similar to using "decode_prefix" to see |
475 | if a full CBOR object is available, but is much more efficient. |
475 | if a full CBOR object is available, but is much more efficient. |
476 | |
476 | |
477 | It basically works by parsing as much of a CBOR string as possible - if |
477 | It basically works by parsing as much of a CBOR string as possible - if |
478 | the CBOR data is not complete yet, the pasrer will remember where it was, |
478 | the CBOR data is not complete yet, the parser will remember where it was, |
479 | to be able to restart when more data has been accumulated. Once enough |
479 | to be able to restart when more data has been accumulated. Once enough |
480 | data is available to either decode a complete CBOR value or raise an |
480 | data is available to either decode a complete CBOR value or raise an |
481 | error, a real decode will be attempted. |
481 | error, a real decode will be attempted. |
482 | |
482 | |
483 | A typical use case would be a network protocol that consists of sending |
483 | A typical use case would be a network protocol that consists of sending |
… | |
… | |
635 | create such objects. |
635 | create such objects. |
636 | |
636 | |
637 | =item Types::Serialiser::true, Types::Serialiser::false, Types::Serialiser::error |
637 | =item Types::Serialiser::true, Types::Serialiser::false, Types::Serialiser::error |
638 | |
638 | |
639 | These special values become CBOR true, CBOR false and CBOR undefined |
639 | These special values become CBOR true, CBOR false and CBOR undefined |
640 | values, respectively. You can also use C<\1>, C<\0> and C<\undef> directly |
640 | values, respectively. |
641 | if you want. |
|
|
642 | |
641 | |
643 | =item other blessed objects |
642 | =item other blessed objects |
644 | |
643 | |
645 | Other blessed objects are serialised via C<TO_CBOR> or C<FREEZE>. See |
644 | Other blessed objects are serialised via C<TO_CBOR> or C<FREEZE>. See |
646 | L<TAG HANDLING AND EXTENSIONS> for specific classes handled by this |
645 | L<TAG HANDLING AND EXTENSIONS> for specific classes handled by this |