| 1 | package CBOR::PP; | ||
| 2 | |||
| 3 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | =encoding utf-8 | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | CBOR::PP - CBOR in pure Perl | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | my $value = CBOR::PP::decode( $cbor ); | ||
| 15 | |||
| 16 | my $tagged = CBOR::PP::tag( 123, 'value' ); | ||
| 17 | |||
| 18 | my $cbor = CBOR::PP::encode( [ 'some', { data => $tagged } ] ); | ||
| 19 | |||
| 20 | # canonical encoding | ||
| 21 | $cbor = CBOR::PP::encode( | ||
| 22 | { aa => 'last', a => 'first', z => 'middle' }, | ||
| 23 | { canonical => 1 }, | ||
| 24 | ); | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | This library implements a L<CBOR|https://tools.ietf.org/html/rfc7049> | ||
| 29 | encoder and decoder in pure Perl. | ||
| 30 | |||
| 31 | This module itself is a syntactic convenience. For details about what | ||
| 32 | CBOR::PP can and can’t do, see the underlying L<CBOR::PP::Encode> and | ||
| 33 | L<CBOR::PP::Decode> modules. | ||
| 34 | |||
| 35 | =head1 STATUS | ||
| 36 | |||
| 37 | This distribution is an experimental effort. | ||
| 38 | |||
| 39 | That having been said, CBOR is a simple enough encoding that I | ||
| 40 | suspect—I hope!—that bugs here will be few and far between. | ||
| 41 | |||
| 42 | Note that, because L<CBOR::Free> is so much faster, | ||
| 43 | there probably won’t be much further effort put into this pure-Perl code. | ||
| 44 | |||
| 45 | Note that this distribution’s interface can still change. If you decide | ||
| 46 | to use CBOR::PP in your project, please always check the changelog before | ||
| 47 | upgrading. | ||
| 48 | |||
| 49 | =head1 FRACTIONAL (FLOATING-POINT) NUMBERS | ||
| 50 | |||
| 51 | Floating-point numbers are encoded in CBOR as IEEE 754 half-, single-, | ||
| 52 | or double-precision. If your Perl is compiled to use “long double” | ||
| 53 | floating-point numbers, you may see rounding errors when converting | ||
| 54 | to/from CBOR. If that’s a problem for you, append an empty string to | ||
| 55 | your floating-point numbers, which will cause CBOR::PP to encode | ||
| 56 | them as strings. | ||
| 57 | |||
| 58 | =head1 SEE ALSO | ||
| 59 | |||
| 60 | L<CBOR::Free> is a B<much> faster, XS-based encoder/decoder. | ||
| 61 | |||
| 62 | L<CBOR::XS> isn’t quite as fast as CBOR::Free but is older and | ||
| 63 | (as of this writing) more widely used. It’s also technically unsupported | ||
| 64 | on current Perl versions, though, and its GPL license makes it | ||
| 65 | useful only for open-source projects. | ||
| 66 | |||
| 67 | =head1 AUTHOR | ||
| 68 | |||
| 69 | L<Gasper Software Consulting|http://gaspersoftware.com> (FELIPE) | ||
| 70 | |||
| 71 | =head1 LICENSE | ||
| 72 | |||
| 73 | This code is licensed under the same license as Perl itself. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | #---------------------------------------------------------------------- | ||
| 78 | |||
| 79 | 6 | our $VERSION = '0.04'; | |
| 80 | |||
| 81 | 6 | ▶ | use CBOR::PP::Encode (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 82 | 6 | ▶ | use CBOR::PP::Decode (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 83 | |||
| 84 | 6 | *encode = *CBOR::PP::Encode::encode; | |
| 85 | |||
| 86 | 6 | *decode = *CBOR::PP::Decode::decode; | |
| 87 | |||
| 88 | 6 | *tag = *CBOR::PP::Encode::tag; | |
| 89 | |||
| 90 | 6 | 1; | |