line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2008-2022 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package String::Tagged::Extent 0.21; |
7
|
|
|
|
|
|
|
|
8
|
20
|
|
|
20
|
|
277
|
use v5.14; |
|
20
|
|
|
|
|
77
|
|
9
|
20
|
|
|
20
|
|
126
|
use warnings; |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
5402
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
C - represents a range within a C |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
These objects represent a range of characters within the containing |
18
|
|
|
|
|
|
|
L object. The range they represent is fixed at the time of |
19
|
|
|
|
|
|
|
creation. If the containing string is modified by a call to C |
20
|
|
|
|
|
|
|
then the effect on the extent object is not defined. These objects should be |
21
|
|
|
|
|
|
|
considered as relatively short-lived - used briefly for the purpose of |
22
|
|
|
|
|
|
|
querying the result of an operation, then discarded soon after. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 string |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$extent->string |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns the containing L object. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub string |
39
|
|
|
|
|
|
|
{ |
40
|
33
|
|
|
33
|
1
|
7283
|
shift->[0] |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 start |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$extent->start |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns the start index of the extent. This is the index of the first |
48
|
|
|
|
|
|
|
character within the extent. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub start |
53
|
|
|
|
|
|
|
{ |
54
|
390
|
|
|
390
|
1
|
1938
|
shift->[1] |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 end |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$extent->end |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns the end index of the extent. This is the index of the first character |
62
|
|
|
|
|
|
|
beyond the end of the extent. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub end |
67
|
|
|
|
|
|
|
{ |
68
|
215
|
|
|
215
|
1
|
448
|
shift->[2] |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 anchor_before |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$extent->anchor_before |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
True if this extent begins "before" the start of the string. Only certain |
76
|
|
|
|
|
|
|
methods return extents with this flag defined. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub anchor_before |
81
|
|
|
|
|
|
|
{ |
82
|
36
|
|
|
36
|
1
|
114
|
shift->[3] & String::Tagged::FLAG_ANCHOR_BEFORE; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 anchor_after |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$extent->anchor_after |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
True if this extent ends "after" the end of the string. Only certain methods |
90
|
|
|
|
|
|
|
return extents with this flag defined. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub anchor_after |
95
|
|
|
|
|
|
|
{ |
96
|
51
|
|
|
51
|
1
|
203
|
shift->[3] & String::Tagged::FLAG_ANCHOR_AFTER; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 length |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$extent->length |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns the number of characters within the extent. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub length |
108
|
|
|
|
|
|
|
{ |
109
|
173
|
|
|
173
|
1
|
266
|
my $self = shift; |
110
|
173
|
|
|
|
|
315
|
$self->end - $self->start; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 substr |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$extent->substr |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns the substring contained by the extent, as a L |
118
|
|
|
|
|
|
|
complete with all the relevant tag values. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub substr |
123
|
|
|
|
|
|
|
{ |
124
|
8
|
|
|
8
|
1
|
34
|
my $self = shift; |
125
|
8
|
|
|
|
|
19
|
$self->string->substr( $self->start, $self->length ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 plain_substr |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$extent->plain_substr |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns the substring of the underlying plain string buffer contained by the |
133
|
|
|
|
|
|
|
extent, as a plain Perl string. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub plain_substr |
138
|
|
|
|
|
|
|
{ |
139
|
22
|
|
|
22
|
1
|
49
|
my $self = shift; |
140
|
22
|
|
|
|
|
50
|
$self->string->plain_substr( $self->start, $self->length ); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Paul Evans |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
0x55AA; |