line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Metadata::Column::Bitfield; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use Rose::Object::MakeMethods::Generic; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
6
|
2
|
|
|
2
|
|
61
|
use Rose::DB::Object::MakeMethods::Generic; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
42
|
use Rose::DB::Object::Metadata::Column; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
691
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Metadata::Column); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.788'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->add_common_method_maker_argument_names |
14
|
|
|
|
|
|
|
( |
15
|
|
|
|
|
|
|
qw(default bits) |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Rose::Object::MakeMethods::Generic->make_methods |
19
|
|
|
|
|
|
|
( |
20
|
|
|
|
|
|
|
{ preserve_existing => 1 }, |
21
|
|
|
|
|
|
|
scalar => [ __PACKAGE__->common_method_maker_argument_names ] |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
1
|
50
|
sub type { 'bitfield' } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
foreach my $type (__PACKAGE__->available_method_types) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
__PACKAGE__->method_maker_type($type => 'bitfield') |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# sub dbi_data_type { DBI::SQL_INTEGER() } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub parse_value |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
36
|
0
|
|
|
|
|
0
|
my $db = shift; |
37
|
0
|
|
|
|
|
0
|
my $value = shift; |
38
|
0
|
|
0
|
|
|
0
|
my $bits = shift || $self->bits; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return $db->parse_bitfield($value, $bits); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub format_value |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
0
|
|
|
|
|
0
|
my $db = shift; |
47
|
0
|
|
|
|
|
0
|
my $value = shift; |
48
|
0
|
|
0
|
|
|
0
|
my $bits = shift || $self->bits; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
return $db->format_bitfield($value, $bits); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub init_with_dbi_column_info |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
0
|
0
|
my($self, $col_info) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
$self->SUPER::init_with_dbi_column_info($col_info); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
$self->bits($col_info->{'COLUMN_SIZE'}); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub should_inline_value |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
1
|
0
|
my($self, $db, $value) = @_; |
67
|
2
|
|
|
2
|
|
17
|
no warnings 'uninitialized'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
627
|
|
68
|
0
|
0
|
0
|
|
|
0
|
return (($db->validate_bitfield_keyword($value) && $db->should_inline_bitfield_value($value)) || |
69
|
|
|
|
|
|
|
($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub method_uses_formatted_key |
73
|
|
|
|
|
|
|
{ |
74
|
2
|
|
|
2
|
0
|
6
|
my($self, $type) = @_; |
75
|
2
|
50
|
33
|
|
|
17
|
return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set'); |
|
|
|
33
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub select_sql |
80
|
|
|
|
|
|
|
{ |
81
|
5
|
|
|
5
|
0
|
19
|
my($self, $db, $table) = @_; |
82
|
|
|
|
|
|
|
|
83
|
5
|
50
|
|
|
|
12
|
if($db) |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
0
|
|
|
|
0
|
if(defined $table) |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
0
|
return $db->select_bitfield_column_sql($self->{'name'}, $table); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
0
|
|
|
0
|
return $self->{'select_sql'}{$db->{'driver'}} ||= $db->select_bitfield_column_sql($self->{'name'}); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else |
95
|
|
|
|
|
|
|
{ |
96
|
5
|
|
|
|
|
10
|
return $self->{'name'}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Rose::DB::Object::Metadata::Column::Bitfield - Bitfield column metadata. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use Rose::DB::Object::Metadata::Column::Bitfield; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$col = Rose::DB::Object::Metadata::Column::Bitfield->new(...); |
113
|
|
|
|
|
|
|
$col->make_methods(...); |
114
|
|
|
|
|
|
|
... |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 DESCRIPTION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Objects of this class store and manipulate metadata for bitfield columns in a database. Column metadata objects store information about columns (data type, size, etc.) and are responsible for parsing, formatting, and creating object methods that manipulate column values. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This class inherits from L<Rose::DB::Object::Metadata::Column>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::DB::Object::Metadata::Column> documentation for more information. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
B<Important note:> if you are using MySQL 5.0.3 or later, you I<must> L<allow inline column values|Rose::DB::Object::Metadata/allow_inline_column_values> in any L<Rose::DB::Object>-derived class that has one or more bitfield columns. (That is, columns that use the C<BIT> data type.) This requirement may be relaxed in the future. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 METHOD MAP |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<get_set> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<bitfield|Rose::DB::Object::MakeMethods::Generic/bitfield>, ... |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<get> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<bitfield|Rose::DB::Object::MakeMethods::Generic/bitfield>, ... |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C<get_set> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<Rose::DB::Object::MakeMethods::Generic>, L<bitfield|Rose::DB::Object::MakeMethods::Generic/bitfield>, ... |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
See the L<Rose::DB::Object::Metadata::Column|Rose::DB::Object::Metadata::Column/"MAKING METHODS"> documentation for an explanation of this method map. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over 4 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item B<bits [INT]> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Get or set the number of bits in the column. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item B<parse_value DB, VALUE> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Convert VALUE to the equivalent C<Bit::Vector> object. The return value of the column object's C<bits()> method is used to determine the length of the bitfield in bits. DB is a L<Rose::DB> object that is used as part of the parsing process. Both arguments are required. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item B<type> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns "bitfield". |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
169
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
170
|
|
|
|
|
|
|
as Perl itself. |