| 1 | package Sereal; | ||||||||||||||||||||
| 2 | 5 | ▶ | use 5.014; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 5 | our $VERSION = '7.002'; | |||||||||||||||||||
| 6 | 5 | our $XS_VERSION = $VERSION; $VERSION = eval $VERSION; | |||||||||||||||||||
| 7 | 5 | ▶ | use Sereal::Encoder 7.002 qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | encode_sereal | ||||||||||||||||||||
| 9 | sereal_encode_with_object | ||||||||||||||||||||
| 10 | SRL_UNCOMPRESSED | ||||||||||||||||||||
| 11 | SRL_SNAPPY | ||||||||||||||||||||
| 12 | SRL_ZLIB | ||||||||||||||||||||
| 13 | SRL_ZSTD | ||||||||||||||||||||
| 14 | 5 | ); | |||||||||||||||||||
| 15 | 5 | ▶ | use Sereal::Decoder 7.002 qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | get_sereal_checksum | ||||||||||||||||||||
| 17 | validate_sereal_checksum | ||||||||||||||||||||
| 18 | decode_sereal | ||||||||||||||||||||
| 19 | looks_like_sereal | ||||||||||||||||||||
| 20 | decode_sereal_with_header_data | ||||||||||||||||||||
| 21 | scalar_looks_like_sereal | ||||||||||||||||||||
| 22 | sereal_decode_with_object | ||||||||||||||||||||
| 23 | sereal_decode_with_header_with_object | ||||||||||||||||||||
| 24 | sereal_decode_only_header_with_object | ||||||||||||||||||||
| 25 | sereal_decode_only_header_with_offset_with_object | ||||||||||||||||||||
| 26 | sereal_decode_with_header_and_offset_with_object | ||||||||||||||||||||
| 27 | sereal_decode_with_offset_with_object | ||||||||||||||||||||
| 28 | 5 | ); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 5 | ▶ | use Exporter 'import'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 5 | our @EXPORT_OK = qw( | |||||||||||||||||||
| 32 | get_sereal_checksum | ||||||||||||||||||||
| 33 | validate_sereal_checksum | ||||||||||||||||||||
| 34 | get_sereal_decoder | ||||||||||||||||||||
| 35 | get_sereal_encoder | ||||||||||||||||||||
| 36 | clear_sereal_object_cache | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | encode_sereal | ||||||||||||||||||||
| 39 | decode_sereal | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | read_sereal | ||||||||||||||||||||
| 42 | read_sereal_file | ||||||||||||||||||||
| 43 | write_sereal | ||||||||||||||||||||
| 44 | write_sereal_file | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | looks_like_sereal | ||||||||||||||||||||
| 47 | scalar_looks_like_sereal | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | sereal_encode_with_object | ||||||||||||||||||||
| 50 | sereal_decode_with_object | ||||||||||||||||||||
| 51 | decode_sereal_with_header_data | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | sereal_decode_with_header_with_object | ||||||||||||||||||||
| 54 | sereal_decode_only_header_with_object | ||||||||||||||||||||
| 55 | sereal_decode_only_header_with_offset_with_object | ||||||||||||||||||||
| 56 | sereal_decode_with_header_and_offset_with_object | ||||||||||||||||||||
| 57 | sereal_decode_with_offset_with_object | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | SRL_UNCOMPRESSED | ||||||||||||||||||||
| 60 | SRL_SNAPPY | ||||||||||||||||||||
| 61 | SRL_ZLIB | ||||||||||||||||||||
| 62 | SRL_ZSTD | ||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||
| 64 | 5 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # export by default if run from command line | ||||||||||||||||||||
| 67 | 5 | ▶ | our @EXPORT = ( ( caller() )[1] eq '-e' ? @EXPORT_OK : () ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 5 | our %ENCODERS; | |||||||||||||||||||
| 70 | 5 | our %DECODERS; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 14 | ▶ | sub _key { | ||||||||||||||||||
|
Subroutine
_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | 14 | join "\t", map { $_ => $_[0]->{$_} } sort keys %{ $_[0] }; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 1 | ▶ | sub clear_sereal_object_cache { | ||||||||||||||||||
|
Subroutine
clear_sereal_object_cache: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 77 | 1 | my $count = keys(%DECODERS) + keys(%ENCODERS); | |||||||||||||||||||
| 78 | 1 | %ENCODERS = (); | |||||||||||||||||||
| 79 | 1 | %DECODERS = (); | |||||||||||||||||||
| 80 | 1 | return $count; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 5 | ▶ | sub get_sereal_encoder { | ||||||||||||||||||
|
Subroutine
get_sereal_encoder: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 84 | 5 | my ($opts) = @_; | |||||||||||||||||||
| 85 | 5 | ▶ | return $ENCODERS{ _key($opts) } ||= Sereal::Encoder->new($opts); | ||||||||||||||||||
|
Condition66%2/3
$Sereal::ENCODERS{_key($opts)} ||= "Sereal::Encoder"->new($opts)
MC/DC0%0/2
$Sereal::ENCODERS{_key($opts)} ||= "Sereal::Encoder"->new($opts)
$Sereal::ENCODERS{_key($opts)}
"Sereal::Encoder"->new($opts)
Truth table66%2/3
A ||= B
A= $Sereal::ENCODERS{_key($opts)}B= "Sereal::Encoder"->new($opts)
| |||||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 9 | ▶ | sub get_sereal_decoder { | ||||||||||||||||||
|
Subroutine
get_sereal_decoder: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 89 | 9 | my ($opts) = @_; | |||||||||||||||||||
| 90 | 9 | ▶ | return $DECODERS{ _key($opts) } ||= Sereal::Decoder->new($opts); | ||||||||||||||||||
|
Condition66%2/3
$Sereal::DECODERS{_key($opts)} ||= "Sereal::Decoder"->new($opts)
MC/DC0%0/2
$Sereal::DECODERS{_key($opts)} ||= "Sereal::Decoder"->new($opts)
$Sereal::DECODERS{_key($opts)}
"Sereal::Decoder"->new($opts)
Truth table66%2/3
A ||= B
A= $Sereal::DECODERS{_key($opts)}B= "Sereal::Decoder"->new($opts)
| |||||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 2 | ▶ | sub write_sereal_file { | ||||||||||||||||||
|
Subroutine
write_sereal_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 94 | 2 | my ( $file, $struct, $append, $opts ) = @_; | |||||||||||||||||||
| 95 | 2 | get_sereal_encoder($opts)->encode_to_file( $file, $_[1], $append ); | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 6 | ▶ | sub read_sereal_file { | ||||||||||||||||||
|
Subroutine
read_sereal_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 99 | 6 | my ( $file, $opts ) = @_; | |||||||||||||||||||
| 100 | 6 | ▶ | get_sereal_decoder($opts)->decode_from_file( $file, @_ > 2 ? $_[2] : () ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 5 | *read_sereal = *read_sereal = *read_sereal_file; | |||||||||||||||||||
| 104 | 5 | *write_sereal = *write_sereal = *write_sereal_file; | |||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 5 | 1; | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | __END__ | ||||||||||||||||||||