# Setup $self and bless into this class.
##
my $class = shift;
- my $args = shift;
+ my ($args) = @_;
# These are the defaults to be optionally overridden below
my $self = bless {
type => TYPE_HASH,
engine => DBM::Deep::Engine->new,
}, $class;
-
$self->{base_offset} = length( $self->{engine}->SIG_FILE );
foreach my $param ( keys %$self ) {
# times before unlock(), then the same number of unlocks() must
# be called before the lock is released.
##
- my $self = $_[0]->_get_self;
- my $type = $_[1];
+ my $self = shift->_get_self;
+ my ($type) = @_;
$type = LOCK_EX unless defined $type;
if (!defined($self->_fh)) { return; }
# If db locking is set, unlock the db file. See note in lock()
# regarding calling lock() multiple times.
##
- my $self = $_[0]->_get_self;
+ my $self = shift->_get_self;
if (!defined($self->_fh)) { return; }
##
# Recursively export into standard Perl hashes and arrays.
##
- my $self = $_[0]->_get_self;
+ my $self = shift->_get_self;
my $temp;
if ($self->_type eq TYPE_HASH) { $temp = {}; }
#XXX This use of ref() seems to be ok
if (!ref($_[0])) { return; } # Perl calls import() on use -- ignore
- my $self = $_[0]->_get_self;
- my $struct = $_[1];
+ my $self = shift->_get_self;
+ my ($struct) = @_;
#XXX This use of ref() seems to be ok
if (!ref($struct)) {
# Rebuild entire database into new file, then move
# it back on top of original.
##
- my $self = $_[0]->_get_self;
+ my $self = shift->_get_self;
#XXX Need to create a new test for this
# if ($self->_root->{links} > 1) {
##
# Make copy of object and return
##
- my $self = $_[0]->_get_self;
+ my $self = shift->_get_self;
return DBM::Deep->new(
type => $self->_type,
##
# Setup filter function for storing or fetching the key or value
##
- my $self = $_[0]->_get_self;
- my $type = lc $_[1];
- my $func = $_[2] ? $_[2] : undef;
+ my $self = shift->_get_self;
+ my $type = lc shift;
+ my $func = shift;
if ( $is_legal_filter{$type} ) {
$self->_root->{"filter_$type"} = $func;
return $self->{root};
}
-sub _fh {
- ##
- # Get access to the raw fh
- ##
- my $self = $_[0]->_get_self;
- return $self->_root->{fh};
-}
-
sub _type {
##
# Get type of current node (TYPE_HASH or TYPE_ARRAY)
return $self->{base_offset};
}
+sub _fh {
+ ##
+ # Get access to the raw fh
+ ##
+ my $self = $_[0]->_get_self;
+ return $self->_root->{fh};
+}
+
##
# Utility methods
##
seek($fh, 0 + $obj->_root->{file_offset}, SEEK_SET);
print( $fh SIG_FILE);
+ $obj->_root->{end} = length( SIG_FILE );
+
+ $obj->{base_offset} = $self->_request_space($obj, $self->{index_size});
+
$self->create_tag(
- $obj, $obj->_base_offset, $obj->_type,
- chr(0) x $self->{index_size},
+ $obj, $obj->_base_offset, $obj->_type, chr(0) x $self->{index_size},
);
# Flush the filehandle
return;
}
+sub _request_space {
+ my $self = shift;
+ my ($obj, $size) = @_;
+
+ my $loc = $obj->_root->{end};
+
+ return $loc;
+}
+
+sub _release_space {
+ my $self = shift;
+ my ($obj, $size, $loc) = @_;
+
+ return;
+}
+
1;
__END__