NAME
DataPort::DataFile - pure Perl API for local database files
SYNOPSIS
use DataPort::FileType::$Data_Source_Module
$dbh = new(@args)
$success = $dbh->put( \@fields, \$record )
$success = $dbh->get( \@fields, \$record )
$success = $dbh->finish( )
~~~~ Data Source Interface (DSI) follows ~~~~~
$success = $dbh->get_record( \$record )
$success = $dbh->decode_record( \$record )
$success = $dbh->decode_field( \$record, \@fields )
$success = $dbh->encode_field( \@fields, $record_p)
$success = $dbh->encode_record( \$record);
$success = $dbh->put_record( \$record );
DESCRIPTION
new method
$dbh = new(@args)
put method
$success = $dbh->put( \@fields, \$record )
get method
$success = $dbh->get( \@fields, \$record )
finish method
$success = $dbh->finish( )
get_record DSI method
$success = $dbh->get_record( \$record )
decode_record DSI method
$success = $dbh->decode_record( \$record )
decode_field DSI method
$success = $dbh->decode_field( \$record, \@fields )
encode_field DSI method
$success = $dbh->encode_field( \@fields, $record_p)
encode_record DSI method
$success = $dbh->encode_record( \$record);
put_record DSI method
$success = $dbh->put_record( \$record );
REQUIREMENTS
Requirements are coming.
DEMONSTRATION
~~~~~~ Demonstration overview ~~~~~
Perl code begins with the prompt
=>
The selected results from executing the Perl Code follow on the next lines. For example,
=> 2 + 2
4
~~~~~~ The demonstration follows ~~~~~
=> use File::SmartNL;
=> my $snl = 'File::SmartNL';
=> use File::Package;
=> my $fp = 'File::Package';
=> my $loaded = '';
=> my $errors = $fp->load_package( 't::DataPort::DataFileI' )
=> $errors
''
=> $snl->fin( 'DataFile0.tdb' )
'test record 1
test record 2
'
=> unlink 'DataFile1.txt';
=> my $record;
=> my ($array_p, $record_p) = ([], \$record);
=> my $dbh = new t::DataPort::DataFileI(flag => '<', file => 'DataFile0.tdb',
=> option1 => '1', option2 => '2' );
=> while( $dbh->get($array_p, $record_p) ) {
=> $snl->fout( 'DataFile1.txt', $$record_p . "\n~-~\n", {append=>1});
=> $snl->fout( 'DataFile1.txt', join("\n+--\n",@$array_p) . "\n~-~\n", {append=>1});
=> }
=> $snl->fin('DataFile1.txt')
'test record 1
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
get_record
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
decode_record
~-~
fields
+--
test record 1
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
get_record
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
decode_record
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option1
+--
1
+--
option2
+--
2
+--
subroutine
+--
decode_field
~-~
test record 2
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
get_record
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
decode_record
~-~
fields
+--
test record 2
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
get_record
file => DataFile0.tdb
flag => <
option1 => 1
option2 => 2
decode_record
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option1
+--
1
+--
option2
+--
2
+--
subroutine
+--
decode_field
~-~
'
=> unlink 'DataFile1.txt';
=> $dbh->finish();
=> $dbh = new t::DataPort::DataFileI(flag => '<', file => 'DataFile0.tdb',
=> option3 => '3', option4 => '4', option5 => '5' );
=> while( $dbh->get($array_p) ) {
=> $snl->fout( 'DataFile1.txt', join("\n+--\n",@$array_p) . "\n~-~\n", {append=>1});
=> }
=> $dbh->finish();
=> $snl->fin('DataFile1.txt')
'fields
+--
test record 1
file => DataFile0.tdb
flag => <
option3 => 3
option4 => 4
option5 => 5
get_record
file => DataFile0.tdb
flag => <
option3 => 3
option4 => 4
option5 => 5
decode_record
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option3
+--
3
+--
option4
+--
4
+--
option5
+--
5
+--
subroutine
+--
decode_field
~-~
fields
+--
test record 2
file => DataFile0.tdb
flag => <
option3 => 3
option4 => 4
option5 => 5
get_record
file => DataFile0.tdb
flag => <
option3 => 3
option4 => 4
option5 => 5
decode_record
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option3
+--
3
+--
option4
+--
4
+--
option5
+--
5
+--
subroutine
+--
decode_field
~-~
'
=> unlink 'DataFile1.txt';
=> unlink 'DataFile1.tdb';
=> $dbh = new t::DataPort::DataFileI(flag => '>', file => 'DataFile1.tdb',
=> option6 => '6', option7 => '7' );
=> my @db = ( [ 'name1','data1','name2','data2'], [ 'name3', 'data3', 'name4', 'data4' ] );
=>
=> foreach $array_p (@db) {
=> $record = '';
=> $dbh->put($array_p, $record_p);
=> $snl->fout('DataFile1.txt', $$record_p . "\n~-~\n", {append=>1});
=> }
=> $dbh->finish();
=> $snl->fin('DataFile1.tdb')
'put_record
encode_record
encode_field
name1
data1
name2
data2
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
~-~
put_record
encode_record
encode_field
name3
data3
name4
data4
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
~-~
'
=> $snl->fin('DataFile1.txt')
'encode_record
encode_field
name1
data1
name2
data2
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
~-~
encode_record
encode_field
name3
data3
name4
data4
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
option file => DataFile1.tdb
option flag => >
option option6 => 6
option option7 => 7
~-~
'
=> $dbh->finish();
=> unlink 'DataFile1.txt';
=> unlink 'DataFile1.tdb';
=> $dbh = new t::DataPort::DataFileI(flag => '>', file => 'DataFile1.tdb',
=> option8 => '8' );
=> @db = ( [ 'name5','data5','name6','data6'], [ 'name7', 'data7' ] );
=>
=> foreach $array_p (@db) {
=> $dbh->put($array_p);
=> }
=> $dbh->finish();
=> $snl->fin('DataFile1.tdb')
'put_record
encode_record
encode_field
name5
data5
name6
data6
option file => DataFile1.tdb
option flag => >
option option8 => 8
option file => DataFile1.tdb
option flag => >
option option8 => 8
~-~
put_record
encode_record
encode_field
name7
data7
option file => DataFile1.tdb
option flag => >
option option8 => 8
option file => DataFile1.tdb
option flag => >
option option8 => 8
~-~
'
=> unlink 'DataFile1.txt';
=> unlink 'DataFile1.tdb';
=> $dbh = new t::DataPort::DataFileI(flag => '>', file => 'DataFile1.tdb',
=> binary => 1, option9 => '9' );
=> @db = ( [ 'name5','data5','name6','data6'], [ 'name7', 'data7' ] );
=>
=> foreach $array_p (@db) {
=> $dbh->put($array_p);
=> }
=> $dbh->finish();
=> $snl->fin('DataFile1.tdb')
'put_record
encode_record
encode_field
name5
data5
name6
data6
option binary => 1
option file => DataFile1.tdb
option flag => >
option option9 => 9
option binary => 1
option file => DataFile1.tdb
option flag => >
option option9 => 9
~-~
put_record
encode_record
encode_field
name7
data7
option binary => 1
option file => DataFile1.tdb
option flag => >
option option9 => 9
option binary => 1
option file => DataFile1.tdb
option flag => >
option option9 => 9
~-~
'
=> unlink 'DataFile1.txt';
=> unlink 'DataFile1.tdb';
=> $dbh = new t::DataPort::DataFileI(flag => '<', file => 'DataFile0.tdb',
=> binary => 1, option10 => '10', option11 => '11' );
=> while( $dbh->get($array_p, $record_p) ) {
=> $snl->fout( 'DataFile1.txt', $$record_p . "\n~-~\n", {append => 1, binary => 1});
=> $snl->fout( 'DataFile1.txt', join("\n+--\n",@$array_p) . "\n~-~\n", {append => 1, binary => 1});
=> }
=> $dbh->finish();
=> $snl->fin('DataFile1.txt')
'test record 1
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
get_record
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
decode_record
~-~
fields
+--
test record 1
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
get_record
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
decode_record
+--
binary
+--
1
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option10
+--
10
+--
option11
+--
11
+--
subroutine
+--
decode_field
~-~
test record 2
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
get_record
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
decode_record
~-~
fields
+--
test record 2
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
get_record
binary => 1
file => DataFile0.tdb
flag => <
option10 => 10
option11 => 11
decode_record
+--
binary
+--
1
+--
file
+--
DataFile0.tdb
+--
flag
+--
<
+--
option10
+--
10
+--
option11
+--
11
+--
subroutine
+--
decode_field
~-~
'
=> unlink 'DataFile1.txt';
=> unlink 'DataFile1.tdb';
QUALITY ASSURANCE
The module "t::DataPort::DataFile" is the Software Test Description(STD) module for the "DataPort::DataFile". module.
To generate all the test output files, run the generated test script, run the demonstration script, execute the following in any directory:
tmake -verbose -replace -run -pm=t::DataPort::DataFile
Note that tmake.pl must be in the execution path $ENV{PATH}
and the "t" directory on the same level as the "lib" that contains the "DataPort::DataFile" module.
NOTES
AUTHOR
The holder of the copyright and maintainer is
E<lt>support@SoftwareDiamonds.comE<gt>
COPYRIGHT NOTICE
Copyrighted (c) 2002 Software Diamonds
All Rights Reserved
BINDING REQUIREMENTS NOTICE
Binding requirements are indexed with the pharse 'shall[dd]' where dd is an unique number for each header section. This conforms to standard federal government practices, 490A ("3.2.3.6" in STD490A). In accordance with the License, Software Diamonds is not liable for any requirement, binding or otherwise.
LICENSE
Software Diamonds permits the redistribution and use in source and binary forms, with or without modification, provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
SOFTWARE DIAMONDS PROVIDES THIS SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.