DTA::CAB::Format::Storable - Datum parser using Storable::freeze() & co.
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);
DTA::CAB::Format::Storable inherits from DTA::CAB::Format.
This module registers the filename regex:
/\.(?i:sto|bin)$/
with DTA::CAB::Format.
$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
@keys = $class_or_obj->noSaveKeys();
Override: returns list of keys not to be saved. This implementation just returns qw(doc).
qw(doc)
$fmt = $fmt->close();
Override: close current input source, if any.
$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.
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.
$doc = $fmt->parseDocument();
Just returns buffered object in $fmt->{doc}
$fmt = $fmt->flush();
Override: flush accumulated output
$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.
Like "toString"(), but uses Storable::nfreeze() and Storable::freeze() internally. See "fromString_freeze" for some hints regarding why this is a Bad Idea.
$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"().
$fmt = $fmt->putToken($tok); $fmt = $fmt->putTokenRaw($tok);
Non-destructive / destructive token append.
$fmt = $fmt->putSentence($sent); $fmt = $fmt->putSentenceRaw($sent);
Non-destructive / destructive sentence append.
$fmt = $fmt->putDocument($doc); $fmt = $fmt->putDocumentRaw($doc);
Non-destructive / destructive document append.
This module provides a backwards-compatible DTA::CAB::Format::Freeze class which is a trivial subclass of DTA::CAB::Format::Storable.
DTA::CAB::Format::Freeze
DTA::CAB::Format::Storable
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.
Storable
Bryan Jurish <moocow@cpan.org>
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.
To install DTA::CAB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DTA::CAB
CPAN shell
perl -MCPAN -e shell install DTA::CAB
For more information on module installation, please visit the detailed CPAN module installation guide.