1 |
=head1 REGISTRATION INFORMATION |
2 |
|
3 |
Tag 22098 (indirection) |
4 |
Data Item multiple |
5 |
Semantics hint that indicates an additional level of indirection |
6 |
Reference http://cbor.schmorp.de/indirection |
7 |
Contact Marc A. Lehmann <cbor@schmorp.de> |
8 |
|
9 |
=head1 SUMMARY |
10 |
|
11 |
This tag indicates an additional level of indirection when |
12 |
decoding a value. |
13 |
|
14 |
=head1 BACKGROUND |
15 |
|
16 |
Data structures in some languages or data models sometimes employ |
17 |
references, pointers or similar forms of indirection to represent |
18 |
relationships between values. For example, in Perl, CBOR arrays are |
19 |
usually represented as references to perl arrays, rather than arrays |
20 |
themselves, while simple scalar values are represented as these values |
21 |
themselves. However, CBOR leaves explicit references unencodable - while |
22 |
arrays and maps might implicitly result in references, references to |
23 |
simple values, or references to references are not representable. |
24 |
|
25 |
For example, in Perl: |
26 |
|
27 |
{ 1, 2, 3, 4 } # reference to a hash, becomes CBOR map |
28 |
[ 1, 2, 3, 4 } # reference to an array, becomes CBOR array |
29 |
\5 # reference to the scalar value 5, needs extension |
30 |
\[] # reference to a reference to an array, needs extension |
31 |
|
32 |
This tag allows to encode such references - prefixing a value with this |
33 |
tag indicates a hint to the decoder that the original value was actually |
34 |
a reference. Decoders can chose to heed the hint (if their data model has |
35 |
a convenient representation), or simply ignore it and decode the value |
36 |
as-is. |
37 |
|
38 |
For example, CBOR encoders for Perl would not use the indirection tag for |
39 |
hash and array references, as the only way to reference these values in a |
40 |
data structure is already by reference. However, references to strings, |
41 |
numbers, other references or other complex objects would be encoded by |
42 |
tagging the referenced value with the indirection tag. |
43 |
|
44 |
Indirection tags can be nested - each additional level of nesting would |
45 |
indicate an additional indirection. |
46 |
|
47 |
=head1 EXAMPLES |
48 |
|
49 |
<TBD> |
50 |
|