| 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 <abw@wardley.org> | ||
| 10 | # | ||
| 11 | #======================================================================== | ||
| 12 | |||
| 13 | package Badger::Codec; | ||
| 14 | |||
| 15 | use Badger::Class | ||
| 16 | 21 | version => 0.01, | |
| 17 | debug => 0, | ||
| 18 | base => 'Badger::Base', | ||
| 19 | 21 | ▶ | utils => 'UTILS'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | sub encode { | ||
| 22 | 0 | ▶ | shift->not_implemented; |
|
Subroutine
encode: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 23 | } | ||
| 24 | |||
| 25 | sub decode { | ||
| 26 | 0 | ▶ | shift->not_implemented; |
|
Subroutine
decode: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 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 | ▶ | my $self = shift; |
|
Subroutine
encoder: called CC=1 SCAR=0.0
Pod
documented
| |||
| 37 | 3 | ▶ | return sub { $self->encode(@_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 38 | } | ||
| 39 | |||
| 40 | sub decoder { | ||
| 41 | 3 | ▶ | my $self = shift; |
|
Subroutine
decoder: called CC=1 SCAR=0.0
Pod
documented
| |||
| 42 | 3 | ▶ | return sub { $self->decode(@_) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 43 | } | ||
| 44 | |||
| 45 | 21 | 1; | |
| 46 | |||
| 47 | |||
| 48 | __END__ | ||