| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CQL::ModifierSet; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
95
|
use strict; |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
364
|
|
|
4
|
10
|
|
|
10
|
|
53
|
use warnings; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
308
|
|
|
5
|
10
|
|
|
10
|
|
26157
|
use CQL::Utils qw( indent xq ); |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
875
|
|
|
6
|
10
|
|
|
10
|
|
64
|
use Carp qw( croak ); |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
8223
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
CQL::ModifierSet - represents a base string and modifier strings |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This class is used as a delegate by both CQLRelation and |
|
17
|
|
|
|
|
|
|
CQLProxNode - two functionally very separate classes that happen to |
|
18
|
|
|
|
|
|
|
require similar data structures and functionality. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
A ModifierSet consists of a ``base'' string together with a set of |
|
21
|
|
|
|
|
|
|
zero or more type=value pairs, where both type and value are strings. |
|
22
|
|
|
|
|
|
|
Types may be null, values may not. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new() |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Creates a new modifier set with the specified base. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
103
|
|
|
103
|
1
|
346
|
my ($class,$base) = @_; |
|
34
|
103
|
|
|
|
|
440
|
my $self = { base => $base, modifiers => [] }; |
|
35
|
103
|
|
33
|
|
|
830
|
return bless $self, ref($class) || $class; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 getBase() |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns the base string with which the modifier set was created. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub getBase { |
|
45
|
7
|
|
|
7
|
1
|
28
|
return shift->{base}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 addModifier() |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Adds a modifier of the specified type and value to a modifier set. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub addModifier { |
|
55
|
34
|
|
|
34
|
1
|
270
|
my ($self,$type,$value) = @_; |
|
56
|
34
|
|
|
|
|
45
|
push( @{ $self->{modifiers} }, [ $type => $value ] ); |
|
|
34
|
|
|
|
|
155
|
|
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 modifier() |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns a modifier with a given type, or null if a modifier of that |
|
62
|
|
|
|
|
|
|
type isn't present. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub modifier { |
|
67
|
40
|
|
|
40
|
1
|
65
|
my ($self,$type) = @_; |
|
68
|
40
|
|
|
|
|
48
|
foreach my $pair ( @{ $self->{modifiers} } ) { |
|
|
40
|
|
|
|
|
90
|
|
|
69
|
58
|
100
|
|
|
|
127
|
if ( $pair->[0] eq $type ) { return $pair->[1]; } |
|
|
19
|
|
|
|
|
59
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
21
|
|
|
|
|
57
|
return undef; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 getModifiers() |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns a list of modifiers each represented by a 2 element array ref. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub getModifiers { |
|
81
|
13
|
|
|
13
|
1
|
17
|
my $self = shift; |
|
82
|
13
|
|
|
|
|
17
|
return @{ $self->{modifiers} }; |
|
|
13
|
|
|
|
|
53
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 toCQL() |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub toCQL { |
|
90
|
47
|
|
|
47
|
1
|
64
|
my $self = shift; |
|
91
|
47
|
|
|
|
|
90
|
my $cql = $self->{base}; |
|
92
|
47
|
|
|
|
|
63
|
foreach ( @{ $self->{modifiers} } ) { |
|
|
47
|
|
|
|
|
117
|
|
|
93
|
24
|
|
|
|
|
117
|
$cql .= "/" . $_->[1]; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
47
|
|
|
|
|
194
|
return $cql; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 toSwish() |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub toSwish { |
|
103
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
|
104
|
2
|
|
|
|
|
8
|
croak( "Swish does not support relational modifiers" ) |
|
105
|
2
|
50
|
|
|
|
2
|
if @{ $self->{modifiers} } > 0; |
|
106
|
2
|
|
|
|
|
6
|
my $base = $self->getBase(); |
|
107
|
2
|
100
|
66
|
|
|
28
|
return $base if $base eq "=" or $base eq "not"; |
|
108
|
1
|
|
|
|
|
25
|
croak( "Swish doesn't support relations other than = and not" ); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 toXCQL() |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub toXCQL { |
|
116
|
2
|
|
|
2
|
1
|
5
|
my ($self, $level, $topLevelElement) = @_; |
|
117
|
2
|
|
|
|
|
8
|
my $buffer = |
|
118
|
|
|
|
|
|
|
indent($level).'<'.$topLevelElement.">\n". |
|
119
|
|
|
|
|
|
|
indent($level+1)."".xq($self->{base})."\n"; |
|
120
|
2
|
|
|
|
|
8
|
my @modifiers = $self->getModifiers(); |
|
121
|
2
|
50
|
|
|
|
10
|
if ( @modifiers > 0 ) { |
|
122
|
0
|
|
|
|
|
0
|
$buffer .= indent($level+1)."\n"; |
|
123
|
0
|
|
|
|
|
0
|
foreach my $m ( @modifiers ) { |
|
124
|
0
|
|
|
|
|
0
|
$buffer .= indent($level+2).""; |
|
125
|
0
|
0
|
|
|
|
0
|
$buffer .= "".xq($m->[0])."" if $m->[0]; |
|
126
|
0
|
|
|
|
|
0
|
$buffer .= "".xq($m->[1])."\n" |
|
127
|
|
|
|
|
|
|
} |
|
128
|
0
|
|
|
|
|
0
|
$buffer .= indent($level+1)."\n"; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
2
|
|
|
|
|
7
|
$buffer .= indent($level).''.$topLevelElement.">\n"; |
|
131
|
2
|
|
|
|
|
8
|
return $buffer; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |