| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OPTIMADE::Filter::Zip; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
33
|
use strict; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
183
|
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
269
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
23
|
use parent 'OPTIMADE::Filter::Modifiable'; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
27
|
|
|
7
|
5
|
|
|
5
|
|
408
|
use List::Util qw(any); |
|
|
5
|
|
|
|
|
42
|
|
|
|
5
|
|
|
|
|
658
|
|
|
8
|
5
|
|
|
5
|
|
29
|
use Scalar::Util qw(blessed); |
|
|
5
|
|
|
|
|
25
|
|
|
|
5
|
|
|
|
|
4498
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.11.0'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
16
|
|
|
16
|
0
|
31
|
my( $class ) = @_; |
|
14
|
16
|
|
|
|
|
82
|
return bless { properties => [], |
|
15
|
|
|
|
|
|
|
operator => undef, |
|
16
|
|
|
|
|
|
|
values => [] }, $class; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub push_property { |
|
20
|
18
|
|
|
18
|
0
|
35
|
my( $self, $property ) = @_; |
|
21
|
18
|
|
|
|
|
30
|
push @{$self->{properties}}, $property; |
|
|
18
|
|
|
|
|
62
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub unshift_property { |
|
25
|
16
|
|
|
16
|
0
|
34
|
my( $self, $property ) = @_; |
|
26
|
16
|
|
|
|
|
24
|
unshift @{$self->{properties}}, $property; |
|
|
16
|
|
|
|
|
50
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub operator { |
|
30
|
32
|
|
|
32
|
0
|
71
|
my( $self, $operator ) = @_; |
|
31
|
32
|
|
|
|
|
62
|
my $previous_operator = $self->{operator}; |
|
32
|
32
|
100
|
|
|
|
107
|
$self->{operator} = $operator if defined $operator; |
|
33
|
32
|
|
|
|
|
82
|
return $previous_operator; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub values { |
|
37
|
48
|
|
|
48
|
0
|
87
|
my( $self, $values ) = @_; |
|
38
|
48
|
|
|
|
|
83
|
my $previous_values = $self->{values}; |
|
39
|
48
|
100
|
|
|
|
101
|
$self->{values} = $values if defined $values; |
|
40
|
48
|
|
|
|
|
149
|
return $previous_values; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub to_filter { |
|
44
|
16
|
|
|
16
|
0
|
2837
|
my( $self ) = @_; |
|
45
|
16
|
|
|
|
|
51
|
$self->validate; |
|
46
|
|
|
|
|
|
|
|
|
47
|
16
|
|
|
|
|
65
|
my @zip_list; |
|
48
|
16
|
|
|
|
|
26
|
foreach my $zip (@{$self->{values}}) { |
|
|
16
|
|
|
|
|
39
|
|
|
49
|
26
|
|
|
|
|
35
|
my @zip; |
|
50
|
26
|
|
|
|
|
60
|
for my $i (0..$#$zip) { |
|
51
|
58
|
|
|
|
|
70
|
my( $operator, $arg ) = @{$zip->[$i]}; |
|
|
58
|
|
|
|
|
122
|
|
|
52
|
58
|
100
|
66
|
|
|
155
|
if( blessed $arg && $arg->can( 'to_filter' ) ) { |
|
53
|
2
|
|
|
|
|
7
|
$arg = $arg->to_filter; |
|
54
|
|
|
|
|
|
|
} else { |
|
55
|
56
|
|
|
|
|
89
|
$arg =~ s/\\/\\\\/g; |
|
56
|
56
|
|
|
|
|
83
|
$arg =~ s/"/\\"/g; |
|
57
|
56
|
|
|
|
|
83
|
$arg = "\"$arg\""; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
58
|
|
|
|
|
117
|
push @zip, "$operator $arg"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
26
|
|
|
|
|
76
|
push @zip_list, join( ' : ', @zip ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
34
|
|
|
|
|
118
|
return '(' . join( ':', map { $_->to_filter } @{$self->{properties}} ) . |
|
|
16
|
|
|
|
|
39
|
|
|
65
|
16
|
|
|
|
|
32
|
' ' . $self->{operator} . ' ' . |
|
66
|
|
|
|
|
|
|
join( ', ', @zip_list ) . ')'; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub to_SQL |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
8
|
|
|
8
|
0
|
97
|
die "no SQL representation\n"; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub modify |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
77
|
0
|
|
|
|
|
0
|
my $code = shift; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
$self->{properties} = [ map { $_->modify( $code, @_ ) } @{$self->{properties}} ]; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
80
|
0
|
|
|
|
|
0
|
$self->{values} = [ map { [ OPTIMADE::Filter::Modifiable::modify( $_->[0], $code, @_ ), |
|
81
|
|
|
|
|
|
|
OPTIMADE::Filter::Modifiable::modify( $_->[1], $code, @_ ) ] } |
|
82
|
0
|
|
|
|
|
0
|
@{$self->{values}} ]; |
|
|
0
|
|
|
|
|
0
|
|
|
83
|
0
|
|
|
|
|
0
|
return $code->( $self, @_ ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub validate |
|
87
|
|
|
|
|
|
|
{ |
|
88
|
16
|
|
|
16
|
0
|
29
|
my $self = shift; |
|
89
|
|
|
|
|
|
|
|
|
90
|
16
|
50
|
|
|
|
48
|
if( !$self->{properties} ) { |
|
91
|
0
|
|
|
|
|
0
|
die 'properties undefined for OPTIMADE::Filter::Zip'; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
16
|
50
|
|
|
|
38
|
if( !$self->operator ) { |
|
94
|
0
|
|
|
|
|
0
|
die 'operator undefined for OPTIMADE::Filter::Zip'; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
16
|
50
|
|
|
|
39
|
if( !$self->values ) { |
|
97
|
0
|
|
|
|
|
0
|
die 'values undefined for OPTIMADE::Filter::Zip'; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
16
|
50
|
|
26
|
|
98
|
if( any { scalar @$_ != scalar @{$self->{properties}} } |
|
|
26
|
|
|
|
|
47
|
|
|
|
26
|
|
|
|
|
82
|
|
|
100
|
16
|
|
|
|
|
38
|
@{$self->values} ) { |
|
101
|
0
|
|
|
|
|
|
die 'different number of properties and values for OPTIMADE::Filter::Zip'; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |