NAME

FlatFile::DataStore::Lite::Preamble - Perl module that implements a lightweight flat file data store preamble class.

SYNOPSYS

use FlatFile::DataStore::Lite::Preamble;

my $preamble = FlatFile::DataStore::Lite::Preamble->new( {
    indicator => $indicator,  # single-character crud flag
    keynum    => $keynum,     # record sequence number (integer)
    reclen    => $reclen,     # record length (integer)
    thisfnum  => $fnum,       # file number (in base format)
    thisseek  => $datapos,    # seek position (integer)
    user      => $user_data,  # pre-formatted user-defined data
    } );

my $string = $preamble->string(); # e.g.,

# new preamble from existing preamble string
# e.g., something like "=000I00Tw1001XNTest "

my $clone = FlatFile::DataStore::Lite::Preamble->new( { string => $string } );

DESCRIPTION

FlatFile::DataStore::Lite::Preamble - Perl module that implements a lightweight flat file data store preamble class. This class defines objects used by FlatFile::DataStore::Lite::Record and FlatFile::DataStore::Lite. So you will probably not ever call new() yourself, but you might call some of the accessors either directly or via a FF::DS::Record object;

A "preamble" is a string of fixed-length fields that precedes every record in a FlatFile::DataStore::Lite data file. In addition, this string constitutes the entry in the data store key file for each current record.

VERSION

FlatFile::DataStore::Lite::Preamble version 0.01

CLASS METHODS

FlatFile::DataStore::Lite::Preamble->new( $parms )

Constructs a new FlatFile::DataStore::Lite::Preamble object.

The parm $parms is a hash reference containing key/value pairs to populate the preamble string. If there is a $parms-{'string'}> value, it will be parsed into fields and the resulting key/value pairs will replace the $parms hash reference.

OBJECT METHODS: ACCESSORS

The following methods set and return their respective attribute values if $value is given. Otherwise, they just return the value.

$preamble->string(    [$value] ); # full preamble string
$preamble->indicator( [$value] ); # single-character crud indicator
$preamble->keynum(    [$value] ); # record sequence number (integer)
$preamble->reclen(    [$value] ); # record length (integer)
$preamble->thisfnum(  [$value] ); # file number (in base format)
$preamble->thisseek(  [$value] ); # seek position (integer)
$preamble->user(      [$value] ); # pre-formatted user-defined data

Note: the class code uses these accessors to set values in the object as it is assembling the preamble string in new(). Unless you have a really good reason, you should not set these values yourself (outside of a call to new()). For example: setting the user data with user() will not change the user data in the string attribute.

In other words, even though these are read/write accessors, you should only use them for reading.

AUTHOR

Brad Baxter, <bbaxter@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Brad Baxter

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