… | |
… | |
64 | |
64 | |
65 | package CBOR::XS; |
65 | package CBOR::XS; |
66 | |
66 | |
67 | use common::sense; |
67 | use common::sense; |
68 | |
68 | |
69 | our $VERSION = 1.86; |
69 | our $VERSION = 1.87; |
70 | our @ISA = qw(Exporter); |
70 | our @ISA = qw(Exporter); |
71 | |
71 | |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
73 | |
73 | |
74 | use Exporter; |
74 | use Exporter; |
… | |
… | |
245 | isn't prepared for this will not leak memory. |
245 | isn't prepared for this will not leak memory. |
246 | |
246 | |
247 | If C<$enable> is false (the default), then C<decode> will throw an error |
247 | If C<$enable> is false (the default), then C<decode> will throw an error |
248 | when it encounters a self-referential/cyclic data structure. |
248 | when it encounters a self-referential/cyclic data structure. |
249 | |
249 | |
250 | FUTURE DIRECTION: the motivation behind this option is to avoid I<real> |
250 | This option does not affect C<encode> in any way - shared values and |
251 | cycles - future versions of this module might chose to decode cyclic data |
251 | references will always be encoded properly if present. |
252 | structures using weak references when this option is off, instead of |
252 | |
253 | throwing an error. |
253 | =item $cbor = $cbor->allow_weak_cycles ([$enable]) |
|
|
254 | |
|
|
255 | =item $enabled = $cbor->get_allow_weak_cycles |
|
|
256 | |
|
|
257 | This works like C<allow_cycles> in that it allows the resulting data |
|
|
258 | structures to contain cycles, but unlike C<allow_cycles>, those cyclic |
|
|
259 | rreferences will be weak. That means that code that recurrsively walks |
|
|
260 | the data structure must be prepared with cycles, but at least not special |
|
|
261 | precautions must be implemented to free these data structures. |
|
|
262 | |
|
|
263 | Only those references leading to actual cycles will be weakened - other |
|
|
264 | references, e.g. when the same hash or arrray is referenced multiple times |
|
|
265 | in an arrray, will be normal references. |
254 | |
266 | |
255 | This option does not affect C<encode> in any way - shared values and |
267 | This option does not affect C<encode> in any way - shared values and |
256 | references will always be encoded properly if present. |
268 | references will always be encoded properly if present. |
257 | |
269 | |
258 | =item $cbor = $cbor->forbid_objects ([$enable]) |
270 | =item $cbor = $cbor->forbid_objects ([$enable]) |