… | |
… | |
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.82; |
69 | our $VERSION = 1.83; |
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; |
… | |
… | |
712 | |
712 | |
713 | Type forcing is done by calling a special "cast" function which keeps a |
713 | Type forcing is done by calling a special "cast" function which keeps a |
714 | copy of the value and returns a new value that can be handed over to any |
714 | copy of the value and returns a new value that can be handed over to any |
715 | CBOR encoder function. |
715 | CBOR encoder function. |
716 | |
716 | |
717 | The following casts are currently available (all of which are unary operators): |
717 | The following casts are currently available (all of which are unary |
|
|
718 | operators, that is, have a prototype of C<$>): |
718 | |
719 | |
719 | =over |
720 | =over |
720 | |
721 | |
721 | =item CBOR::XS::as_int $value |
722 | =item CBOR::XS::as_int $value |
722 | |
723 | |
… | |
… | |
792 | sub CBOR::XS::as_bool ($) { $_[0] ? $Types::Serialiser::true : $Types::Serialiser::false } |
793 | sub CBOR::XS::as_bool ($) { $_[0] ? $Types::Serialiser::true : $Types::Serialiser::false } |
793 | |
794 | |
794 | sub CBOR::XS::as_map ($) { |
795 | sub CBOR::XS::as_map ($) { |
795 | ARRAY:: eq ref $_[0] |
796 | ARRAY:: eq ref $_[0] |
796 | and $#{ $_[0] } & 1 |
797 | and $#{ $_[0] } & 1 |
797 | or do { require Carp; Carp::croak ("CBOR::XS::as_map only acepts array references with an even number of elements, found ") }; |
798 | or do { require Carp; Carp::croak ("CBOR::XS::as_map only acepts array references with an even number of elements, caught") }; |
798 | |
799 | |
799 | bless [$_[0], 7, undef], CBOR::XS::Tagged:: |
800 | bless [$_[0], 7, undef], CBOR::XS::Tagged:: |
800 | } |
801 | } |
801 | |
802 | |
802 | =head2 OBJECT SERIALISATION |
803 | =head2 OBJECT SERIALISATION |