line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
71
|
|
|
71
|
|
43715
|
use 5.010001; |
|
71
|
|
|
|
|
227
|
|
2
|
71
|
|
|
71
|
|
319
|
use strict; |
|
71
|
|
|
|
|
123
|
|
|
71
|
|
|
|
|
1418
|
|
3
|
71
|
|
|
71
|
|
288
|
use warnings; |
|
71
|
|
|
|
|
121
|
|
|
71
|
|
|
|
|
2373
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package BSON::String; |
6
|
|
|
|
|
|
|
# ABSTRACT: BSON type wrapper for strings |
7
|
|
|
|
|
|
|
|
8
|
71
|
|
|
71
|
|
321
|
use version; |
|
71
|
|
|
|
|
133
|
|
|
71
|
|
|
|
|
278
|
|
9
|
|
|
|
|
|
|
our $VERSION = 'v1.12.2'; |
10
|
|
|
|
|
|
|
|
11
|
71
|
|
|
71
|
|
9825
|
use Moo; |
|
71
|
|
|
|
|
131
|
|
|
71
|
|
|
|
|
364
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#pod =attr value |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod A scalar value, which will be stringified during construction. The default |
16
|
|
|
|
|
|
|
#pod is the empty string. |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod =cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'value' => ( |
21
|
|
|
|
|
|
|
is => 'ro' |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
71
|
|
|
71
|
|
21030
|
use namespace::clean -except => 'meta'; |
|
71
|
|
|
|
|
145
|
|
|
71
|
|
|
|
|
467
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILDARGS { |
27
|
27824
|
|
|
27824
|
0
|
5981031
|
my $class = shift; |
28
|
27824
|
|
|
|
|
40266
|
my $n = scalar(@_); |
29
|
|
|
|
|
|
|
|
30
|
27824
|
|
|
|
|
33484
|
my %args; |
31
|
27824
|
100
|
|
|
|
67108
|
if ( $n == 0 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
32
|
1
|
|
|
|
|
3
|
$args{value} = ''; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( $n == 1 ) { |
35
|
27800
|
|
|
|
|
67719
|
$args{value} = shift; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( $n % 2 == 0 ) { |
38
|
23
|
|
|
|
|
65
|
%args = @_; |
39
|
23
|
100
|
|
|
|
120
|
$args{value} = '' unless defined $args{value}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
0
|
|
|
|
|
0
|
croak("Invalid number of arguments ($n) to BSON::String::new"); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# normalize all to internal PV type |
46
|
27824
|
|
|
|
|
53763
|
$args{value} = "$args{value}"; |
47
|
|
|
|
|
|
|
|
48
|
27824
|
|
|
|
|
390985
|
return \%args; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#pod =method TO_JSON |
52
|
|
|
|
|
|
|
#pod |
53
|
|
|
|
|
|
|
#pod Returns value as a string. |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod =cut |
56
|
|
|
|
|
|
|
|
57
|
6
|
|
|
6
|
1
|
17
|
sub TO_JSON { return "$_[0]->{value}" } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use overload ( |
60
|
|
|
|
|
|
|
# Unary |
61
|
1
|
|
|
1
|
|
86
|
q{bool} => sub { !! $_[0]->{value} }, |
62
|
45675
|
|
|
45675
|
|
8629420
|
q{""} => sub { $_[0]->{value} }, |
63
|
0
|
|
|
0
|
|
0
|
q{0+} => sub { 0+ $_[0]->{value} }, |
64
|
0
|
|
|
0
|
|
0
|
q{~} => sub { ~( $_[0]->{value} ) }, |
65
|
|
|
|
|
|
|
# Binary |
66
|
142
|
|
|
0
|
|
10818
|
( map { $_ => eval "sub { return \$_[0]->{value} $_ \$_[1] }" } qw( + * ) ), ## no critic |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
( |
68
|
|
|
|
|
|
|
map { |
69
|
852
|
0
|
|
0
|
|
63784
|
$_ => eval ## no critic |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
50
|
|
|
|
0
|
|
|
3
|
0
|
|
|
|
697
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
"sub { return \$_[2] ? \$_[1] $_ \$_[0]->{value} : \$_[0]->{value} $_ \$_[1] }" |
71
|
|
|
|
|
|
|
} qw( - / % ** << >> x <=> cmp & | ^ ) |
72
|
|
|
|
|
|
|
), |
73
|
|
|
|
|
|
|
( |
74
|
426
|
|
|
0
|
|
24319
|
map { $_ => eval "sub { return $_(\$_[0]->{value}) }" } ## no critic |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
qw( cos sin exp log sqrt int ) |
76
|
|
|
|
|
|
|
), |
77
|
|
|
|
|
|
|
q{atan2} => sub { |
78
|
0
|
0
|
|
0
|
|
0
|
return $_[2] ? atan2( $_[1], $_[0]->{value} ) : atan2( $_[0]->{value}, $_[1] ); |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Special |
82
|
71
|
|
|
|
|
567
|
fallback => 1, |
83
|
71
|
|
|
71
|
|
47352
|
); |
|
71
|
|
|
|
|
179
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding UTF-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
BSON::String - BSON type wrapper for strings |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version v1.12.2 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SYNOPSIS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
use BSON::Types ':all'; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
bson_string( $string ); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This module provides a BSON type wrapper for a string value. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Since Perl does not distinguish between numbers and strings, this module |
110
|
|
|
|
|
|
|
provides an explicit string type for a scalar value. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 value |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
A scalar value, which will be stringified during construction. The default |
117
|
|
|
|
|
|
|
is the empty string. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 METHODS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 TO_JSON |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns value as a string. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=for Pod::Coverage BUILDARGS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 OVERLOADING |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The stringification operator (C<"">) is overloaded to return the C, |
130
|
|
|
|
|
|
|
the full "minimal set" of overloaded operations is provided (per L |
131
|
|
|
|
|
|
|
documentation) and fallback overloading is enabled. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHORS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=over 4 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
David Golden |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Stefan G. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software, licensed under: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |