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