CGI::MxScreen::Serializer::Storable - Storable serialization


CGI-MxScreen documentation Contained in the CGI-MxScreen distribution.

Index


Code Index:

NAME

Top

CGI::MxScreen::Serializer::Storable - Storable serialization

SYNOPSIS

Top

 # Inherits from CGI::MxScreen::Serializer

 require CGI::MxScreen::Serializer::Storable;

 my $ser = CGI::MxScreen::Serializer::Storable->make(
     -shared     => 1,
     -compress   => 1,
 );

DESCRIPTION

Top

This module customizes the serialization interface inherited from CGI::MxScreen::Serializer to use Storable.

Apart from the creation routine documented hereinafter, this class conforms to the interface described in CGI::MxScreen::Serializer.

The creation routine make() takes the following optional arguments:

-compress => flag

Whether to compress the serialized form before returning it. Data will be uncompressed on-the-fly by the deserialize routine. It is false by default.

This makes compression transparent once configured.

-shared => flag

Whether serialized data are expected to be shared across different architectures. When true, Storable will use its portable format to perform the serialization. Otherwise, data can normally be recovered only on a compatible architecture.

It is false by default.

AUTHOR

Top

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO

Top

CGI::MxScreen::Serializer(3), Storable(3).


CGI-MxScreen documentation Contained in the CGI-MxScreen distribution.

# -*- Mode: perl -*-
#
# $Id: Storable.pm,v 0.1 2001/04/22 17:57:03 ram Exp $
#
#  Copyright (c) 1998-2001, Raphael Manfredi
#  Copyright (c) 2000-2001, Christophe Dehaudt
#  
#  You may redistribute only under the terms of the Artistic License,
#  as specified in the README file that comes with the distribution.
#
# HISTORY
# $Log: Storable.pm,v $
# Revision 0.1  2001/04/22 17:57:03  ram
# Baseline for first Alpha release.
#
# $EndLog$
#

use strict;

package CGI::MxScreen::Serializer::Storable;

require CGI::MxScreen::Serializer;
use vars qw(@ISA);
@ISA = qw(CGI::MxScreen::Serializer);

use Carp::Datum;
use Getargs::Long;
use Storable qw(freeze nfreeze thaw);

#
# ->make
#
# Creation routine.
#
# Arguments:
#   -shared		whether stored data can be read by various architectures
#   -compress	whether stored data should be compressed
#
sub make {
	DFEATURE my $f_;
	my $self = bless {}, shift;
	my ($shared, $compress) = xgetargs(@_,
		-shared		=> ['i', 0],
		-compress	=> ['i', 0],
	);

	my $freezer = $shared ? \&nfreeze : \&freeze;
	$self->_init($freezer, \&thaw, $compress);

	return DVAL $self;
}

1;