… | |
… | |
32 | |
32 | |
33 | package CBOR::XS; |
33 | package CBOR::XS; |
34 | |
34 | |
35 | use common::sense; |
35 | use common::sense; |
36 | |
36 | |
37 | our $VERSION = 0.01; |
37 | our $VERSION = 0.02; |
38 | our @ISA = qw(Exporter); |
38 | our @ISA = qw(Exporter); |
39 | |
39 | |
40 | our @EXPORT = qw(encode_cbor decode_cbor); |
40 | our @EXPORT = qw(encode_cbor decode_cbor); |
41 | |
41 | |
42 | use Exporter; |
42 | use Exporter; |
43 | use XSLoader; |
43 | use XSLoader; |
|
|
44 | |
|
|
45 | our $MAGIC = "\xd9\xd9\xf7"; |
44 | |
46 | |
45 | =head1 FUNCTIONAL INTERFACE |
47 | =head1 FUNCTIONAL INTERFACE |
46 | |
48 | |
47 | The following convenience methods are provided by this module. They are |
49 | The following convenience methods are provided by this module. They are |
48 | exported by default: |
50 | exported by default: |
… | |
… | |
168 | These CBOR values become C<CBOR::XS::true> and C<CBOR::XS::false>, |
170 | These CBOR values become C<CBOR::XS::true> and C<CBOR::XS::false>, |
169 | respectively. They are overloaded to act almost exactly like the numbers |
171 | respectively. They are overloaded to act almost exactly like the numbers |
170 | C<1> and C<0>. You can check whether a scalar is a CBOR boolean by using |
172 | C<1> and C<0>. You can check whether a scalar is a CBOR boolean by using |
171 | the C<CBOR::XS::is_bool> function. |
173 | the C<CBOR::XS::is_bool> function. |
172 | |
174 | |
173 | =item null |
175 | =item Null, Undefined |
174 | |
176 | |
175 | A CBOR Null value becomes C<undef> in Perl. |
177 | CBOR Null and Undefined values becomes C<undef> in Perl (in the future, |
|
|
178 | Undefined may raise an exception). |
176 | |
179 | |
177 | =back |
180 | =back |
178 | |
181 | |
179 | |
182 | |
180 | =head2 PERL -> CBOR |
183 | =head2 PERL -> CBOR |
… | |
… | |
258 | extensions to the floating point numbers of your platform, such as |
261 | extensions to the floating point numbers of your platform, such as |
259 | infinities or NaN's - these cannot be represented in CBOR, and it is an |
262 | infinities or NaN's - these cannot be represented in CBOR, and it is an |
260 | error to pass those in. |
263 | error to pass those in. |
261 | |
264 | |
262 | =back |
265 | =back |
|
|
266 | |
|
|
267 | |
|
|
268 | =head2 MAGIC HEADER |
|
|
269 | |
|
|
270 | There is no way to distinguish CBOR from other formats |
|
|
271 | programmatically. To make it easier to distinguish CBOR from other |
|
|
272 | formats, the CBOR specification has a special "magic string" that can be |
|
|
273 | prepended to any CBOR string without changing it's meaning. |
|
|
274 | |
|
|
275 | This string is available as C<$CBOR::XS::MAGIC>. This module does not |
|
|
276 | prepend this string tot he CBOR data it generates, but it will ignroe it |
|
|
277 | if present, so users can prepend this string as a "file type" indicator as |
|
|
278 | required. |
263 | |
279 | |
264 | |
280 | |
265 | =head2 CBOR and JSON |
281 | =head2 CBOR and JSON |
266 | |
282 | |
267 | TODO |
283 | TODO |