/[wait]/cvs-head/lib/WAIT/Index.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /cvs-head/lib/WAIT/Index.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10 by ulpfr, Fri Apr 28 15:40:52 2000 UTC revision 29 by laperla, Sun Nov 12 01:21:05 2000 UTC
# Line 1  Line 1 
1  #                              -*- Mode: Perl -*-  #                              -*- Mode: Cperl -*-
2  # Index.pm --  # Index.pm --
3  # ITIID           : $ITI$ $Header $__Header$  # ITIID           : $ITI$ $Header $__Header$
4  # Author          : Ulrich Pfeifer  # Author          : Ulrich Pfeifer
# Line 17  use WAIT::IndexScan; Line 17  use WAIT::IndexScan;
17  use strict;  use strict;
18  use DB_File;  use DB_File;
19  use Fcntl;  use Fcntl;
20    use vars qw($VERSION);
21    
22  sub fail {  $VERSION = "1.801"; # Table.pm tests if we are loaded by checking $VERSION
   $@ .= join "\n", @_;  
   return undef;  
 }  
23    
24  sub new {  sub new {
25    my $type = shift;    my $type = shift;
26    my %parm = @_;    my %parm = @_;
27    my $self = {};    my $self = {};
28    
29    $self->{file}     = $parm{file}     or return fail("No file specified");    unless ($self->{file} = $parm{file}) {
30    $self->{attr}     = $parm{attr}     or return fail("No attributes specified");      require Carp;
31        Carp::croak("No file specified");
32      }
33      unless ($self->{attr} = $parm{attr}) {
34        require Carp;
35        Carp::croak("No attributes specified");
36      }
37    bless $self, ref($type) || $type;    bless $self, ref($type) || $type;
38  }  }
39    
# Line 37  sub drop { Line 41  sub drop {
41    my $self = shift;    my $self = shift;
42    if ((caller)[0] eq 'WAIT::Table') { # Table knows about this    if ((caller)[0] eq 'WAIT::Table') { # Table knows about this
43      my $file = $self->{file};      my $file = $self->{file};
   
44      ! (!-e $file or unlink $file);      ! (!-e $file or unlink $file);
45    } else {                              # notify our database    } else {                            # notify our database
46      fail ref($self)."::drop called directly";      require Carp;
47        Carp::croak(ref($self)."::drop called directly");
48    }    }
49  }  }
50    
# Line 87  sub fetch { Line 91  sub fetch {
91    my $self  = shift;    my $self  = shift;
92    my %parm  = @_;    my %parm  = @_;
93    my @keys  = @{$self->{attr}->[0]};    my @keys  = @{$self->{attr}->[0]};
94      
95    defined $self->{db} or $self->open;    defined $self->{db} or $self->open;
96    
97    my $key   = join($;, map($parm{$_}, @keys));    my $key   = join($;, map($parm{$_}, @keys));
# Line 101  sub delete { Line 105  sub delete {
105    
106    defined $self->{db} or $self->open;    defined $self->{db} or $self->open;
107    
108    my $tuple = join($;, map($parm{$_}, @{$self->{attr}}));    my $tuple = join($;, map($parm{$_}||"", @{$self->{attr}}));
109      
110    delete $self->{db}->{$tuple};    delete $self->{db}->{$tuple};
111  }  }
112    
# Line 128  sub close { Line 132  sub close {
132  sub open_scan {  sub open_scan {
133    my $self = shift;    my $self = shift;
134    my $code = shift;    my $code = shift;
135      
136    $self->{dbh} or $self->open;    $self->{dbh} or $self->open;
137    new WAIT::IndexScan $self, $code;    new WAIT::IndexScan $self, $code;
138  }  }

Legend:
Removed from v.10  
changed lines
  Added in v.29

  ViewVC Help
Powered by ViewVC 1.1.26