line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#############################################################################
|
2
|
|
|
|
|
|
|
## Name: TieHandle.pm
|
3
|
|
|
|
|
|
|
## Purpose: AutoSession::TieHandle
|
4
|
|
|
|
|
|
|
## Author: Graciliano M. P.
|
5
|
|
|
|
|
|
|
## Modified by:
|
6
|
|
|
|
|
|
|
## Created: 20/5/2003
|
7
|
|
|
|
|
|
|
## RCS-ID:
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2003 Graciliano M. P.
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself
|
11
|
|
|
|
|
|
|
#############################################################################
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package AutoSession::TieHandle ;
|
14
|
|
|
|
|
|
|
our $VERSION = '0.01' ;
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
9
|
use strict qw(vars) ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
17
|
1
|
|
|
1
|
|
5
|
no warnings ;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
912
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub TIEHASH { #print STDOUT "TIEHASH>> @_\n" ;
|
20
|
1
|
|
|
1
|
|
3
|
my $class = shift;
|
21
|
1
|
|
|
|
|
7
|
return bless({ driver => $_[0] }, $class) ;
|
22
|
|
|
|
|
|
|
}
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub FETCH { #print STDOUT "FETCH>> @_\n" ;
|
25
|
5
|
|
|
5
|
|
49
|
my $this = shift ;
|
26
|
5
|
|
|
|
|
7
|
my $key = shift ;
|
27
|
|
|
|
|
|
|
|
28
|
5
|
50
|
|
|
|
24
|
delete($this->{KEYS}) if $this->{driver}->refresh ;
|
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
35
|
return( $this->{driver}{tree}{$key} ) ;
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub STORE { #print STDOUT "STORE>> @_\n" ;
|
34
|
3
|
|
|
3
|
|
5
|
my $this = shift ;
|
35
|
3
|
|
|
|
|
5
|
my $key = shift ;
|
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
3
|
my $notdef ;
|
38
|
3
|
50
|
|
|
|
47
|
if (! defined $this->{driver}{tree}{$key}) { $notdef = 1 ;}
|
|
3
|
|
|
|
|
6
|
|
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
16
|
$this->{driver}{tree}{$key} = $_[0] ;
|
41
|
3
|
|
|
|
|
12
|
$this->{driver}->save ;
|
42
|
|
|
|
|
|
|
|
43
|
3
|
50
|
|
|
|
10
|
delete $this->{KEYS} if !$notdef ;
|
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
14
|
return $_[0] ;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub DELETE { #print STDOUT "DELETE>> @_\n" ;
|
49
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
50
|
0
|
|
|
|
|
|
my $key = shift ;
|
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $ret ;
|
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ( defined $this->{driver}{tree}{$key} ) {
|
55
|
0
|
|
|
|
|
|
$ret = delete $this->{driver}{tree}{$key} ;
|
56
|
0
|
|
|
|
|
|
$this->{driver}->save ;
|
57
|
0
|
|
|
|
|
|
delete $this->{KEYS} ;
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $ret ;
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub EXISTS { #print STDOUT "EXISTS>> @_\n" ;
|
64
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
65
|
0
|
|
|
|
|
|
my $key = shift ;
|
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
delete($this->{KEYS}) if $this->{driver}->refresh ;
|
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ( defined $this->{driver}{tree}{$key} ) { return( 1 ) ;}
|
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return undef ;
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub FIRSTKEY { #my @call = caller ; print STDOUT "FIRSTKEY>> $_[0]->{TYPE} >> @call\n" ;
|
75
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
delete($this->{KEYS}) if $this->{driver}->refresh ;
|
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
if (! $this->{KEYS} ) {
|
80
|
0
|
|
|
|
|
|
my %keys = map { $_ => 1 } ( keys %{$this->{driver}{tree}} ) ;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$this->{KEYS} = [sort keys %keys] ;
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return @{$this->{KEYS}}[0] ;
|
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub NEXTKEY { #print STDOUT "NEXTKEY>> @_\n" ;
|
88
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
89
|
0
|
|
|
|
|
|
my $keylast = shift ;
|
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
delete($this->{KEYS}) if $this->{driver}->refresh ;
|
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if (! $this->{KEYS} ) {
|
94
|
0
|
|
|
|
|
|
my %keys = map { $_ => 1 } ( keys %{$this->{driver}{tree}} ) ;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
$this->{KEYS} = [sort keys %keys] ;
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $ret_next ;
|
99
|
0
|
|
|
|
|
|
foreach my $keys_i ( @{ $this->{KEYS} } ) {
|
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#print STDOUT " >> $keys_i ** $keylast\n" ;
|
101
|
0
|
0
|
|
|
|
|
if ($ret_next) { return($keys_i) ;}
|
|
0
|
|
|
|
|
|
|
102
|
0
|
0
|
0
|
|
|
|
if ($keys_i eq $keylast || ! defined $keylast) { $ret_next = 1 ;}
|
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return undef ;
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub CLEAR { #print STDOUT "CLEAR>> @_\n" ;
|
109
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
110
|
0
|
|
|
|
|
|
$this->{driver}{tree} = {} ;
|
111
|
0
|
|
|
|
|
|
$this->{driver}->save ;
|
112
|
0
|
|
|
|
|
|
delete $this->{KEYS} ;
|
113
|
0
|
|
|
|
|
|
return ;
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
|
|
sub UNTIE {}
|
117
|
0
|
|
|
0
|
|
|
sub DESTROY {}
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#######
|
120
|
|
|
|
|
|
|
# END #
|
121
|
|
|
|
|
|
|
#######
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1;
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|