Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Badger::Codec(3)      User Contributed Perl Documentation     Badger::Codec(3)

NAME
       Badger::Codec - base class for encoding/decoding	data

SYNOPSIS
	   # creating a	Badger::Codec subclass
	   package My::Codec;
	   use base 'Badger::Codec';

	   sub encode {
	       my ($self, $data) = @_;
	       # do something
	       return $encoded_data;
	   }

	   sub decode {
	       my ($self, $encoded_data) = @_;
	       # do something
	       return $decoded_data;
	   }

	   # using the subclass:
	   use My::Codec;

	   my $codec   = My::Codec->new();
	   my $encoded = $codec->encode($some_data);
	   my $decoded = $codec->decode($encoded);

INTRODUCTION
       This documentation describes the	inner working of codec modules.	You
       should only need	to consult this	documentation if you're	writing	a
       codec subclass.	For a general introduction to codecs and examples of
       use, please see Badger::Codecs.

DESCRIPTION
       This module implements a	base class codec module	for encoding and
       decoding	data to	and from different formats. It must be subclassed to
       provide useful implementations of the "encode()"	and "decode()"
       methods.

       In most,	if not all cases, subclasses will simply delegate to
       subroutines provided by other modules.  For example, the
       Badger::Codec::Storable module delegates	to the "freeze()" and "thaw()"
       methods provided	by the Storable	module.

METHODS
   encode($data)
       Method for encoding data.  This must be redefined in subclassed
       modules.

   decode($data)
       Method for decoding data.  This must be redefined in subclassed
       modules.

   encoder()
       Returns a reference to a	subroutine which performs the encoding
       operation.

   decoder()
       Returns a reference to a	subroutine which performs the decoding
       operation.

AUTHOR
       Andy Wardley <http://wardley.org/>

COPYRIGHT
       Copyright (C) 2005-2009 Andy Wardley. All rights	reserved.

       This module is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

perl v5.32.0			  2016-12-12		      Badger::Codec(3)

NAME | SYNOPSIS | INTRODUCTION | DESCRIPTION | METHODS | AUTHOR | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Badger::Codec&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help