line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
### |
3
|
|
|
|
|
|
|
### Copyright 2002-2003 University of Illinois Board of Trustees |
4
|
|
|
|
|
|
|
### Copyright 2002-2003 Mark D. Roth |
5
|
|
|
|
|
|
|
### All rights reserved. |
6
|
|
|
|
|
|
|
### |
7
|
|
|
|
|
|
|
### Config::Objective::Boolean - boolean data type for Config::Objective |
8
|
|
|
|
|
|
|
### |
9
|
|
|
|
|
|
|
### Mark D. Roth |
10
|
|
|
|
|
|
|
### Campus Information Technologies and Educational Services |
11
|
|
|
|
|
|
|
### University of Illinois at Urbana-Champaign |
12
|
|
|
|
|
|
|
### |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Config::Objective::Boolean; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
473
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#use overload |
20
|
|
|
|
|
|
|
# 'bool' => \&get |
21
|
|
|
|
|
|
|
# ; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use Config::Objective::DataType; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
289
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @ISA = qw(Config::Objective::DataType); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
29
|
|
|
|
|
|
|
### utility function to interpret boolean values |
30
|
|
|
|
|
|
|
############################################################################### |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _boolean |
33
|
|
|
|
|
|
|
{ |
34
|
5
|
|
|
5
|
|
8
|
my ($self, $value) = @_; |
35
|
|
|
|
|
|
|
|
36
|
5
|
100
|
100
|
|
|
44
|
if (!defined($value) |
|
|
50
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|| $value =~ m/^(yes|on|true|1)$/i) |
38
|
|
|
|
|
|
|
{ |
39
|
4
|
|
|
|
|
19
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ($value =~ m/^(no|off|false|0)$/i) |
42
|
|
|
|
|
|
|
{ |
43
|
1
|
|
|
|
|
5
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
die "non-boolean value '$value' specified for boolean variable\n"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
############################################################################### |
51
|
|
|
|
|
|
|
### set method |
52
|
|
|
|
|
|
|
############################################################################### |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub set |
55
|
|
|
|
|
|
|
{ |
56
|
3
|
|
|
3
|
1
|
6
|
my ($self, $value) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# print "==> Boolean::set($value)\n"; |
59
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
10
|
$self->{'value'} = $self->_boolean($value); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
############################################################################### |
65
|
|
|
|
|
|
|
### equals method |
66
|
|
|
|
|
|
|
############################################################################### |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub equals |
69
|
|
|
|
|
|
|
{ |
70
|
2
|
|
|
2
|
1
|
4
|
my ($self, $value) = @_; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
11
|
return ($self->{'value'} == $self->_boolean($value)); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
############################################################################### |
77
|
|
|
|
|
|
|
### cleanup and documentation |
78
|
|
|
|
|
|
|
############################################################################### |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |