FFI/FieldDefn.pm

filter: Statementstmt 13.1% 13 / 99 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 15.3% 4 / 26 Podpod 9.5% 2 / 21 totaltotal 8.7% 19 / 218 CC 32 SCAR 33.3
CC
32
Cov
8%
new
110.0
SetType
20.0
SetSubtype
20.0
CRAP 28.0
« FFI/FeatureDefn.pm ↑ Summary FFI.pm »
1 package Geo::GDAL::FFI::FieldDefn;
2 13 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 13 our $VERSION = '0.15';
8
9 sub new {
10 0 ▶ my ($class, $args) = @_;
Subroutine new: not called CC=10 SCAR=47.0
Pod undocumented
11 0 ▶ my $name = $args->{Name} // 'Unnamed';
Condition0%0/2
$args->{"Name"} // "Unnamed"
l!l
00
MC/DC0%0/1
$args->{"Name"} // "Unnamed"
$args->{"Name"}
Truth table0%0/2
A
A= $args->{"Name"}
Aresult
11
00
12 0 ▶ my $type = $args->{Type} // 'String';
Condition0%0/2
$args->{"Type"} // "String"
l!l
00
MC/DC0%0/1
$args->{"Type"} // "String"
$args->{"Type"}
Truth table0%0/2
A
A= $args->{"Type"}
Aresult
11
00
13 0 my $tmp = $Geo::GDAL::FFI::field_types{$type};
14 0 ▶ confess "Unknown field type: '$type'." unless defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 0 0
15 0 my $self = bless \Geo::GDAL::FFI::OGR_Fld_Create($name, $tmp), $class;
16 0 ▶ $self->SetDefault($args->{Default}) if defined $args->{Default};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"Default"} 0 0 0
17 0 ▶ $self->SetSubtype($args->{Subtype}) if defined $args->{Subtype};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"Subtype"} 0 0 0
18 0 ▶ $self->SetJustify($args->{Justify}) if defined $args->{Justify};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"Justify"} 0 0 0
19 0 ▶ $self->SetWidth($args->{Width}) if defined $args->{Width};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"Width"} 0 0 0
20 0 ▶ $self->SetPrecision($args->{Precision}) if defined $args->{Precision};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"Precision"} 0 0 0
21 0 ▶ $self->SetNullable(0) if $args->{NotNullable};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"NotNullable"} 0 0 0
22 0 return $self;
23 }
24
25 sub DESTROY {
26 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=3 SCAR=24.8
27 #say STDERR "destroy $self => $$self";
28 0 ▶ if ($Geo::GDAL::FFI::immutable{$$self}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Geo::GDAL::FFI::immutable{$$self}) { } 0 0 0
29 #say STDERR "remove it from immutable";
30 0 $Geo::GDAL::FFI::immutable{$$self}--;
31 0 ▶ delete $Geo::GDAL::FFI::immutable{$$self} if $Geo::GDAL::FFI::immutable{$$self} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} == 0 0 0 0
32 } else {
33 #say STDERR "destroy it";
34 0 Geo::GDAL::FFI::OGR_Fld_Destroy($$self);
35 }
36 }
37
38 sub GetSchema {
39 0 ▶ my $self = shift;
Subroutine GetSchema: not called CC=3 SCAR=24.8
Pod undocumented
40 0 my $schema = {
41 Name => $self->GetName,
42 Type => $self->GetType,
43 Subtype => $self->GetSubtype,
44 Justify => $self->GetJustify,
45 Width => $self->GetWidth,
46 Precision => $self->GetPrecision,
47 };
48 0 my $default = $self->GetDefault;
49 0 ▶ $schema->{Default} = $default if defined $default;
Branch: 1 branch
BranchTrueFalseTotal
if defined $default 0 0 0
50 0 ▶ $schema->{NotNullable} = 1 unless $self->IsNullable;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->IsNullable 0 0 0
51 0 return $schema;
52 }
53
54 sub SetName {
55 0 ▶ my ($self, $name) = @_;
Subroutine SetName: not called CC=3 SCAR=24.8
Pod undocumented
56 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
57 0 ▶ $name //= '';
Condition0%0/2
$name //= ""
l!l
00
MC/DC0%0/1
$name //= ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
58 0 Geo::GDAL::FFI::OGR_Fld_SetName($$self, $name);
59 }
60
61 sub GetName {
62 0 ▶ my ($self) = @_;
Subroutine GetName: not called CC=1 SCAR=6.9
Pod undocumented
63 0 return Geo::GDAL::FFI::OGR_Fld_GetNameRef($$self);
64 }
65
66 sub SetType {
67 0 ▶ my ($self, $type) = @_;
Subroutine SetType: not called CC=4 SCAR=30.0
Pod undocumented
68 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
69 0 ▶ $type //= 'String';
Condition0%0/2
$type //= "String"
l!l
00
MC/DC0%0/1
$type //= "String"
$type
Truth table0%0/2
A
A= $type
Aresult
11
00
70 0 my $tmp = $Geo::GDAL::FFI::field_types{$type};
71 0 ▶ confess "Unknown field type: $type." unless defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 0 0
72 0 $type = $tmp;
73 0 Geo::GDAL::FFI::OGR_Fld_SetType($$self, $type);
74 }
75
76 sub GetType {
77 0 ▶ my ($self) = @_;
Subroutine GetType: not called CC=1 SCAR=6.9
Pod undocumented
78 0 return $Geo::GDAL::FFI::field_types_reverse{Geo::GDAL::FFI::OGR_Fld_GetType($$self)};
79 }
80
81 sub GetDefault {
82 0 ▶ my $self = shift;
Subroutine GetDefault: not called CC=1 SCAR=6.9
Pod undocumented
83 0 return Geo::GDAL::FFI::OGR_Fld_GetDefault($$self)
84 }
85
86 sub SetDefault {
87 0 ▶ my ($self, $default) = @_;
Subroutine SetDefault: not called CC=1 SCAR=6.9
Pod undocumented
88 0 Geo::GDAL::FFI::OGR_Fld_SetDefault($$self, $default);
89 }
90
91 sub IsDefaultDriverSpecific {
92 0 ▶ my $self = shift;
Subroutine IsDefaultDriverSpecific: not called CC=1 SCAR=6.9
Pod undocumented
93 0 return Geo::GDAL::FFI::OGR_Fld_IsDefaultDriverSpecific($$self);
94 }
95
96 sub SetSubtype {
97 0 ▶ my ($self, $subtype) = @_;
Subroutine SetSubtype: not called CC=4 SCAR=30.0
Pod undocumented
98 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
99 0 ▶ $subtype //= 'None';
Condition0%0/2
$subtype //= "None"
l!l
00
MC/DC0%0/1
$subtype //= "None"
$subtype
Truth table0%0/2
A
A= $subtype
Aresult
11
00
100 0 my $tmp = $Geo::GDAL::FFI::field_subtypes{$subtype};
101 0 ▶ confess "Unknown field subtype: $subtype." unless defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 0 0
102 0 $subtype = $tmp;
103 0 Geo::GDAL::FFI::OGR_Fld_SetSubType($$self, $subtype);
104 }
105
106 sub GetSubtype {
107 0 ▶ my ($self) = @_;
Subroutine GetSubtype: not called CC=1 SCAR=6.9
Pod undocumented
108 0 return $Geo::GDAL::FFI::field_subtypes_reverse{Geo::GDAL::FFI::OGR_Fld_GetSubType($$self)};
109 }
110
111 sub SetJustify {
112 0 ▶ my ($self, $justify) = @_;
Subroutine SetJustify: not called CC=4 SCAR=30.0
Pod undocumented
113 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
114 0 ▶ $justify //= 'Undefined';
Condition0%0/2
$justify //= "Undefined"
l!l
00
MC/DC0%0/1
$justify //= "Undefined"
$justify
Truth table0%0/2
A
A= $justify
Aresult
11
00
115 0 my $tmp = $Geo::GDAL::FFI::justification{$justify};
116 0 ▶ confess "Unknown justify: $justify." unless defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 0 0
117 0 $justify = $tmp;
118 0 Geo::GDAL::FFI::OGR_Fld_SetJustify($$self, $justify);
119 }
120
121 sub GetJustify {
122 0 ▶ my ($self) = @_;
Subroutine GetJustify: not called CC=1 SCAR=6.9
Pod undocumented
123 0 return $Geo::GDAL::FFI::justification_reverse{Geo::GDAL::FFI::OGR_Fld_GetJustify($$self)};
124 }
125
126 sub SetWidth {
127 0 ▶ my ($self, $width) = @_;
Subroutine SetWidth: not called CC=3 SCAR=24.8
Pod undocumented
128 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
129 0 ▶ $width //= '';
Condition0%0/2
$width //= ""
l!l
00
MC/DC0%0/1
$width //= ""
$width
Truth table0%0/2
A
A= $width
Aresult
11
00
130 0 Geo::GDAL::FFI::OGR_Fld_SetWidth($$self, $width);
131 }
132
133 sub GetWidth {
134 0 ▶ my ($self) = @_;
Subroutine GetWidth: not called CC=1 SCAR=6.9
Pod undocumented
135 0 return Geo::GDAL::FFI::OGR_Fld_GetWidth($$self);
136 }
137
138 sub SetPrecision {
139 0 ▶ my ($self, $precision) = @_;
Subroutine SetPrecision: not called CC=3 SCAR=24.8
Pod undocumented
140 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
141 0 ▶ $precision //= '';
Condition0%0/2
$precision //= ""
l!l
00
MC/DC0%0/1
$precision //= ""
$precision
Truth table0%0/2
A
A= $precision
Aresult
11
00
142 0 Geo::GDAL::FFI::OGR_Fld_SetPrecision($$self, $precision);
143 }
144
145 sub GetPrecision {
146 0 ▶ my ($self) = @_;
Subroutine GetPrecision: not called CC=1 SCAR=6.9
Pod undocumented
147 0 return Geo::GDAL::FFI::OGR_Fld_GetPrecision($$self);
148 }
149
150 sub SetIgnored {
151 0 ▶ my ($self, $ignored) = @_;
Subroutine SetIgnored: not called CC=2 SCAR=17.9
Pod documented
152 #confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
153 0 ▶ $ignored //= 1;
Condition0%0/2
$ignored //= 1
l!l
00
MC/DC0%0/1
$ignored //= 1
$ignored
Truth table0%0/2
A
A= $ignored
Aresult
11
00
154 0 Geo::GDAL::FFI::OGR_Fld_SetIgnored($$self, $ignored);
155 }
156
157 sub IsIgnored {
158 0 ▶ my ($self) = @_;
Subroutine IsIgnored: not called CC=1 SCAR=6.9
Pod documented
159 0 return Geo::GDAL::FFI::OGR_Fld_IsIgnored($$self);
160 }
161
162 sub SetNullable {
163 0 ▶ my ($self, $nullable) = @_;
Subroutine SetNullable: not called CC=3 SCAR=24.8
Pod undocumented
164 0 ▶ confess "Can't modify an immutable object." if $Geo::GDAL::FFI::immutable{$$self};
Branch: 1 branch
BranchTrueFalseTotal
if $Geo::GDAL::FFI::immutable{$$self} 0 0 0
165 0 ▶ $nullable //= 0;
Condition0%0/2
$nullable //= 0
l!l
00
MC/DC0%0/1
$nullable //= 0
$nullable
Truth table0%0/2
A
A= $nullable
Aresult
11
00
166 0 Geo::GDAL::FFI::OGR_Fld_SetNullable($$self, $nullable);
167 }
168
169 sub IsNullable {
170 0 ▶ my ($self) = @_;
Subroutine IsNullable: not called CC=1 SCAR=6.9
Pod undocumented
171 0 return Geo::GDAL::FFI::OGR_Fld_IsNullable($$self);
172 }
173
174 13 1;
175
176 =pod
177
178 =encoding UTF-8
179
180 =head1 NAME
181
182 Geo::GDAL::FFI::FieldDefn - A field in a GDAL feature schema
183
184 =head1 SYNOPSIS
185
186 =head1 DESCRIPTION
187
188 There should not usually be any reason to directly access this method
189 except for the ignore methods. This object is created/read from/to the
190 Perl data structure in the CreateLayer method of a dataset, or in the
191 constructor or schema method of FeatureDefn.
192
193 The schema of a FieldDefn is (Name, Type, Default, Subtype, Justify,
194 Width, Precision, NotNullable).
195
196 =head1 METHODS
197
198 =head2 SetIgnored
199
200 $defn->SetIgnored($arg);
201
202 Ignore this field when reading features from a layer. To not ignore
203 this field call this method with defined but false (0) argument.
204
205 =head2 IsIgnored
206
207 Is this field ignored when reading features from a layer.
208
209 =head1 LICENSE
210
211 This software is released under the Artistic License. See
212 L<perlartistic>.
213
214 =head1 AUTHOR
215
216 Ari Jolma - Ari.Jolma at gmail.com
217
218 =head1 SEE ALSO
219
220 L<Geo::GDAL::FFI>
221
222 L<Alien::gdal>, L<FFI::Platypus>, L<http://www.gdal.org>
223
224 =cut
225
226 __END__;
« FFI/FeatureDefn.pm ↑ Summary FFI.pm »