line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2002-2006 |
3
|
|
|
|
|
|
|
# Steffen Müller |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# All rights reserved. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
8
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Data::Page::Tied; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
795
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
14
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
785
|
use Data::Page; |
|
1
|
|
|
|
|
7149
|
|
|
1
|
|
|
|
|
12
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
34
|
use vars qw/$VERSION @ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1247
|
|
19
|
|
|
|
|
|
|
$VERSION = '2.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# inherit methods from Data::Page. |
22
|
|
|
|
|
|
|
push @ISA, 'Data::Page'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# constructor |
25
|
|
|
|
|
|
|
sub new { |
26
|
103
|
|
|
103
|
1
|
27079
|
my $proto = shift; |
27
|
103
|
|
33
|
|
|
466
|
my $class = ref($proto) || $proto; |
28
|
103
|
|
|
|
|
145
|
my $self = {}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# get the data to start with |
31
|
103
|
|
|
|
|
182
|
my $entries = shift; |
32
|
|
|
|
|
|
|
|
33
|
103
|
100
|
|
|
|
258
|
if (ref $entries eq 'ARRAY') { |
34
|
|
|
|
|
|
|
# if it's an array ref, we use its contents |
35
|
69
|
|
|
|
|
95
|
$self->{ENTRIES} = [ @{ $entries } ]; |
|
69
|
|
|
|
|
326
|
|
36
|
|
|
|
|
|
|
} else { |
37
|
|
|
|
|
|
|
# if it's not an array ref, we return a Data::Page object |
38
|
34
|
|
|
|
|
191
|
return Data::Page->new($entries, @_); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
69
|
|
|
|
|
168
|
bless($self, $class); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# set entries per page and current page (args) |
44
|
69
|
|
|
|
|
166
|
$self->set_entries_per_page(shift); |
45
|
69
|
|
|
|
|
657
|
$self->set_current_page(shift); |
46
|
|
|
|
|
|
|
|
47
|
69
|
|
|
|
|
1471
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# return the total number of entries. |
51
|
|
|
|
|
|
|
sub total_entries { |
52
|
311
|
|
|
311
|
1
|
217737
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
311
|
|
|
|
|
392
|
return scalar(@{$self->{ENTRIES}}); |
|
311
|
|
|
|
|
1591
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# set the current page. |
58
|
|
|
|
|
|
|
sub set_current_page { |
59
|
71
|
|
|
71
|
1
|
2148
|
my $o = shift()->current_page(@_); |
60
|
71
|
|
|
|
|
772
|
$o->current_page(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# set entries per page |
64
|
|
|
|
|
|
|
sub set_entries_per_page { |
65
|
71
|
|
|
71
|
1
|
1487
|
my $o = shift()->entries_per_page( @_ ); |
66
|
71
|
|
|
|
|
1647
|
return $o->entries_per_page; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# access an entry |
70
|
|
|
|
|
|
|
sub entry { |
71
|
68
|
|
|
68
|
1
|
2971
|
my $self = shift; |
72
|
68
|
|
|
|
|
127
|
my $index = shift; |
73
|
68
|
50
|
|
|
|
224
|
$self->{ENTRIES}->[$index] = shift if @_; |
74
|
68
|
|
|
|
|
532
|
return $self->{ENTRIES}->[$index]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# set an entry |
78
|
|
|
|
|
|
|
sub set_entry { |
79
|
34
|
|
|
34
|
1
|
122
|
shift()->entry(@_); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
################## |
83
|
|
|
|
|
|
|
# tied interface # |
84
|
|
|
|
|
|
|
################## |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# invokes constructor |
87
|
|
|
|
|
|
|
sub TIEARRAY { |
88
|
34
|
|
|
34
|
|
517
|
my $class = shift; |
89
|
34
|
|
|
|
|
83
|
my $self = $class->new(@_); |
90
|
34
|
|
|
|
|
121
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub FETCH { |
94
|
105
|
|
|
105
|
|
717
|
$_[0]->{ENTRIES}->[$_[1]]; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub STORE { |
98
|
34
|
|
|
34
|
|
286
|
$_[0]->{ENTRIES}->[$_[1]] = $_[2]; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub FETCHSIZE { |
102
|
77
|
|
|
77
|
|
236
|
my $self = shift; |
103
|
77
|
|
|
|
|
91
|
return scalar @{$self->{ENTRIES}}; |
|
77
|
|
|
|
|
431
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub STORESIZE { |
107
|
34
|
|
|
34
|
|
77
|
my $self = shift; |
108
|
34
|
|
|
|
|
71
|
$#{$self->{ENTRIES}} = shift() - 1; |
|
34
|
|
|
|
|
294
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub EXTEND { |
112
|
0
|
|
|
0
|
|
|
my $self = shift; |
113
|
0
|
|
|
|
|
|
$#{$self->{ENTRIES}} = shift() - 1; |
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
|
|
sub POP { pop @{ $_[0]->{ENTRIES} } } |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
0
|
|
|
sub PUSH { push @{ $_[0]->{ENTRIES} }, @_ } |
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
|
|
sub SHIFT { shift @{ $_[0]->{ENTRIES} } } |
|
0
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
0
|
|
|
sub UNSHIFT { unshift @{ $_[0]->{ENTRIES} }, @_ } |
|
0
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
0
|
|
|
sub SPLICE { splice @{ $_[0]->{ENTRIES} }, @_ } |
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
0
|
|
|
sub DELETE { $_[0]->{ENTRIES}->[$_[1]] = '' } |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
|
|
sub EXISTS { croak "We don't do 'exists' here!" } |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
|
|
sub CLEAR { } |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
0
|
|
|
sub DESTROY { } |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |