line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim:ts=4 sw=4
|
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
3
|
|
|
|
|
|
|
# Name : Class::STL::Utilities.pm
|
4
|
|
|
|
|
|
|
# Created : 22 February 2006
|
5
|
|
|
|
|
|
|
# Author : Mario Gaffiero (gaffie)
|
6
|
|
|
|
|
|
|
#
|
7
|
|
|
|
|
|
|
# Copyright 2006-2007 Mario Gaffiero.
|
8
|
|
|
|
|
|
|
#
|
9
|
|
|
|
|
|
|
# This file is part of Class::STL::Containers(TM).
|
10
|
|
|
|
|
|
|
#
|
11
|
|
|
|
|
|
|
# Class::STL::Containers is free software; you can redistribute it and/or modify
|
12
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
13
|
|
|
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
14
|
|
|
|
|
|
|
#
|
15
|
|
|
|
|
|
|
# Class::STL::Containers is distributed in the hope that it will be useful,
|
16
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
|
|
|
|
|
|
# GNU General Public License for more details.
|
19
|
|
|
|
|
|
|
#
|
20
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
21
|
|
|
|
|
|
|
# along with Class::STL::Containers; if not, write to the Free Software
|
22
|
|
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
23
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
24
|
|
|
|
|
|
|
# Modification History
|
25
|
|
|
|
|
|
|
# When Version Who What
|
26
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
27
|
|
|
|
|
|
|
# TO DO:
|
28
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
29
|
|
|
|
|
|
|
package Class::STL::Utilities;
|
30
|
|
|
|
|
|
|
require 5.005_62;
|
31
|
7
|
|
|
7
|
|
49
|
use strict;
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
314
|
|
32
|
7
|
|
|
7
|
|
42
|
use warnings;
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
273
|
|
33
|
7
|
|
|
7
|
|
43
|
use vars qw( $VERSION $BUILD @EXPORT_OK %EXPORT_TAGS );
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
615
|
|
34
|
7
|
|
|
7
|
|
37
|
use Exporter;
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
926
|
|
35
|
|
|
|
|
|
|
my @export_names = qw(
|
36
|
|
|
|
|
|
|
equal_to not_equal_to greater greater_equal less less_equal compare bind1st bind2nd
|
37
|
|
|
|
|
|
|
mem_fun ptr_fun ptr_fun_binary matches matches_ic logical_and logical_or
|
38
|
|
|
|
|
|
|
multiplies divides plus minus modulus not1 not2 negate not_null
|
39
|
|
|
|
|
|
|
);
|
40
|
|
|
|
|
|
|
@EXPORT_OK = (@export_names);
|
41
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => [@export_names] );
|
42
|
|
|
|
|
|
|
$VERSION = '0.18';
|
43
|
|
|
|
|
|
|
$BUILD = 'Thursday April 27 23:08:34 GMT 2006';
|
44
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
45
|
|
|
|
|
|
|
{
|
46
|
|
|
|
|
|
|
package Class::STL::Utilities;
|
47
|
7
|
|
|
7
|
|
45
|
use vars qw( $AUTOLOAD );
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4639
|
|
48
|
|
|
|
|
|
|
sub AUTOLOAD
|
49
|
|
|
|
|
|
|
{
|
50
|
0
|
|
|
0
|
|
|
(my $func = $AUTOLOAD) =~ s/.*:://;
|
51
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::EqualTo->new(@_) if ($func eq 'equal_to');
|
52
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::NotEqualTo->new(@_) if ($func eq 'not_equal_to');
|
53
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Greater->new(@_) if ($func eq 'greater');
|
54
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::GreaterEqual->new(@_) if ($func eq 'greater_equal');
|
55
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Less->new(@_) if ($func eq 'less');
|
56
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::LessEqual->new(@_) if ($func eq 'less_equal');
|
57
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Compare->new(@_) if ($func eq 'compare');
|
58
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Matches->new(@_) if ($func eq 'matches');
|
59
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::MatchesIC->new(@_) if ($func eq 'matches_ic');
|
60
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::LogicalAnd->new(@_) if ($func eq 'logical_and');
|
61
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::LogicalOr->new(@_) if ($func eq 'logical_or');
|
62
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Multiplies->new(@_) if ($func eq 'multiplies');
|
63
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Divides->new(@_) if ($func eq 'divides');
|
64
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Plus->new(@_) if ($func eq 'plus');
|
65
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Minus->new(@_) if ($func eq 'minus');
|
66
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Modulus->new(@_) if ($func eq 'modulus');
|
67
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Binder1st->new(@_) if ($func eq 'bind1st');
|
68
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Binder2nd->new(@_) if ($func eq 'bind2nd');
|
69
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::MemberFunction->new(@_) if ($func eq 'mem_fun');
|
70
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::PointerToUnaryFunction->new(@_)if ($func eq 'ptr_fun');
|
71
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::PointerToBinaryFunction->new(@_)if ($func eq 'ptr_fun_binary');
|
72
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::UnaryNegate->new(@_) if ($func eq 'not1');
|
73
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::BinaryNegate->new(@_) if ($func eq 'not2');
|
74
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::Negate->new(@_) if ($func eq 'negate');
|
75
|
0
|
0
|
|
|
|
|
return Class::STL::Utilities::NotNull->new(@_) if ($func eq 'not_null');
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
79
|
|
|
|
|
|
|
{
|
80
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject;
|
81
|
7
|
|
|
7
|
|
52
|
use Class::STL::ClassMembers qw(result_type);
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
76
|
|
82
|
7
|
|
|
7
|
|
49
|
use Class::STL::ClassMembers::Constructor;
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
78
|
|
83
|
|
|
|
|
|
|
sub function_operator
|
84
|
|
|
|
|
|
|
{
|
85
|
0
|
|
|
0
|
|
|
my $self = shift;
|
86
|
7
|
|
|
7
|
|
44
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
1390
|
|
87
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
91
|
|
|
|
|
|
|
{
|
92
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject::Generator;
|
93
|
7
|
|
|
7
|
|
44
|
use base qw(Class::STL::Utilities::FunctionObject);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
9800
|
|
94
|
|
|
|
|
|
|
sub function_operator
|
95
|
|
|
|
|
|
|
{
|
96
|
0
|
|
|
0
|
|
|
my $self = shift;
|
97
|
7
|
|
|
7
|
|
60
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
819
|
|
98
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
102
|
|
|
|
|
|
|
{
|
103
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject::UnaryFunction;
|
104
|
7
|
|
|
7
|
|
41
|
use base qw(Class::STL::Utilities::FunctionObject);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3420
|
|
105
|
|
|
|
|
|
|
sub function_operator
|
106
|
|
|
|
|
|
|
{
|
107
|
0
|
|
|
0
|
|
|
my $self = shift;
|
108
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
109
|
7
|
|
|
7
|
|
45
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
933
|
|
110
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
114
|
|
|
|
|
|
|
{
|
115
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject::BinaryFunction;
|
116
|
7
|
|
|
7
|
|
39
|
use base qw(Class::STL::Utilities::FunctionObject);
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
3199
|
|
117
|
|
|
|
|
|
|
sub function_operator
|
118
|
|
|
|
|
|
|
{
|
119
|
0
|
|
|
0
|
|
|
my $self = shift;
|
120
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
121
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
122
|
7
|
|
|
7
|
|
44
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
737
|
|
123
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
127
|
|
|
|
|
|
|
{
|
128
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject::UnaryPredicate;
|
129
|
7
|
|
|
7
|
|
37
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
3716
|
|
130
|
|
|
|
|
|
|
sub new_extra
|
131
|
|
|
|
|
|
|
{
|
132
|
0
|
|
|
0
|
|
|
my $self = shift;
|
133
|
0
|
|
|
|
|
|
$self->result_type('bool');
|
134
|
0
|
|
|
|
|
|
return $self;
|
135
|
|
|
|
|
|
|
}
|
136
|
|
|
|
|
|
|
sub function_operator
|
137
|
|
|
|
|
|
|
{
|
138
|
0
|
|
|
0
|
|
|
my $self = shift;
|
139
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
140
|
7
|
|
|
7
|
|
45
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
32
|
|
|
7
|
|
|
|
|
733
|
|
141
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
}
|
144
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
145
|
|
|
|
|
|
|
{
|
146
|
|
|
|
|
|
|
package Class::STL::Utilities::FunctionObject::BinaryPredicate;
|
147
|
7
|
|
|
7
|
|
35
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3744
|
|
148
|
|
|
|
|
|
|
sub new_extra
|
149
|
|
|
|
|
|
|
{
|
150
|
0
|
|
|
0
|
|
|
my $self = shift;
|
151
|
0
|
|
|
|
|
|
$self->result_type('bool');
|
152
|
0
|
|
|
|
|
|
return $self;
|
153
|
|
|
|
|
|
|
}
|
154
|
|
|
|
|
|
|
sub function_operator
|
155
|
|
|
|
|
|
|
{
|
156
|
0
|
|
|
0
|
|
|
my $self = shift;
|
157
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
158
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
159
|
7
|
|
|
7
|
|
48
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
1019
|
|
160
|
0
|
|
|
|
|
|
confess "@{[ __PACKAGE__ ]} abstract class must be derived!\n";
|
|
0
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
}
|
162
|
|
|
|
|
|
|
}
|
163
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
164
|
|
|
|
|
|
|
{
|
165
|
|
|
|
|
|
|
package Class::STL::Utilities::MemberFunction;
|
166
|
7
|
|
|
7
|
|
41
|
use base qw(Class::STL::Utilities::FunctionObject);
|
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
13361
|
|
167
|
7
|
|
|
7
|
|
148
|
use Class::STL::ClassMembers qw(function_name);
|
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
65
|
|
168
|
|
|
|
|
|
|
sub new
|
169
|
|
|
|
|
|
|
{
|
170
|
0
|
|
|
0
|
|
|
my $self = shift;
|
171
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
172
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
173
|
0
|
|
|
|
|
|
bless($self, $class);
|
174
|
0
|
|
|
|
|
|
$self->members_init(function_name => shift);
|
175
|
0
|
|
|
|
|
|
return $self;
|
176
|
|
|
|
|
|
|
}
|
177
|
|
|
|
|
|
|
sub function_operator
|
178
|
|
|
|
|
|
|
{
|
179
|
0
|
|
|
0
|
|
|
my $self = shift;
|
180
|
0
|
|
|
|
|
|
my $element = shift;
|
181
|
0
|
|
|
|
|
|
my $fname = $self->function_name();
|
182
|
0
|
|
|
|
|
|
return $element->$fname(@_);
|
183
|
|
|
|
|
|
|
}
|
184
|
|
|
|
|
|
|
}
|
185
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
186
|
|
|
|
|
|
|
{
|
187
|
|
|
|
|
|
|
package Class::STL::Utilities::PointerToUnaryFunction;
|
188
|
7
|
|
|
7
|
|
44
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
4003
|
|
189
|
7
|
|
|
7
|
|
44
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
495
|
|
190
|
7
|
|
|
7
|
|
464
|
use Class::STL::ClassMembers qw(function_name);
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
48
|
|
191
|
|
|
|
|
|
|
sub new
|
192
|
|
|
|
|
|
|
{
|
193
|
0
|
|
|
0
|
|
|
my $self = shift;
|
194
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
195
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
196
|
0
|
|
|
|
|
|
bless($self, $class);
|
197
|
0
|
|
|
|
|
|
$self->members_init(function_name => shift);
|
198
|
0
|
|
|
|
|
|
return $self->factory();
|
199
|
|
|
|
|
|
|
}
|
200
|
|
|
|
|
|
|
sub factory
|
201
|
|
|
|
|
|
|
{
|
202
|
0
|
|
|
0
|
|
|
my $self = shift;
|
203
|
0
|
|
|
|
|
|
our %__dynfun;
|
204
|
0
|
0
|
|
|
|
|
if (!exists($__dynfun{$self->function_name()}))
|
205
|
|
|
|
|
|
|
{
|
206
|
0
|
|
|
|
|
|
$__dynfun{$self->function_name()} = eval("
|
207
|
|
|
|
|
|
|
{
|
208
|
0
|
|
|
|
|
|
package Class::STL::Utilities::PointerToUnaryFunction::__@{[ $self->function_name() ]};
|
|
0
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
210
|
|
|
|
|
|
|
sub function_operator
|
211
|
|
|
|
|
|
|
{
|
212
|
|
|
|
|
|
|
my \$self = shift;
|
213
|
|
|
|
|
|
|
my \$arg = shift;
|
214
|
|
|
|
|
|
|
my \$tmp;
|
215
|
|
|
|
|
|
|
if (ref(\$arg) && \$arg->isa('Class::STL::Element'))
|
216
|
|
|
|
|
|
|
{
|
217
|
|
|
|
|
|
|
\$tmp = \$arg->clone();
|
218
|
0
|
|
|
|
|
|
\$tmp->data(@{[ $self->function_name() ]}(\$tmp->data()));
|
219
|
|
|
|
|
|
|
}
|
220
|
|
|
|
|
|
|
return \$tmp;
|
221
|
|
|
|
|
|
|
}
|
222
|
|
|
|
|
|
|
}
|
223
|
|
|
|
|
|
|
Class::STL::Utilities::PointerToUnaryFunction::__@{[ $self->function_name() ]}->new();
|
224
|
|
|
|
|
|
|
");
|
225
|
0
|
0
|
|
|
|
|
confess "**Error in eval for @{[ __PACKAGE__ ]} ptr_fun dynamic class creation:\n$@" if ($@);
|
|
0
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
}
|
227
|
0
|
|
|
|
|
|
return $__dynfun{$self->function_name()};
|
228
|
|
|
|
|
|
|
}
|
229
|
|
|
|
|
|
|
}
|
230
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
231
|
|
|
|
|
|
|
{
|
232
|
|
|
|
|
|
|
package Class::STL::Utilities::PointerToBinaryFunction;
|
233
|
7
|
|
|
7
|
|
48
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4972
|
|
234
|
7
|
|
|
7
|
|
49
|
use Carp qw(confess);
|
|
7
|
|
|
|
|
175
|
|
|
7
|
|
|
|
|
474
|
|
235
|
7
|
|
|
7
|
|
45
|
use Class::STL::ClassMembers qw(function_name);
|
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
47
|
|
236
|
|
|
|
|
|
|
sub new
|
237
|
|
|
|
|
|
|
{
|
238
|
0
|
|
|
0
|
|
|
my $self = shift;
|
239
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
240
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
241
|
0
|
|
|
|
|
|
bless($self, $class);
|
242
|
0
|
|
|
|
|
|
$self->members_init(function_name => shift);
|
243
|
0
|
|
|
|
|
|
return $self->factory();
|
244
|
|
|
|
|
|
|
}
|
245
|
|
|
|
|
|
|
sub factory
|
246
|
|
|
|
|
|
|
{
|
247
|
0
|
|
|
0
|
|
|
my $self = shift;
|
248
|
0
|
|
|
|
|
|
our %__dynfun;
|
249
|
0
|
0
|
|
|
|
|
if (!exists($__dynfun{$self->function_name()}))
|
250
|
|
|
|
|
|
|
{
|
251
|
0
|
|
|
|
|
|
$__dynfun{$self->function_name()} = eval("
|
252
|
|
|
|
|
|
|
{
|
253
|
0
|
|
|
|
|
|
package Class::STL::Utilities::PointerToBinaryFunction::__@{[ $self->function_name() ]};
|
|
0
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
255
|
|
|
|
|
|
|
sub function_operator
|
256
|
|
|
|
|
|
|
{
|
257
|
|
|
|
|
|
|
my \$self = shift;
|
258
|
|
|
|
|
|
|
my \$arg1 = shift;
|
259
|
|
|
|
|
|
|
my \$arg2 = shift;
|
260
|
|
|
|
|
|
|
my \$tmp;
|
261
|
|
|
|
|
|
|
if (ref(\$arg1) && \$arg1->isa('Class::STL::Element') && ref(\$arg2) && \$arg2->isa('Class::STL::Element'))
|
262
|
|
|
|
|
|
|
{
|
263
|
|
|
|
|
|
|
\$tmp = \$arg1->clone();
|
264
|
0
|
|
|
|
|
|
\$tmp->data(@{[ $self->function_name() ]}(\$arg1->data(), \$arg2->data()));
|
265
|
|
|
|
|
|
|
}
|
266
|
|
|
|
|
|
|
elsif (ref(\$arg2) && \$arg2->isa('Class::STL::Element'))
|
267
|
|
|
|
|
|
|
{
|
268
|
|
|
|
|
|
|
\$tmp = \$arg2->clone();
|
269
|
0
|
|
|
|
|
|
\$tmp->data(@{[ $self->function_name() ]}(\$arg1, \$arg2->data()));
|
270
|
|
|
|
|
|
|
}
|
271
|
|
|
|
|
|
|
elsif (ref(\$arg1) && \$arg1->isa('Class::STL::Element'))
|
272
|
|
|
|
|
|
|
{
|
273
|
|
|
|
|
|
|
\$tmp = \$arg1->clone();
|
274
|
0
|
|
|
|
|
|
\$tmp->data(@{[ $self->function_name() ]}(\$arg1->data(), \$arg2));
|
275
|
|
|
|
|
|
|
}
|
276
|
|
|
|
|
|
|
return \$tmp;
|
277
|
|
|
|
|
|
|
}
|
278
|
|
|
|
|
|
|
}
|
279
|
|
|
|
|
|
|
Class::STL::Utilities::PointerToBinaryFunction::__@{[ $self->function_name() ]}->new();
|
280
|
|
|
|
|
|
|
");
|
281
|
0
|
0
|
|
|
|
|
confess "**Error in eval for @{[ __PACKAGE__ ]} ptr_fun_binary dynamic class creation:\n$@" if ($@);
|
|
0
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
}
|
283
|
0
|
|
|
|
|
|
return $__dynfun{$self->function_name()};
|
284
|
|
|
|
|
|
|
}
|
285
|
|
|
|
|
|
|
}
|
286
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
287
|
|
|
|
|
|
|
{
|
288
|
|
|
|
|
|
|
package Class::STL::Utilities::UnaryNegate;
|
289
|
7
|
|
|
7
|
|
47
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryPredicate);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
4071
|
|
290
|
7
|
|
|
7
|
|
50
|
use Class::STL::ClassMembers qw(predicate);
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
45
|
|
291
|
|
|
|
|
|
|
sub new
|
292
|
|
|
|
|
|
|
{
|
293
|
0
|
|
|
0
|
|
|
my $self = shift;
|
294
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
295
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
296
|
0
|
|
|
|
|
|
bless($self, $class);
|
297
|
0
|
|
|
|
|
|
$self->members_init(predicate => shift);
|
298
|
0
|
|
|
|
|
|
return $self;
|
299
|
|
|
|
|
|
|
}
|
300
|
|
|
|
|
|
|
sub function_operator
|
301
|
|
|
|
|
|
|
{
|
302
|
0
|
|
|
0
|
|
|
my $self = shift;
|
303
|
0
|
|
|
|
|
|
my $arg = shift;
|
304
|
0
|
|
|
|
|
|
return !($self->predicate()->function_operator($arg));
|
305
|
|
|
|
|
|
|
}
|
306
|
|
|
|
|
|
|
}
|
307
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
308
|
|
|
|
|
|
|
{
|
309
|
|
|
|
|
|
|
package Class::STL::Utilities::BinaryNegate;
|
310
|
7
|
|
|
7
|
|
80
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4120
|
|
311
|
7
|
|
|
7
|
|
49
|
use Class::STL::ClassMembers qw(predicate);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
41
|
|
312
|
|
|
|
|
|
|
sub new
|
313
|
|
|
|
|
|
|
{
|
314
|
0
|
|
|
0
|
|
|
my $self = shift;
|
315
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
316
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
317
|
0
|
|
|
|
|
|
bless($self, $class);
|
318
|
0
|
|
|
|
|
|
$self->members_init(predicate => shift);
|
319
|
0
|
|
|
|
|
|
return $self;
|
320
|
|
|
|
|
|
|
}
|
321
|
|
|
|
|
|
|
sub function_operator
|
322
|
|
|
|
|
|
|
{
|
323
|
0
|
|
|
0
|
|
|
my $self = shift;
|
324
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
325
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
326
|
0
|
|
|
|
|
|
return !($self->predicate()->function_operator($arg1, $arg2));
|
327
|
|
|
|
|
|
|
}
|
328
|
|
|
|
|
|
|
}
|
329
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
330
|
|
|
|
|
|
|
{
|
331
|
|
|
|
|
|
|
package Class::STL::Utilities::Binder1st;
|
332
|
7
|
|
|
7
|
|
41
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
3854
|
|
333
|
7
|
|
|
7
|
|
48
|
use Class::STL::ClassMembers qw(operation first_argument);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
42
|
|
334
|
|
|
|
|
|
|
sub new
|
335
|
|
|
|
|
|
|
{
|
336
|
0
|
|
|
0
|
|
|
my $self = shift;
|
337
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
338
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
339
|
0
|
|
|
|
|
|
bless($self, $class);
|
340
|
0
|
|
|
|
|
|
$self->members_init(operation => shift, first_argument => shift);
|
341
|
0
|
|
|
|
|
|
return $self;
|
342
|
|
|
|
|
|
|
}
|
343
|
|
|
|
|
|
|
sub function_operator
|
344
|
|
|
|
|
|
|
{
|
345
|
0
|
|
|
0
|
|
|
my $self = shift;
|
346
|
0
|
|
|
|
|
|
my $arg = shift; # element object
|
347
|
0
|
|
|
|
|
|
return $self->operation()->function_operator($self->first_argument(), $arg);
|
348
|
|
|
|
|
|
|
}
|
349
|
|
|
|
|
|
|
}
|
350
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
351
|
|
|
|
|
|
|
{
|
352
|
|
|
|
|
|
|
package Class::STL::Utilities::Binder2nd;
|
353
|
7
|
|
|
7
|
|
46
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
3489
|
|
354
|
7
|
|
|
7
|
|
58
|
use Class::STL::ClassMembers qw(operation second_argument);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
47
|
|
355
|
|
|
|
|
|
|
sub new
|
356
|
|
|
|
|
|
|
{
|
357
|
0
|
|
|
0
|
|
|
my $self = shift;
|
358
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self;
|
359
|
0
|
|
|
|
|
|
$self = $class->SUPER::new();
|
360
|
0
|
|
|
|
|
|
bless($self, $class);
|
361
|
0
|
|
|
|
|
|
$self->members_init(operation => shift, second_argument => shift);
|
362
|
0
|
|
|
|
|
|
return $self;
|
363
|
|
|
|
|
|
|
}
|
364
|
|
|
|
|
|
|
sub function_operator
|
365
|
|
|
|
|
|
|
{
|
366
|
0
|
|
|
0
|
|
|
my $self = shift;
|
367
|
0
|
|
|
|
|
|
my $arg = shift; # element object
|
368
|
0
|
|
|
|
|
|
return $self->operation()->function_operator($arg, $self->second_argument());
|
369
|
|
|
|
|
|
|
}
|
370
|
|
|
|
|
|
|
}
|
371
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
372
|
|
|
|
|
|
|
{
|
373
|
|
|
|
|
|
|
package Class::STL::Utilities::EqualTo;
|
374
|
7
|
|
|
7
|
|
243
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
5282
|
|
375
|
|
|
|
|
|
|
sub function_operator
|
376
|
|
|
|
|
|
|
{
|
377
|
0
|
|
|
0
|
|
|
my $self = shift;
|
378
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
379
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
380
|
|
|
|
|
|
|
return
|
381
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
382
|
|
|
|
|
|
|
? $arg1->eq($arg2)
|
383
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
384
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 eq $arg2->data() : $arg1 == $arg2->data()
|
385
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
386
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() eq $arg2 : $arg1->data() == $arg2
|
387
|
|
|
|
|
|
|
: $arg1 == $arg2;
|
388
|
|
|
|
|
|
|
}
|
389
|
|
|
|
|
|
|
}
|
390
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
391
|
|
|
|
|
|
|
{
|
392
|
|
|
|
|
|
|
package Class::STL::Utilities::NotEqualTo;
|
393
|
7
|
|
|
7
|
|
61
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
4286
|
|
394
|
|
|
|
|
|
|
sub function_operator
|
395
|
|
|
|
|
|
|
{
|
396
|
0
|
|
|
0
|
|
|
my $self = shift;
|
397
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
398
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
399
|
|
|
|
|
|
|
return
|
400
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
401
|
|
|
|
|
|
|
? $arg1->ne($arg2)
|
402
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
403
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 ne $arg2->data() : $arg1 != $arg2->data()
|
404
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
405
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() ne $arg2 : $arg1->data() != $arg2
|
406
|
|
|
|
|
|
|
: $arg1 != $arg2;
|
407
|
|
|
|
|
|
|
}
|
408
|
|
|
|
|
|
|
}
|
409
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
410
|
|
|
|
|
|
|
{
|
411
|
|
|
|
|
|
|
package Class::STL::Utilities::NotNull;
|
412
|
7
|
|
|
7
|
|
49
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryPredicate);
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
3805
|
|
413
|
|
|
|
|
|
|
sub function_operator
|
414
|
|
|
|
|
|
|
{
|
415
|
0
|
|
|
0
|
|
|
my $self = shift;
|
416
|
0
|
|
|
|
|
|
my $arg = shift;
|
417
|
0
|
|
0
|
|
|
|
return defined($arg) && (ref($arg) || $arg != 0);
|
418
|
|
|
|
|
|
|
}
|
419
|
|
|
|
|
|
|
}
|
420
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
421
|
|
|
|
|
|
|
{
|
422
|
|
|
|
|
|
|
package Class::STL::Utilities::Greater;
|
423
|
7
|
|
|
7
|
|
47
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4901
|
|
424
|
|
|
|
|
|
|
sub function_operator
|
425
|
|
|
|
|
|
|
{
|
426
|
0
|
|
|
0
|
|
|
my $self = shift;
|
427
|
0
|
|
|
|
|
|
my $arg1 = shift; # element or scalar
|
428
|
0
|
|
|
|
|
|
my $arg2 = shift; # element or scalar
|
429
|
|
|
|
|
|
|
return
|
430
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
431
|
|
|
|
|
|
|
? $arg1->gt($arg2)
|
432
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
433
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 gt $arg2->data() : $arg1 > $arg2->data()
|
434
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
435
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() gt $arg2 : $arg1->data() > $arg2
|
436
|
|
|
|
|
|
|
: $arg1 > $arg2;
|
437
|
|
|
|
|
|
|
}
|
438
|
|
|
|
|
|
|
}
|
439
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
440
|
|
|
|
|
|
|
{
|
441
|
|
|
|
|
|
|
package Class::STL::Utilities::GreaterEqual;
|
442
|
7
|
|
|
7
|
|
93
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
4380
|
|
443
|
|
|
|
|
|
|
sub function_operator
|
444
|
|
|
|
|
|
|
{
|
445
|
0
|
|
|
0
|
|
|
my $self = shift;
|
446
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
447
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
448
|
|
|
|
|
|
|
return
|
449
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
450
|
|
|
|
|
|
|
? $arg1->ge($arg2)
|
451
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
452
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 ge $arg2->data() : $arg1 >= $arg2->data()
|
453
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
454
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() ge $arg2 : $arg1->data() >= $arg2
|
455
|
|
|
|
|
|
|
: $arg1 >= $arg2;
|
456
|
|
|
|
|
|
|
}
|
457
|
|
|
|
|
|
|
}
|
458
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
459
|
|
|
|
|
|
|
{
|
460
|
|
|
|
|
|
|
package Class::STL::Utilities::Less;
|
461
|
7
|
|
|
7
|
|
54
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
4542
|
|
462
|
|
|
|
|
|
|
sub function_operator
|
463
|
|
|
|
|
|
|
{
|
464
|
0
|
|
|
0
|
|
|
my $self = shift;
|
465
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
466
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
467
|
|
|
|
|
|
|
return
|
468
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
469
|
|
|
|
|
|
|
? $arg1->lt($arg2)
|
470
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
471
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 lt $arg2->data() : $arg1 < $arg2->data()
|
472
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
473
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() lt $arg2 : $arg1->data() < $arg2
|
474
|
|
|
|
|
|
|
: $arg1 < $arg2;
|
475
|
|
|
|
|
|
|
}
|
476
|
|
|
|
|
|
|
}
|
477
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
478
|
|
|
|
|
|
|
{
|
479
|
|
|
|
|
|
|
package Class::STL::Utilities::LessEqual;
|
480
|
7
|
|
|
7
|
|
68
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
32
|
|
|
7
|
|
|
|
|
4377
|
|
481
|
|
|
|
|
|
|
sub function_operator
|
482
|
|
|
|
|
|
|
{
|
483
|
0
|
|
|
0
|
|
|
my $self = shift;
|
484
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
485
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
486
|
|
|
|
|
|
|
return
|
487
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
488
|
|
|
|
|
|
|
? $arg1->le($arg2)
|
489
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
490
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 le $arg2->data() : $arg1 <= $arg2->data()
|
491
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
492
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() le $arg2 : $arg1->data() <= $arg2
|
493
|
|
|
|
|
|
|
: $arg1 <= $arg2;
|
494
|
|
|
|
|
|
|
}
|
495
|
|
|
|
|
|
|
}
|
496
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
497
|
|
|
|
|
|
|
{
|
498
|
|
|
|
|
|
|
package Class::STL::Utilities::Compare;
|
499
|
7
|
|
|
7
|
|
49
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
5805
|
|
500
|
|
|
|
|
|
|
sub function_operator
|
501
|
|
|
|
|
|
|
{
|
502
|
0
|
|
|
0
|
|
|
my $self = shift;
|
503
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
504
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
505
|
|
|
|
|
|
|
return
|
506
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
507
|
|
|
|
|
|
|
? $arg1->cmp($arg2)
|
508
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
509
|
|
|
|
|
|
|
? ($arg2->data_type() eq 'string') ? $arg1 cmp $arg2->data() : $arg1 <=> $arg2->data()
|
510
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
511
|
|
|
|
|
|
|
? ($arg1->data_type() eq 'string') ? $arg1->data() cmp $arg2 : $arg1->data() <=> $arg2
|
512
|
|
|
|
|
|
|
: $arg1 <=> $arg2;
|
513
|
|
|
|
|
|
|
}
|
514
|
|
|
|
|
|
|
}
|
515
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
516
|
|
|
|
|
|
|
{
|
517
|
|
|
|
|
|
|
package Class::STL::Utilities::LogicalAnd;
|
518
|
7
|
|
|
7
|
|
66
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
4264
|
|
519
|
|
|
|
|
|
|
sub function_operator
|
520
|
|
|
|
|
|
|
{
|
521
|
0
|
|
|
0
|
|
|
my $self = shift;
|
522
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
523
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
524
|
|
|
|
|
|
|
return
|
525
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
526
|
|
|
|
|
|
|
? $arg1->and($arg2)
|
527
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
528
|
|
|
|
|
|
|
? $arg1 && $arg2->data()
|
529
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
530
|
|
|
|
|
|
|
? $arg1->data() && $arg2
|
531
|
|
|
|
|
|
|
: $arg1 && $arg2;
|
532
|
|
|
|
|
|
|
}
|
533
|
|
|
|
|
|
|
}
|
534
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
535
|
|
|
|
|
|
|
{
|
536
|
|
|
|
|
|
|
package Class::STL::Utilities::LogicalOr;
|
537
|
7
|
|
|
7
|
|
55
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
4125
|
|
538
|
|
|
|
|
|
|
sub function_operator
|
539
|
|
|
|
|
|
|
{
|
540
|
0
|
|
|
0
|
|
|
my $self = shift;
|
541
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
542
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
543
|
|
|
|
|
|
|
return
|
544
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
545
|
|
|
|
|
|
|
? $arg1->or($arg2)
|
546
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
547
|
|
|
|
|
|
|
? $arg1 || $arg2->data()
|
548
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
549
|
|
|
|
|
|
|
? $arg1->data() || $arg2
|
550
|
|
|
|
|
|
|
: $arg1 || $arg2;
|
551
|
|
|
|
|
|
|
}
|
552
|
|
|
|
|
|
|
}
|
553
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
554
|
|
|
|
|
|
|
{
|
555
|
|
|
|
|
|
|
package Class::STL::Utilities::Matches;
|
556
|
7
|
|
|
7
|
|
50
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
4541
|
|
557
|
|
|
|
|
|
|
sub function_operator
|
558
|
|
|
|
|
|
|
{
|
559
|
0
|
|
|
0
|
|
|
my $self = shift;
|
560
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
561
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
562
|
|
|
|
|
|
|
return
|
563
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
564
|
|
|
|
|
|
|
? $arg1->match($arg2)
|
565
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
566
|
0
|
|
|
|
|
|
? $arg1 =~ /@{[ $arg2->data() ]}/
|
567
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
568
|
0
|
|
|
|
|
|
? $arg1->data() =~ /@{[ $arg2 ]}/
|
569
|
|
|
|
|
|
|
: $arg1 =~ /$arg2/;
|
570
|
|
|
|
|
|
|
}
|
571
|
|
|
|
|
|
|
}
|
572
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
573
|
|
|
|
|
|
|
{
|
574
|
|
|
|
|
|
|
package Class::STL::Utilities::MatchesIC;
|
575
|
7
|
|
|
7
|
|
59
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryPredicate);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
4502
|
|
576
|
|
|
|
|
|
|
sub function_operator
|
577
|
|
|
|
|
|
|
{
|
578
|
0
|
|
|
0
|
|
|
my $self = shift;
|
579
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
580
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
581
|
|
|
|
|
|
|
return
|
582
|
0
|
0
|
0
|
|
|
|
(ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
583
|
|
|
|
|
|
|
? $arg1->match_ic($arg2)
|
584
|
|
|
|
|
|
|
: (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
585
|
0
|
|
|
|
|
|
? $arg1 =~ /@{[ $arg2->data() ]}/i
|
586
|
|
|
|
|
|
|
: (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
587
|
0
|
|
|
|
|
|
? $arg1->data() =~ /@{[ $arg2 ]}/i
|
588
|
|
|
|
|
|
|
: $arg1 =~ /$arg2/i;
|
589
|
|
|
|
|
|
|
}
|
590
|
|
|
|
|
|
|
}
|
591
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
592
|
|
|
|
|
|
|
{
|
593
|
|
|
|
|
|
|
package Class::STL::Utilities::Multiplies;
|
594
|
7
|
|
|
7
|
|
47
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
6366
|
|
595
|
|
|
|
|
|
|
sub function_operator
|
596
|
|
|
|
|
|
|
{
|
597
|
0
|
|
|
0
|
|
|
my $self = shift;
|
598
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
599
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
600
|
0
|
|
|
|
|
|
my $tmp;
|
601
|
0
|
0
|
0
|
|
|
|
if (ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
602
|
|
|
|
|
|
|
{
|
603
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
604
|
0
|
|
|
|
|
|
$tmp->mult($arg2);
|
605
|
|
|
|
|
|
|
}
|
606
|
|
|
|
|
|
|
elsif (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
607
|
|
|
|
|
|
|
{
|
608
|
0
|
|
|
|
|
|
$tmp = $arg2->clone();
|
609
|
0
|
|
|
|
|
|
$tmp->data($tmp->data() * $arg1);
|
610
|
|
|
|
|
|
|
}
|
611
|
|
|
|
|
|
|
elsif (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
612
|
|
|
|
|
|
|
{
|
613
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
614
|
0
|
|
|
|
|
|
$tmp->data($tmp->data() * $arg2);
|
615
|
|
|
|
|
|
|
}
|
616
|
0
|
|
|
|
|
|
return $tmp;
|
617
|
|
|
|
|
|
|
}
|
618
|
|
|
|
|
|
|
}
|
619
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
620
|
|
|
|
|
|
|
{
|
621
|
|
|
|
|
|
|
package Class::STL::Utilities::Plus;
|
622
|
7
|
|
|
7
|
|
52
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
4507
|
|
623
|
|
|
|
|
|
|
sub function_operator
|
624
|
|
|
|
|
|
|
{
|
625
|
0
|
|
|
0
|
|
|
my $self = shift;
|
626
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
627
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
628
|
0
|
|
|
|
|
|
my $tmp;
|
629
|
0
|
0
|
0
|
|
|
|
if (ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
630
|
|
|
|
|
|
|
{
|
631
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
632
|
0
|
|
|
|
|
|
$tmp->add($arg2);
|
633
|
|
|
|
|
|
|
}
|
634
|
|
|
|
|
|
|
elsif (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
635
|
|
|
|
|
|
|
{
|
636
|
0
|
|
|
|
|
|
$tmp = $arg2->clone();
|
637
|
0
|
|
|
|
|
|
$tmp->data($tmp->data() + $arg1);
|
638
|
|
|
|
|
|
|
}
|
639
|
|
|
|
|
|
|
elsif (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
640
|
|
|
|
|
|
|
{
|
641
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
642
|
0
|
|
|
|
|
|
$tmp->data($tmp->data() + $arg2);
|
643
|
|
|
|
|
|
|
}
|
644
|
0
|
|
|
|
|
|
return $tmp;
|
645
|
|
|
|
|
|
|
}
|
646
|
|
|
|
|
|
|
}
|
647
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
648
|
|
|
|
|
|
|
{
|
649
|
|
|
|
|
|
|
package Class::STL::Utilities::Minus;
|
650
|
7
|
|
|
7
|
|
46
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
4663
|
|
651
|
|
|
|
|
|
|
sub function_operator
|
652
|
|
|
|
|
|
|
{
|
653
|
0
|
|
|
0
|
|
|
my $self = shift;
|
654
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
655
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
656
|
0
|
|
|
|
|
|
my $tmp;
|
657
|
0
|
0
|
0
|
|
|
|
if (ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
658
|
|
|
|
|
|
|
{
|
659
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
660
|
0
|
|
|
|
|
|
$tmp->subtract($arg2);
|
661
|
|
|
|
|
|
|
}
|
662
|
|
|
|
|
|
|
elsif (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
663
|
|
|
|
|
|
|
{
|
664
|
0
|
|
|
|
|
|
$tmp = $arg2->clone();
|
665
|
0
|
|
|
|
|
|
$tmp->data($arg1 - $arg2->data());
|
666
|
|
|
|
|
|
|
}
|
667
|
|
|
|
|
|
|
elsif (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
668
|
|
|
|
|
|
|
{
|
669
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
670
|
0
|
|
|
|
|
|
$tmp->data($arg1->data() - $arg2);
|
671
|
|
|
|
|
|
|
}
|
672
|
0
|
|
|
|
|
|
return $tmp;
|
673
|
|
|
|
|
|
|
}
|
674
|
|
|
|
|
|
|
}
|
675
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
676
|
|
|
|
|
|
|
{
|
677
|
|
|
|
|
|
|
package Class::STL::Utilities::Modulus;
|
678
|
7
|
|
|
7
|
|
72
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
200
|
|
|
7
|
|
|
|
|
4559
|
|
679
|
|
|
|
|
|
|
sub function_operator
|
680
|
|
|
|
|
|
|
{
|
681
|
0
|
|
|
0
|
|
|
my $self = shift;
|
682
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
683
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
684
|
0
|
|
|
|
|
|
my $tmp;
|
685
|
0
|
0
|
0
|
|
|
|
if (ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
686
|
|
|
|
|
|
|
{
|
687
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
688
|
0
|
|
|
|
|
|
$tmp->mod($arg2);
|
689
|
|
|
|
|
|
|
}
|
690
|
|
|
|
|
|
|
elsif (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
691
|
|
|
|
|
|
|
{
|
692
|
0
|
|
|
|
|
|
$tmp = $arg2->clone();
|
693
|
0
|
|
|
|
|
|
$tmp->data($arg1 % $arg2->data());
|
694
|
|
|
|
|
|
|
}
|
695
|
|
|
|
|
|
|
elsif (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
696
|
|
|
|
|
|
|
{
|
697
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
698
|
0
|
|
|
|
|
|
$tmp->data($arg1->data() % $arg2);
|
699
|
|
|
|
|
|
|
}
|
700
|
0
|
|
|
|
|
|
return $tmp;
|
701
|
|
|
|
|
|
|
}
|
702
|
|
|
|
|
|
|
}
|
703
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
704
|
|
|
|
|
|
|
{
|
705
|
|
|
|
|
|
|
package Class::STL::Utilities::Divides;
|
706
|
7
|
|
|
7
|
|
49
|
use base qw(Class::STL::Utilities::FunctionObject::BinaryFunction);
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
5319
|
|
707
|
|
|
|
|
|
|
sub function_operator
|
708
|
|
|
|
|
|
|
{
|
709
|
0
|
|
|
0
|
|
|
my $self = shift;
|
710
|
0
|
|
|
|
|
|
my $arg1 = shift;
|
711
|
0
|
|
|
|
|
|
my $arg2 = shift;
|
712
|
0
|
|
|
|
|
|
my $tmp;
|
713
|
0
|
0
|
0
|
|
|
|
if (ref($arg1) && $arg1->isa('Class::STL::Element') && ref($arg2) && $arg2->isa('Class::STL::Element'))
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
714
|
|
|
|
|
|
|
{
|
715
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
716
|
0
|
|
|
|
|
|
$tmp->div($arg2);
|
717
|
|
|
|
|
|
|
}
|
718
|
|
|
|
|
|
|
elsif (ref($arg2) && $arg2->isa('Class::STL::Element'))
|
719
|
|
|
|
|
|
|
{
|
720
|
0
|
|
|
|
|
|
$tmp = $arg2->clone();
|
721
|
0
|
|
|
|
|
|
$tmp->data($arg1 / $arg2->data());
|
722
|
|
|
|
|
|
|
}
|
723
|
|
|
|
|
|
|
elsif (ref($arg1) && $arg1->isa('Class::STL::Element'))
|
724
|
|
|
|
|
|
|
{
|
725
|
0
|
|
|
|
|
|
$tmp = $arg1->clone();
|
726
|
0
|
|
|
|
|
|
$tmp->data($arg1->data() / $arg2);
|
727
|
|
|
|
|
|
|
}
|
728
|
0
|
|
|
|
|
|
return $tmp;
|
729
|
|
|
|
|
|
|
}
|
730
|
|
|
|
|
|
|
}
|
731
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
732
|
|
|
|
|
|
|
{
|
733
|
|
|
|
|
|
|
package Class::STL::Utilities::Negate;
|
734
|
7
|
|
|
7
|
|
48
|
use base qw(Class::STL::Utilities::FunctionObject::UnaryFunction);
|
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
4924
|
|
735
|
|
|
|
|
|
|
sub function_operator
|
736
|
|
|
|
|
|
|
{
|
737
|
0
|
|
|
0
|
|
|
my $self = shift;
|
738
|
0
|
|
|
|
|
|
my $arg = shift;
|
739
|
0
|
|
|
|
|
|
my $tmp;
|
740
|
0
|
0
|
0
|
|
|
|
if (ref($arg) && $arg->isa('Class::STL::Element'))
|
741
|
|
|
|
|
|
|
{
|
742
|
0
|
|
|
|
|
|
$tmp = $arg->clone();
|
743
|
0
|
|
|
|
|
|
$tmp->neg();
|
744
|
|
|
|
|
|
|
}
|
745
|
|
|
|
|
|
|
else
|
746
|
|
|
|
|
|
|
{
|
747
|
0
|
|
|
|
|
|
$tmp = Class::STL::Element->new(data => -$arg, data_type => 'numeric');
|
748
|
|
|
|
|
|
|
}
|
749
|
0
|
|
|
|
|
|
return $tmp;
|
750
|
|
|
|
|
|
|
}
|
751
|
|
|
|
|
|
|
}
|
752
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
753
|
|
|
|
|
|
|
1;
|