line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
71
|
|
|
71
|
|
24582
|
use 5.010001; |
|
71
|
|
|
|
|
221
|
|
2
|
71
|
|
|
71
|
|
339
|
use strict; |
|
71
|
|
|
|
|
109
|
|
|
71
|
|
|
|
|
1305
|
|
3
|
71
|
|
|
71
|
|
291
|
use warnings; |
|
71
|
|
|
|
|
122
|
|
|
71
|
|
|
|
|
2090
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package BSON::String; |
6
|
|
|
|
|
|
|
# ABSTRACT: BSON type wrapper for strings |
7
|
|
|
|
|
|
|
|
8
|
71
|
|
|
71
|
|
329
|
use version; |
|
71
|
|
|
|
|
115
|
|
|
71
|
|
|
|
|
270
|
|
9
|
|
|
|
|
|
|
our $VERSION = 'v1.12.0'; |
10
|
|
|
|
|
|
|
|
11
|
71
|
|
|
71
|
|
5322
|
use Moo; |
|
71
|
|
|
|
|
158
|
|
|
71
|
|
|
|
|
355
|
|
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
|
|
21317
|
use namespace::clean -except => 'meta'; |
|
71
|
|
|
|
|
151
|
|
|
71
|
|
|
|
|
473
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILDARGS { |
27
|
26109
|
|
|
26109
|
0
|
4848689
|
my $class = shift; |
28
|
26109
|
|
|
|
|
32465
|
my $n = scalar(@_); |
29
|
|
|
|
|
|
|
|
30
|
26109
|
|
|
|
|
30212
|
my %args; |
31
|
26109
|
100
|
|
|
|
52963
|
if ( $n == 0 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
32
|
1
|
|
|
|
|
3
|
$args{value} = ''; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( $n == 1 ) { |
35
|
26085
|
|
|
|
|
47618
|
$args{value} = shift; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( $n % 2 == 0 ) { |
38
|
23
|
|
|
|
|
71
|
%args = @_; |
39
|
23
|
100
|
|
|
|
137
|
$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
|
26109
|
|
|
|
|
45594
|
$args{value} = "$args{value}"; |
47
|
|
|
|
|
|
|
|
48
|
26109
|
|
|
|
|
341117
|
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
|
18
|
sub TO_JSON { return "$_[0]->{value}" } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use overload ( |
60
|
|
|
|
|
|
|
# Unary |
61
|
1
|
|
|
1
|
|
108
|
q{bool} => sub { !! $_[0]->{value} }, |
62
|
42685
|
|
|
42685
|
|
7517027
|
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
|
|
10590
|
( map { $_ => eval "sub { return \$_[0]->{value} $_ \$_[1] }" } qw( + * ) ), ## no critic |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
( |
68
|
|
|
|
|
|
|
map { |
69
|
852
|
0
|
|
0
|
|
64111
|
$_ => eval ## no critic |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
50
|
|
|
|
0
|
|
|
3
|
0
|
|
|
|
850
|
|
|
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
|
|
24585
|
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
|
|
|
|
|
586
|
fallback => 1, |
83
|
71
|
|
|
71
|
|
45489
|
); |
|
71
|
|
|
|
|
161
|
|
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.0 |
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) 2019 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__ |