line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#======================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Badger::Codec |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Base class codec providing a generic API for encoding/decoding data. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Andy Wardley |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
#======================================================================== |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Badger::Codec; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Badger::Class |
16
|
21
|
|
|
|
|
139
|
version => 0.01, |
17
|
|
|
|
|
|
|
debug => 0, |
18
|
|
|
|
|
|
|
base => 'Badger::Base', |
19
|
21
|
|
|
21
|
|
2547
|
utils => 'UTILS'; |
|
21
|
|
|
|
|
40
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub encode { |
22
|
0
|
|
|
0
|
1
|
0
|
shift->not_implemented; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub decode { |
26
|
0
|
|
|
0
|
1
|
0
|
shift->not_implemented; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# This is the "brute force and ignorance" approach to creating stand-alone |
31
|
|
|
|
|
|
|
# subroutines. They get the job done, albeit at the overhead of an extra |
32
|
|
|
|
|
|
|
# method call. Subclasses can do something better, like exporting existing |
33
|
|
|
|
|
|
|
# subrefs directly. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub encoder { |
36
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
37
|
3
|
|
|
3
|
|
11
|
return sub { $self->encode(@_) }; |
|
3
|
|
|
|
|
10
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub decoder { |
41
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
42
|
3
|
|
|
1
|
|
26
|
return sub { $self->decode(@_) }; |
|
1
|
|
|
|
|
4
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |