line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IRC::Toolkit::Case::MappedString; |
2
|
|
|
|
|
|
|
$IRC::Toolkit::Case::MappedString::VERSION = '0.091001'; |
3
|
1
|
|
|
1
|
|
23
|
use strictures 2; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
52
|
|
4
|
1
|
|
|
1
|
|
231
|
use IRC::Toolkit::Case; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
386
|
use Scalar::Util 'blessed'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
6
|
|
|
|
|
|
|
use overload |
7
|
1
|
|
|
|
|
7
|
bool => 'length', |
8
|
|
|
|
|
|
|
eq => '_eq', |
9
|
|
|
|
|
|
|
ne => '_ne', |
10
|
|
|
|
|
|
|
gt => '_gt', |
11
|
|
|
|
|
|
|
lt => '_lt', |
12
|
|
|
|
|
|
|
ge => '_ge', |
13
|
|
|
|
|
|
|
le => '_le', |
14
|
|
|
|
|
|
|
cmp => '_cmp', |
15
|
|
|
|
|
|
|
'""' => 'as_string', |
16
|
1
|
|
|
1
|
|
4
|
fallback => 1; |
|
1
|
|
|
|
|
1
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=pod |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=for Pod::Coverage STR CMAP |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub STR () { 0 } |
25
|
|
|
|
|
|
|
sub CMAP () { 1 } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
7
|
|
|
7
|
1
|
9
|
my ($class, $cmap, $str) = @_; |
29
|
7
|
100
|
|
|
|
15
|
unless (defined $str) { |
30
|
1
|
|
|
|
|
1
|
$str = $cmap; |
31
|
1
|
|
|
|
|
2
|
$cmap = 'rfc1459'; |
32
|
|
|
|
|
|
|
} |
33
|
7
|
|
|
|
|
39
|
bless [ $str, $cmap ], $class |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
0
|
sub as_string { $_[0]->[STR] } |
37
|
1
|
|
|
1
|
1
|
6
|
sub casemap { $_[0]->[CMAP] } |
38
|
1
|
|
|
1
|
1
|
4
|
sub length { length $_[0]->[STR] } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub as_upper { |
41
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
42
|
2
|
|
|
|
|
13
|
blessed($self)->new( |
43
|
|
|
|
|
|
|
$self->[CMAP], |
44
|
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub as_lower { |
49
|
2
|
|
|
2
|
1
|
3
|
my ($self) = @_; |
50
|
2
|
|
|
|
|
12
|
blessed($self)->new( |
51
|
|
|
|
|
|
|
$self->[CMAP], |
52
|
|
|
|
|
|
|
lc_irc( $self->[STR], $self->[CMAP] ) |
53
|
|
|
|
|
|
|
) |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _eq { |
57
|
5
|
|
|
5
|
|
43
|
my ($self) = @_; |
58
|
5
|
|
|
|
|
13
|
eq_irc( $_[1], $self->[STR], $self->[CMAP] ) |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _ne { |
62
|
3
|
|
|
3
|
|
5
|
my ($self) = @_; |
63
|
3
|
|
|
|
|
10
|
! eq_irc( $_[1], $self->[STR], $self->[CMAP] ) |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _cmp { |
67
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
68
|
0
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) cmp uc_irc( $_[1], $self->[CMAP] ) |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _gt { |
72
|
0
|
0
|
|
0
|
|
|
return _lt( @_[0,1] ) if $_[2]; |
73
|
0
|
|
|
|
|
|
my ($self) = @_; |
74
|
0
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) gt uc_irc( $_[1], $self->[CMAP] ) |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _lt { |
78
|
0
|
0
|
|
0
|
|
|
return _gt( @_[0,1] ) if $_[2]; |
79
|
0
|
|
|
|
|
|
my ($self) = @_; |
80
|
0
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) lt uc_irc( $_[1], $self->[CMAP] ) |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _ge { |
84
|
0
|
0
|
|
0
|
|
|
return _le( @_[0,1] ) if $_[2]; |
85
|
0
|
|
|
|
|
|
my ($self) = @_; |
86
|
0
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) ge uc_irc( $_[1], $self->[CMAP] ) |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _le { |
90
|
0
|
0
|
|
0
|
|
|
return _ge( @_[0,1] ) if $_[2]; |
91
|
0
|
|
|
|
|
|
my ($self) = @_; |
92
|
0
|
|
|
|
|
|
uc_irc( $self->[STR], $self->[CMAP] ) le uc_irc( $_[1], $self->[CMAP] ) |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=pod |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
IRC::Toolkit::Case::MappedString - Strings with casemaps attached |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
use IRC::Toolkit::Case; |
107
|
|
|
|
|
|
|
my $str = irc_str( strict => 'Nick^[Abc]' ); |
108
|
|
|
|
|
|
|
if ($str eq 'nick^{abc}') { |
109
|
|
|
|
|
|
|
# true |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
These overloaded objects represent IRC strings with a specific IRC casemap |
115
|
|
|
|
|
|
|
attached (such as nick/channel names). |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L for more details on IRC casemapping peculiarities. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 new |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Creates a new string object. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Expects a casemap and string; if given a single argument, it is taken to be |
124
|
|
|
|
|
|
|
the string and the casemap defaults to C. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 as_string |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the raw string. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 as_upper |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns a new string object containing the uppercased (per specified rules) |
133
|
|
|
|
|
|
|
string. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 as_lower |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns a new string object containing the lowercased (per specified rules) |
138
|
|
|
|
|
|
|
string. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 casemap |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns the currently-configured casemap setting. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 length |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Returns the string's length. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Jon Portnoy |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |