--- CBOR-XS/XS.pm 2020/11/29 21:32:01 1.71 +++ CBOR-XS/XS.pm 2020/12/01 01:49:47 1.76 @@ -66,7 +66,7 @@ use common::sense; -our $VERSION = 1.71; +our $VERSION = 1.82; our @ISA = qw(Exporter); our @EXPORT = qw(encode_cbor decode_cbor); @@ -718,6 +718,11 @@ =over +=item CBOR::XS::as_int $value + +Forces the value to be encoded as some form of (basic, not bignum) integer +type. + =item CBOR::XS::as_text $value Forces the value to be encoded as (UTF-8) text values. @@ -726,6 +731,13 @@ Forces the value to be encoded as a (binary) string value. +=item CBOR::XS::as_bool $value + +Converts a Perl boolean (which can be any kind of scalar) into a CBOR +boolean. Strictly the same, but shorter to write, than: + + $value ? Types::Serialiser::true : Types::Serialiser::false + =item CBOR::XS::as_float16 $value Forces half-float (IEEE 754 binary16) encoding of the given value. @@ -756,11 +768,14 @@ =cut sub CBOR::XS::as_cbor ($) { bless [$_[0], 0, undef], CBOR::XS::Tagged:: } -sub CBOR::XS::as_bytes ($) { bless [$_[0], 1, undef], CBOR::XS::Tagged:: } -sub CBOR::XS::as_text ($) { bless [$_[0], 2, undef], CBOR::XS::Tagged:: } -sub CBOR::XS::as_float16 ($) { bless [$_[0], 3, undef], CBOR::XS::Tagged:: } -sub CBOR::XS::as_float32 ($) { bless [$_[0], 4, undef], CBOR::XS::Tagged:: } -sub CBOR::XS::as_float64 ($) { bless [$_[0], 5, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_int ($) { bless [$_[0], 1, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_bytes ($) { bless [$_[0], 2, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_text ($) { bless [$_[0], 3, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_float16 ($) { bless [$_[0], 4, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_float32 ($) { bless [$_[0], 5, undef], CBOR::XS::Tagged:: } +sub CBOR::XS::as_float64 ($) { bless [$_[0], 6, undef], CBOR::XS::Tagged:: } + +sub CBOR::XS::as_bool ($) { $_[0] ? $Types::Serialiser::true : $Types::Serialiser::false } =head2 OBJECT SERIALISATION