File Coverage

blib/lib/Protocol/PostgreSQL/FieldDescription.pm
Criterion Covered Total %
statement 17 23 73.9
branch n/a
condition n/a
subroutine 6 12 50.0
pod 8 9 88.8
total 31 44 70.4


line stmt bran cond sub pod time code
1             package Protocol::PostgreSQL::FieldDescription;
2             BEGIN {
3 5     5   1917 $Protocol::PostgreSQL::FieldDescription::VERSION = '0.008';
4             }
5 5     5   1612 use strict;
  5         11  
  5         1934  
6 5     5   26 use warnings;
  5         11  
  5         2789  
7              
8             =head1 NAME
9              
10             Protocol::PostgreSQL::FieldDescription - field definitions
11              
12             =head1 VERSION
13              
14             version 0.008
15              
16             =head1 SYNOPSIS
17              
18             =head1 DESCRIPTION
19              
20             Each field has the following definitions:
21              
22             =over 4
23              
24             =item * name
25              
26             =item * table_id - object ID for the table
27              
28             =item * field_id - attribute number of the column
29              
30             =item * data_type - object ID for the data type
31              
32             =item * data_size - length of the data type, can be negative for variable
33              
34             =item * type_modifier
35              
36             =item * format_code - text is zero, binary is one
37              
38             =back
39              
40             =cut
41              
42             =head1 METHODS
43              
44             =cut
45              
46             =head2 new
47              
48             =cut
49              
50             sub new {
51 3     3 1 6 my $class = shift;
52 3         15 my %args = @_;
53 3         10 my $self = bless { }, $class;
54 3         38 $self->{$_} = $args{$_} for keys %args;
55 3         17 return $self;
56             }
57              
58 6     6 1 9234 sub name { shift->{name} }
59              
60 0     0 1 0 sub table_id { shift->{table_id} }
61              
62 0     0 1 0 sub field_id { shift->{field_id} }
63              
64 0     0 1 0 sub data_type { shift->{data_type} }
65              
66 0     0 1 0 sub data_size { shift->{data_size} }
67              
68 0     0 1 0 sub type_modifier { shift->{type_modifier} }
69              
70 0     0 1 0 sub format_code { shift->{format_code} }
71              
72             sub parse_data {
73 3     3 0 6 my $self = shift;
74 3         5 my ($data, $size) = @_;
75 3         13 my ($content) = unpack("A$size", $data);
76 3         10 return $content;
77             }
78              
79             1;
80              
81             __END__