CBOR-XS
view release on metacpan or search on metacpan
$cbor = $cbor->allow_weak_cycles ([$enable])
$enabled = $cbor->get_allow_weak_cycles
This works like "allow_cycles" in that it allows the resulting data
structures to contain cycles, but unlike "allow_cycles", those
cyclic rreferences will be weak. That means that code that
recurrsively walks the data structure must be prepared with cycles,
but at least not special precautions must be implemented to free
these data structures.
Only those references leading to actual cycles will be weakened -
other references, e.g. when the same hash or arrray is referenced
multiple times in an arrray, will be normal references.
This option does not affect "encode" in any way - shared values and
references will always be encoded properly if present.
$cbor = $cbor->forbid_objects ([$enable])
$enabled = $cbor->get_forbid_objects
Disables the use of the object serialiser protocol.
=item $cbor = $cbor->allow_weak_cycles ([$enable])
=item $enabled = $cbor->get_allow_weak_cycles
This works like C<allow_cycles> in that it allows the resulting data
structures to contain cycles, but unlike C<allow_cycles>, those cyclic
rreferences will be weak. That means that code that recurrsively walks
the data structure must be prepared with cycles, but at least not special
precautions must be implemented to free these data structures.
Only those references leading to actual cycles will be weakened - other
references, e.g. when the same hash or arrray is referenced multiple times
in an arrray, will be normal references.
This option does not affect C<encode> in any way - shared values and
references will always be encoded properly if present.
=item $cbor = $cbor->forbid_objects ([$enable])
=item $enabled = $cbor->get_forbid_objects
av_push (dec->shareable, (SV *)av);
idx = AvFILLp (dec->shareable);
sv = decode_sv (dec);
// the AV now contains \undef for all unresolved references,
// so we fix them up here.
for (i = 0; i <= AvFILLp (av); ++i)
SvRV_set (AvARRAY (av)[i], SvREFCNT_inc_NN (SvRV (sv)));
// weaken all recursive references
if (dec->cbor.flags & F_ALLOW_WEAK_CYCLES)
for (i = 0; i <= AvFILLp (av); ++i)
sv_rvweaken (AvARRAY (av)[i]);
// now replace the AV by a reference to the completed value
SvREFCNT_dec_NN ((SV *)av);
AvARRAY (dec->shareable)[idx] = SvREFCNT_inc_NN (sv);
}
else
{
av_push (dec->shareable, &PL_sv_undef);
int idx = AvFILLp (dec->shareable);
sv = decode_sv (dec);
( run in 0.401 second using v1.01-cache-2.11-cpan-65fba6d93b7 )