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.11 by root, Tue Oct 29 00:20:26 2013 UTC vs.
Revision 1.12 by root, Tue Oct 29 15:13:50 2013 UTC

453This string is available as C<$CBOR::XS::MAGIC>. This module does not 453This string is available as C<$CBOR::XS::MAGIC>. This module does not
454prepend this string tot he CBOR data it generates, but it will ignroe it 454prepend this string tot he CBOR data it generates, but it will ignroe it
455if present, so users can prepend this string as a "file type" indicator as 455if present, so users can prepend this string as a "file type" indicator as
456required. 456required.
457 457
458
459=head1 THE CBOR::XS::Tagged CLASS
460
461CBOR has the concept of tagged values - any CBOR value can be tagged with
462a numeric 64 bit number, which are centrally administered.
463
464C<CBOR::XS> handles a few tags internally when en- or decoding. You can
465also create tags yourself by encoding C<CBOR::XS::Tagged> objects, and the
466decoder will create C<CBOR::XS::Tagged> objects itself when it hits an
467unknown tag.
468
469These objects are simply blessed array references - the first member of
470the array being the numerical tag, the second being the value.
471
472You can interact with C<CBOR::XS::Tagged> objects in the following ways:
473
474=over 4
475
476=item $tagged = CBOR::XS::tag $tag, $value
477
478This function(!) creates a new C<CBOR::XS::Tagged> object using the given
479C<$tag> (0..2**64-1) to tag the given C<$value> (which can be any Perl
480value that can be encoded in CBOR, including serialisable Perl objects and
481C<CBOR::XS::Tagged> objects).
482
483=item $tagged->[0]
484
485=item $tagged->[0] = $new_tag
486
487=item $tag = $tagged->tag
488
489=item $new_tag = $tagged->tag ($new_tag)
490
491Access/mutate the tag.
492
493=item $tagged->[1]
494
495=item $tagged->[1] = $new_value
496
497=item $value = $tagged->value
498
499=item $new_value = $tagged->value ($new_value)
500
501Access/mutate the tagged value.
502
503=back
504
505=cut
506
507sub tag($$) {
508 bless [@_], CBOR::XS::Tagged::;
509}
510
511sub CBOR::XS::Tagged::tag {
512 $_[0][0] = $_[1] if $#_;
513 $_[0][0]
514}
515
516sub CBOR::XS::Tagged::value {
517 $_[0][1] = $_[1] if $#_;
518 $_[0][1]
519}
458 520
459=head1 CBOR and JSON 521=head1 CBOR and JSON
460 522
461CBOR is supposed to implement a superset of the JSON data model, and is, 523CBOR is supposed to implement a superset of the JSON data model, and is,
462with some coercion, able to represent all JSON texts (something that other 524with some coercion, able to represent all JSON texts (something that other

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines