File Coverage

blib/lib/CBOR/PP.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package CBOR::PP;
2              
3 5     5   242083 use strict;
  5         36  
  5         125  
4 5     5   21 use warnings;
  5         8  
  5         202  
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
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 and
33             L 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 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 is a B faster, XS-based encoder/decoder.
61              
62             L 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 (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             our $VERSION = '0.03';
80              
81 5     5   1794 use CBOR::PP::Encode ();
  5         12  
  5         91  
82 5     5   1809 use CBOR::PP::Decode ();
  5         12  
  5         220  
83              
84             *encode = *CBOR::PP::Encode::encode;
85              
86             *decode = *CBOR::PP::Decode::decode;
87              
88             *tag = *CBOR::PP::Encode::tag;
89              
90             1;