CBOR-PP
view release on metacpan or search on metacpan
lib/CBOR/PP/Encode.pm view on Meta::CPAN
package CBOR::PP::Encode;
use strict;
use warnings;
=encoding utf-8
=head1 NAME
CBOR::PP::Decode
=head1 SYNOPSIS
my $perlvar = CBOR::PP::Decode::decode($binary);
=head1 DESCRIPTION
This implements a L<CBOR|https://tools.ietf.org/html/rfc7049> encoder
in pure Perl.
=head1 MAPPING PERL TO CBOR
=over
=item * Scalars that look like unsigned integers are encoded as such.
UTF-8 strings and strings that fit 7-bit ASCII (including floats and
negatives) are encoded as text. Any other scalar is encoded as binary.
Note that there is no âright wayâ to determine whether an arbitrary
Perl (non-reference) scalar should be encoded as a string or as a number.
The above seems a reasonable enough approach.
=item * UTF8-flagged strings are encoded as text; others are encoded as
binary. This is a âbest-guessâ merely; Perlâs UTF8 flag doesnât reliably
indicate whether a given string is a text or a byte string.
=item * undef, Types::Serialiser::true(), and Types::Serialiser::false()
are encoded as null, true, and false, respectively.
=item * There is no support for streamed (i.e., indefinite-length)
objects.
=item * There is no Perl value that maps to CBORâs undefined value.
=back
=head1 TODO
=over
=item * Add canonicalization support.
=item * Optimize as may be feasible.
=back
=head1 AUTHOR
L<Gasper Software Consulting|http://gaspersoftware.com> (FELIPE)
=head1 LICENSE
This code is licensed under the same license as Perl itself.
=cut
#----------------------------------------------------------------------
use CBOR::PP::X;
use CBOR::PP::Tagged;
#----------------------------------------------------------------------
=head1 FUNCTIONS
=head2 $obj = tag( $NUMBER, $VALUE )
Returns an object that represents a value and its CBOR tag number.
For example, to encode a date/time string, you could do:
my $tagged = tag(0, '2013-03-21T20:04:00Z')
C<encode()> recognizes objects that this function returns and
turns them into tagged CBOR values.
=cut
sub tag {
return CBOR::PP::Tagged->new(@_);
}
#----------------------------------------------------------------------
=head1 METHODS
( run in 2.040 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )