ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.pm
(Generate patch)

Comparing CBOR-XS/XS.pm (file contents):
Revision 1.79 by root, Fri Dec 11 06:03:40 2020 UTC vs.
Revision 1.81 by root, Fri Dec 11 06:10:26 2020 UTC

704=back 704=back
705 705
706=head2 TYPE CASTS 706=head2 TYPE CASTS
707 707
708B<EXPERIMENTAL>: As an experimental extension, C<CBOR::XS> allows you to 708B<EXPERIMENTAL>: As an experimental extension, C<CBOR::XS> allows you to
709force specific cbor types to be used when encoding. That allows you to 709force specific CBOR types to be used when encoding. That allows you to
710encode types not normally accessible (e.g. half floats) as well as force 710encode types not normally accessible (e.g. half floats) as well as force
711string types even when C<text_strings> is in effect. 711string types even when C<text_strings> is in effect.
712 712
713Type forcing is done by calling a special "cast" function which keeps a 713Type forcing is done by calling a special "cast" function which keeps a
714copy of the value and returns a new value that can be handed over to any 714copy of the value and returns a new value that can be handed over to any
756 756
757Forces double-float (IEEE 754 binary64) encoding of the given value. 757Forces double-float (IEEE 754 binary64) encoding of the given value.
758 758
759=item CBOR::XS::as_cbor $cbor_text 759=item CBOR::XS::as_cbor $cbor_text
760 760
761Not a type cast per-se, this type cast forces the argument to eb encoded 761Not a type cast per-se, this type cast forces the argument to be encoded
762as-is. This can be used to embed pre-encoded CBOR data. 762as-is. This can be used to embed pre-encoded CBOR data.
763 763
764Note that no checking on the validity of the C<$cbor_text> is done - it's 764Note that no checking on the validity of the C<$cbor_text> is done - it's
765the callers responsibility to correctly encode values. 765the callers responsibility to correctly encode values.
766 766
767=item CBOR::XS::as_map [key => value...] 767=item CBOR::XS::as_map [key => value...]
768 768
769Treat the array reference as key value pairs and output a CBOR map. This 769Treat the array reference as key value pairs and output a CBOR map. This
770allows you to generate CBOR maps with arbitrary key types (or, if you 770allows you to generate CBOR maps with arbitrary key types (or, if you
771don't care about semantics, duplicate keys or prairs in a custom order), 771don't care about semantics, duplicate keys or pairs in a custom order),
772which is otherwise hard to do with Perl. 772which is otherwise hard to do with Perl.
773 773
774The single argument must be an array reference with an even number of 774The single argument must be an array reference with an even number of
775elements. 775elements.
776
777Note that only the reference to the array is copied, the array itself is
778not. Modifications done to the array before calling an encoding function
779will be reflected in the encoded output.
776 780
777Example: encode a CBOR map with a string and an integer as keys. 781Example: encode a CBOR map with a string and an integer as keys.
778 782
779 encode_cbor CBOR::XS::as_map [string => "value", 5 => "value"] 783 encode_cbor CBOR::XS::as_map [string => "value", 5 => "value"]
780 784

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines