line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Serializer::Sereal; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53080
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
138
|
|
5
|
1
|
|
|
1
|
|
7
|
use base qw(Data::Serializer); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1262
|
|
6
|
1
|
|
|
1
|
|
5274
|
use Sereal::Encoder qw(sereal_encode_with_object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
163
|
|
7
|
1
|
|
|
1
|
|
6
|
use Sereal::Decoder qw(sereal_decode_with_object); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
404
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Data::Serializer::Sereal - Creates bridge between Data::Serializer and Sereal |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.05 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $ENCODER; |
22
|
|
|
|
|
|
|
our $DECODER; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Creates bridge between Data::Serializer and Sereal |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 serialize |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
serialize object/data |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub serialize { |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $object) = @_; |
39
|
0
|
|
|
|
|
|
return sereal_encode_with_object($self->encoder, $object); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 deserialize |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
deserialize object/data |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub deserialize { |
49
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
50
|
0
|
|
|
|
|
|
my $object; |
51
|
0
|
|
|
|
|
|
sereal_decode_with_object($self->decoder, $_[1], $object); |
52
|
0
|
|
|
|
|
|
return $object; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 decoder |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
gets the decoder from options or uses the default decoder |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub decoder { |
62
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
63
|
0
|
|
|
|
|
|
my $decoder = $self->{options}{decoder}; |
64
|
0
|
0
|
|
|
|
|
return $decoder if ref($decoder) eq 'Sereal::Decoder'; |
65
|
0
|
|
0
|
|
|
|
return $DECODER ||= Sereal::Decoder->new(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 encoder |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
gets the encoder from options or uses the default encoder |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub encoder { |
75
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
76
|
0
|
|
|
|
|
|
my $encoder = $self->{options}{encoder}; |
77
|
0
|
0
|
|
|
|
|
return $encoder if ref($encoder) eq 'Sereal::Encoder'; |
78
|
0
|
|
0
|
|
|
|
return $ENCODER ||= Sereal::Encoder->new(); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Recreates global ENCODER/DECODER after thread is created |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub CLONE { |
88
|
0
|
|
|
0
|
|
|
$ENCODER = undef; |
89
|
0
|
|
|
|
|
|
$DECODER = undef; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
James Rouzier, C<< >> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
99
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
100
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SUPPORT |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
perldoc Data::Serializer::Sereal |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
You can also look for information at: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over 4 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * CPAN Ratings |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * Search CPAN |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2014 James Rouzier. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
141
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
142
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; # End of Data::Serializer::Sereal |