|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Data::Iterator::EasyObj;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
7261
 | 
 use strict;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
38
 | 
    | 
| 
4
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
5
 | 
 use vars qw/$AUTOLOAD $VERSION/;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
58
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $VERSION = 0.01;  | 
| 
6
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
1212
 | 
 use Data::Dumper;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10211
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
538
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
9
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
1
  
 | 
35
 | 
   my ($class,$data,$fields,%args) = @_;  | 
| 
10
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
   my $fieldshash;  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "fields : \n", Dumper($fields), "\n";  | 
| 
12
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
   if (lc(ref $fields) eq "hash") {  | 
| 
 
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     foreach my $key (keys %$fields) {  | 
| 
14
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
       if (ref($fields->{$key})) {  | 
| 
15
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	$fieldshash->{$key} = $fields->{$key};  | 
| 
16
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	warn "using id\n";  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       } else {  | 
| 
18
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	$fieldshash->{$key} = { id => $fields->{$key} };  | 
| 
19
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	warn "creating id\n";  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } elsif (lc(ref $fields) eq "array") {  | 
| 
23
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
     my $i = 0;  | 
| 
24
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     foreach my $field (@$fields) {  | 
| 
25
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
       $fieldshash->{$field} = { id => $i++} ;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } else {  | 
| 
28
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     die "fields must be an arrayref or hashref\n";  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "fieldshash : \n", Dumper($fieldshash), "\n";  | 
| 
31
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
   my $self = [ $data, $fieldshash, -1, scalar @{$data}, {}, 0];  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
32
 | 
2
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
12
 | 
   bless ($self,ref($class) || $class);  | 
| 
33
 | 
2
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
15
 | 
   $args{limit} ||= $self->[3];  | 
| 
34
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
   $self->offset($args{offset}) if ($args{offset});  | 
| 
35
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
22
 | 
   $self->limit($args{limit}) if ($args{limit});  | 
| 
36
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
   return $self;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub next {  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "getting next record\n";  | 
| 
41
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
  
0
  
 | 
40
 | 
   my $self = shift;  | 
| 
42
 | 
17
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
35
 | 
   $self->[2]+= $self->[5] if ($self->[2] < 0 );  | 
| 
43
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
   $self->[2]++;  | 
| 
44
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
   my $return = 1;  | 
| 
45
 | 
17
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
43
 | 
   if ($self->[2] >= $self->[3]) {  | 
| 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     $return = 0;  | 
| 
47
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     $self->[2] = -1;  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } elsif ($self->[2] >= $self->[6]) {  | 
| 
49
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
     $return = 0;  | 
| 
50
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
     $self->[2] = -1;  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
52
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26
 | 
   $self->[4] = $self->[0][$self->[2]];  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "current record ::\n", Dumper(@{$self->[4]});  | 
| 
54
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
   return $return;  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub offset {  | 
| 
58
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
6
 | 
   my ($self,$offset) = @_;  | 
| 
59
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
   $self->[5] = $offset;  | 
| 
60
 | 
1
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
17
 | 
   $self->[2] = $offset if ($self->[2] >= 0 && $self->[2] < $offset);  | 
| 
61
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
   my $return = 1;  | 
| 
62
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
   return $return;  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub limit {  | 
| 
66
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
7
 | 
   my ($self,$limit) = @_;  | 
| 
67
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
   my $return = 1;  | 
| 
68
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
   $self->[6] = $limit + $self->[5];  | 
| 
69
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
   return $return;  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub count {  | 
| 
74
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
   my $self = shift;  | 
| 
75
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
   return $self->[3];  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub add_column {  | 
| 
79
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
16
 | 
   my ($self, $name) = @_;  | 
| 
80
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
   my $fieldcount = keys %{$self->[1]};  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "adding column : fieldcount is $fieldcount\n";  | 
| 
82
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
   $self->[1]{$name}{id}=$fieldcount;  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub add_value {  | 
| 
86
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
14
 | 
   my ($self, $field,$value) = @_;  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn"adding value : $field / $value";  | 
| 
88
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
   $self->[4][$self->[1]{$field}{id}] = $value;  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ########################################################################################  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub AUTOLOAD {  | 
| 
94
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
8
 | 
   no strict "refs";  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
169
 | 
    | 
| 
95
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
53
 | 
   my ($self) = @_;  | 
| 
96
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
   $AUTOLOAD =~ /.*::(\w+)/;  | 
| 
97
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
   my $field = $1;  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  warn "(autoload) getting $field \n";  | 
| 
99
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
16
 | 
   exists $self->[1]{$field} or die "no such field : $field \n";  | 
| 
100
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
   *{$AUTOLOAD} = sub {  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #    warn "(magic) getting $field -- counter : $self->[2] -- field : ", Dumper(%{$self->[1]{$field}})," -- value : $self->[4][$self->[1]{$field}{id}]\n";  | 
| 
102
 | 
53
 | 
 
 | 
 
 | 
  
53
  
 | 
 
 | 
345
 | 
     return $self->[4][$self->[1]{$field}{id}]  | 
| 
103
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
37
 | 
   };  | 
| 
104
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
92
 | 
   return $self->[4][$self->[1]{$field}{id}];  | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ########################################################################################  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ########################################################################################  | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
111
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ###########################################################################  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |