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

Comparing CBOR-XS/README (file contents):
Revision 1.20 by root, Tue Dec 1 01:50:01 2020 UTC vs.
Revision 1.21 by root, Tue Dec 8 08:29:44 2020 UTC

637 Forces the value to be encoded as (UTF-8) text values. 637 Forces the value to be encoded as (UTF-8) text values.
638 638
639 CBOR::XS::as_bytes $value 639 CBOR::XS::as_bytes $value
640 Forces the value to be encoded as a (binary) string value. 640 Forces the value to be encoded as a (binary) string value.
641 641
642 Example: encode a perl string as binary even though "text_strings"
643 is in effect.
644
645 CBOR::XS->new->text_strings->encode ([4, "text", CBOR::XS::bytes "bytevalue"]);
646
642 CBOR::XS::as_bool $value 647 CBOR::XS::as_bool $value
643 Converts a Perl boolean (which can be any kind of scalar) into a 648 Converts a Perl boolean (which can be any kind of scalar) into a
644 CBOR boolean. Strictly the same, but shorter to write, than: 649 CBOR boolean. Strictly the same, but shorter to write, than:
645 650
646 $value ? Types::Serialiser::true : Types::Serialiser::false 651 $value ? Types::Serialiser::true : Types::Serialiser::false
652 Forces single-float (IEEE 754 binary32) encoding of the given value. 657 Forces single-float (IEEE 754 binary32) encoding of the given value.
653 658
654 CBOR::XS::as_float64 $value 659 CBOR::XS::as_float64 $value
655 Forces double-float (IEEE 754 binary64) encoding of the given value. 660 Forces double-float (IEEE 754 binary64) encoding of the given value.
656 661
657 =item, CBOR::XS::as_cbor $cbor_text 662 CBOR::XS::as_cbor $cbor_text
658
659 Bot a type cast per-se, this type cast forces the argument to eb 663 Not a type cast per-se, this type cast forces the argument to eb
660 encoded as-is. This can be used to embed pre-encoded CBOR data. 664 encoded as-is. This can be used to embed pre-encoded CBOR data.
661 665
662 Note that no checking on the validity of the $cbor_text is done - 666 Note that no checking on the validity of the $cbor_text is done -
663 it's the callers responsibility to correctly encode values. 667 it's the callers responsibility to correctly encode values.
664 668
665 Example: encode a perl string as binary even though "text_strings" is in 669 CBOR::XS::as_map [key => value...]
666 effect. 670 Treat the array reference as key value pairs and output a CBOR map.
671 This allows you to generate CBOR maps with arbitrary key types (or,
672 if you don't care about semantics, duplicate keys or prairs in a
673 custom order), which is otherwise hard to do with Perl.
667 674
668 CBOR::XS->new->text_strings->encode ([4, "text", CBOR::XS::bytes "bytevalue"]); 675 The single argument must be an array reference with an even number
676 of elements.
677
678 Example: encode a CBOR map with a string and an integer as keys.
679
680 encode_cbor CBOR::XS::as_map [string => "value", 5 => "value"]
669 681
670 OBJECT SERIALISATION 682 OBJECT SERIALISATION
671 This module implements both a CBOR-specific and the generic 683 This module implements both a CBOR-specific and the generic
672 Types::Serialier object serialisation protocol. The following 684 Types::Serialier object serialisation protocol. The following
673 subsections explain both methods. 685 subsections explain both methods.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines