line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1701
|
use 5.006; |
|
3
|
|
|
|
|
10
|
|
2
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
59
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
208
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package LINQ::FieldSet; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
21
|
use Class::Tiny qw( fields seen_asterisk ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
17
|
|
11
|
3
|
|
|
3
|
|
1256
|
use LINQ::Util::Internal (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1358
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _known_parameter_names { |
14
|
55
|
|
|
55
|
|
106
|
my ( $self ) = ( shift ); |
15
|
55
|
|
|
|
|
363
|
return (); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub BUILDARGS { |
19
|
56
|
|
|
56
|
1
|
1030
|
my ( $class, @args ) = ( shift, @_ ); |
20
|
|
|
|
|
|
|
|
21
|
56
|
100
|
100
|
|
|
215
|
if ( @args == 1 and ref( $args[0] ) eq 'HASH' ) { |
22
|
1
|
|
|
|
|
4
|
return $args[0]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
55
|
|
|
|
|
2091
|
require LINQ::Field; |
26
|
|
|
|
|
|
|
|
27
|
55
|
|
|
|
|
226
|
my %known = $class->_known_parameter_names; |
28
|
|
|
|
|
|
|
|
29
|
55
|
|
|
|
|
105
|
my @fields; |
30
|
55
|
|
|
|
|
92
|
my $idx = 0; |
31
|
55
|
|
|
|
|
75
|
my $seen_asterisk; |
32
|
|
|
|
|
|
|
|
33
|
55
|
|
|
|
|
129
|
ARG: while ( @args ) { |
34
|
73
|
|
|
|
|
116
|
my $value = shift @args; |
35
|
73
|
100
|
|
|
|
173
|
if ( $value eq '*' ) { |
36
|
5
|
|
|
|
|
10
|
$seen_asterisk = 1; |
37
|
5
|
|
|
|
|
18
|
next ARG; |
38
|
|
|
|
|
|
|
} |
39
|
68
|
|
|
|
|
127
|
my %params = (); |
40
|
68
|
|
100
|
|
|
507
|
while ( @args and !ref $args[0] and $args[0] =~ /\A-/ ) { |
|
|
|
100
|
|
|
|
|
41
|
77
|
|
|
|
|
172
|
my $p_name = substr( shift( @args ), 1 ); |
42
|
77
|
100
|
|
|
|
187
|
if ( $known{$p_name} ) { |
|
|
100
|
|
|
|
|
|
43
|
60
|
|
|
|
|
240
|
$params{$p_name} = shift( @args ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ( exists $known{$p_name} ) { |
46
|
16
|
|
|
|
|
79
|
$params{$p_name} = 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
1
|
|
|
|
|
6
|
LINQ::Util::Internal::throw( |
50
|
|
|
|
|
|
|
'CallerError', |
51
|
|
|
|
|
|
|
message => "Unknown field parameter '$p_name'", |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} #/ while ( @args and !ref $args...) |
55
|
|
|
|
|
|
|
|
56
|
67
|
|
|
|
|
252
|
my $field = 'LINQ::Field'->new( |
57
|
|
|
|
|
|
|
value => $value, |
58
|
|
|
|
|
|
|
index => ++$idx, |
59
|
|
|
|
|
|
|
params => \%params, |
60
|
|
|
|
|
|
|
); |
61
|
67
|
|
|
|
|
437
|
push @fields, $field; |
62
|
|
|
|
|
|
|
} #/ ARG: while ( @args ) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return { |
65
|
54
|
|
|
|
|
273
|
fields => \@fields, |
66
|
|
|
|
|
|
|
seen_asterisk => $seen_asterisk, |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
} #/ sub BUILDARGS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub fields_hash { |
71
|
10
|
|
|
10
|
1
|
1904
|
my ( $self ) = ( shift ); |
72
|
10
|
|
100
|
|
|
112
|
$self->{fields_hash} ||= $self->_build_fields_hash; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _build_fields_hash { |
76
|
6
|
|
|
6
|
|
9
|
my ( $self ) = ( shift ); |
77
|
6
|
|
|
|
|
9
|
my %fields; |
78
|
6
|
|
|
|
|
7
|
foreach my $field ( @{ $self->fields } ) { |
|
6
|
|
|
|
|
114
|
|
79
|
15
|
|
|
|
|
283
|
$fields{ $field->name } = $field; |
80
|
|
|
|
|
|
|
} |
81
|
6
|
|
|
|
|
71
|
return \%fields; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding utf-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
LINQ::FieldSet - base class for LINQ::FieldSet::{Selection,Assertion} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is used internally by LINQ and you probably don't need to know about it |
100
|
|
|
|
|
|
|
unless you're writing very specific extensions for LINQ. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item C<< new( ARGSLIST ) >> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Constructs a fieldset from a list of fields like: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
'LINQ::FieldSet'->new( |
111
|
|
|
|
|
|
|
'field1', -param1 => 'value1', -param2, |
112
|
|
|
|
|
|
|
'field2', -param1 => 'value2', |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The list of allowed parameters and whether each one takes a value is returned |
116
|
|
|
|
|
|
|
by the C<_known_parameter_names> method. This is empty in LINQ::FieldSet itself |
117
|
|
|
|
|
|
|
so doing anything interesting with this class probably requires subclassing. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=begin trustme |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item BUILDARGS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=end trustme |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 METHODS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item C<fields> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
An arrayref of fields in this fieldset. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item C<fields_hash> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The same, but as a hashref keyed on field name. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item C<seen_asterisk> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Whether "*" was seen by the constructor. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 BUGS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please report any bugs to |
148
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<LINQ::FieldSet>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Toby Inkster. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
163
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
168
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
169
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |