NAME

DTA::CAB::Format::Storable - Datum parser using Storable::freeze() & co.

SYNOPSIS

 use DTA::CAB::Format::Storable;
 
 ##========================================================================
 ## Constructors etc.
 
 $fmt = DTA::CAB::Format::Storable->new(%args);
 
 ##========================================================================
 ## Methods: Persistence
 
 @keys = $class_or_obj->noSaveKeys();
 
 ##========================================================================
 ## Methods: Input
 
 $fmt = $fmt->close();
 $fmt = $fmt->fromString($string);
 $doc = $fmt->parseDocument();
 
 ##========================================================================
 ## Methods: Output
 
 $fmt = $fmt->flush();
 $str = $fmt->toString();
 
 $fmt = $fmt->putToken($tok);
 $fmt = $fmt->putSentence($sent);
 $fmt = $fmt->putDocument($doc);

DESCRIPTION

Globals

Variable: @ISA

DTA::CAB::Format::Storable inherits from DTA::CAB::Format.

Filenames

This module registers the filename regex:

 /\.(?i:sto|bin)$/

with DTA::CAB::Format.

Constructors etc.

new
 $fmt = CLASS_OR_OBJ->new(%args);

Constructor.

%args, %$fmt:

 ##---- Input
 doc      => $doc,               ##-- buffered input document
 ##
 ##---- Output
 docbuf   => $obj,               ##-- an output object buffer (DTA::CAB::Document object)
 netorder => $bool,              ##-- if true (default), then store in network order
 ##
 ##---- INHERITED from DTA::CAB::Format
 #encoding => $encoding,         ##-- n/a
 #level    => $formatLevel,      ##-- sets Data::Dumper->Indent() option
 #outbuf   => $stringBuffer,     ##-- buffered output

Methods: Persistence

noSaveKeys
 @keys = $class_or_obj->noSaveKeys();

Override: returns list of keys not to be saved. This implementation just returns qw(doc).

Methods: Input

close
 $fmt = $fmt->close();

Override: close current input source, if any.

fromString
 $fmt = $fmt->fromString( $string);
 $fmt = $fmt->fromString(\$string)

Override: select input from string $string.

Requires perl 5.8 or better with PerlIO layer for "real" string I/O handles.

fromString_freeze

Like "fromString"(), but uses Storable::thaw() internally. This is actually a Bad Idea, since freeze() and thaw() do not write headers compatible with store() and retrieve() ... annoying but true.

parseDocument
 $doc = $fmt->parseDocument();

Just returns buffered object in $fmt->{doc}

Methods: Output

flush
 $fmt = $fmt->flush();

Override: flush accumulated output

toString
 $str = $fmt->toString();
 $str = $fmt->toString($formatLevel=!$netorder)

Override: flush buffered output in $fmt->{docbuf} to byte-string using Storable::nstore() or Storable::store(). If $formatLevel is given and true, native-endian Storable::store() will be used, otherwise (the default) network-order nstore() will be used.

toString_freeze

Like "toString"(), but uses Storable::nfreeze() and Storable::freeze() internally. See "fromString_freeze" for some hints regarding why this is a Bad Idea.

toFh
 $fmt_or_undef = $fmt->toFh($fh,$formatLevel)

Override: dump buffered output to filehandle $fh. Calls Storable::nstore() or Storable::store() as indicated by $formatLevel, whose semantics are as for "toString"().

putToken , putTokenRaw
 $fmt = $fmt->putToken($tok);
 $fmt = $fmt->putTokenRaw($tok);

Non-destructive / destructive token append.

putSentence , putSentenceRaw
 $fmt = $fmt->putSentence($sent);
 $fmt = $fmt->putSentenceRaw($sent);

Non-destructive / destructive sentence append.

putDocument , putDocumentRaw
 $fmt = $fmt->putDocument($doc);
 $fmt = $fmt->putDocumentRaw($doc);

Non-destructive / destructive document append.

Package Aliases

This module provides a backwards-compatible DTA::CAB::Format::Freeze class which is a trivial subclass of DTA::CAB::Format::Storable.

EXAMPLE

No example file for this format is present, since the format is determined by the perl Storable module. However, the reference stored (rsp. retrieved) should be identical to that in the example perl code in "EXAMPLE" in DTA::CAB::Format::Perl.

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2019 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.