line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
71
|
|
|
71
|
|
26276
|
use 5.010001; |
|
71
|
|
|
|
|
223
|
|
2
|
71
|
|
|
71
|
|
326
|
use strict; |
|
71
|
|
|
|
|
136
|
|
|
71
|
|
|
|
|
1426
|
|
3
|
71
|
|
|
71
|
|
307
|
use warnings; |
|
71
|
|
|
|
|
119
|
|
|
71
|
|
|
|
|
2432
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package BSON::Binary; |
6
|
|
|
|
|
|
|
# ABSTRACT: Legacy BSON type wrapper for binary data (DEPRECATED) |
7
|
|
|
|
|
|
|
|
8
|
71
|
|
|
71
|
|
742
|
use version; |
|
71
|
|
|
|
|
166
|
|
|
71
|
|
|
|
|
392
|
|
9
|
|
|
|
|
|
|
our $VERSION = 'v1.12.2'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $TYPE_SIMPLE = 0x00; |
12
|
|
|
|
|
|
|
our $TYPE_BYTES = 0x02; |
13
|
|
|
|
|
|
|
our $TYPE_UUID = 0x03; |
14
|
|
|
|
|
|
|
our $TYPE_MD5 = 0x05; |
15
|
|
|
|
|
|
|
our $TYPE_USER_DEFINED = 0x80; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
5
|
|
|
5
|
0
|
2611
|
my ( $class, $data, $type ) = @_; |
19
|
5
|
|
66
|
|
|
38
|
$type ||= $TYPE_SIMPLE; |
20
|
5
|
|
|
|
|
14
|
my $self = bless { type => $type }, $class; |
21
|
5
|
|
|
|
|
17
|
$self->data($data); |
22
|
5
|
|
|
|
|
22
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub data { |
26
|
15
|
|
|
15
|
0
|
829
|
my ( $self, $data ) = @_; |
27
|
15
|
100
|
|
|
|
33
|
if ( defined $data ) { |
28
|
5
|
100
|
|
|
|
24
|
$data = [ unpack( 'C*', $data ) ] unless ref $data eq 'ARRAY'; |
29
|
5
|
|
|
|
|
83
|
$self->{data} = $data; |
30
|
|
|
|
|
|
|
} |
31
|
15
|
|
|
|
|
55
|
return $self->{data}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub type { |
35
|
6
|
|
|
6
|
0
|
881
|
return $_[0]->{type}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# alias for compatibility with BSON::Bytes |
39
|
|
|
|
|
|
|
sub subtype { |
40
|
4
|
|
|
4
|
0
|
8
|
return $_[0]->{type}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub to_s { |
44
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
45
|
2
|
|
|
|
|
4
|
my @data = @{ $self->data }; |
|
2
|
|
|
|
|
3
|
|
46
|
2
|
|
|
|
|
6
|
return pack( 'ltype, @data ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub TO_JSON { |
50
|
0
|
|
|
0
|
0
|
|
my %data; |
51
|
0
|
|
|
|
|
|
tie( %data, 'Tie::IxHash' ); |
52
|
0
|
|
|
|
|
|
$data{base64} = $_[0]->to_s; |
53
|
0
|
|
|
|
|
|
$data{subType} = $_[0]->{type}; |
54
|
0
|
|
|
|
|
|
return { '$binary' => \%data }; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
71
|
|
|
71
|
|
26911
|
use overload '""' => \&to_s; |
|
71
|
|
|
|
|
176
|
|
|
71
|
|
|
|
|
498
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
BSON::Binary - Legacy BSON type wrapper for binary data (DEPRECATED) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version v1.12.2 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This module has been deprecated as it was horribly inefficient (unpacking |
76
|
|
|
|
|
|
|
binary data to individual single-byte elements of an array!) and had a |
77
|
|
|
|
|
|
|
weird API that was not compatible with the existing MongoDB Binary wrapper |
78
|
|
|
|
|
|
|
implementation on CPAN. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
You are strongly encouraged to use L instead. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=for Pod::Coverage new data type subtype to_s TO_JSON |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHORS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
David Golden |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Stefan G. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software, licensed under: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |