blib/lib/ICC/Profile/sig_.pm

filter: Statementstmt 77.5% 38 / 49 Branchbran 21.4% 3 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 10 / 12 Podpod 16.6% 1 / 6 totaltotal 60.4% 52 / 86 CC 9 SCAR 22.0
CC
9
Cov
62%
sdump
30.0
text
6.0
new
2.1
CRAP 9.1
« blib/lib/ICC/Support/geo1.pm ↑ Summary blib/lib/ICC/Profile/Generic.pm »
1 package ICC::Profile::sig_;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = 0.12;
7  
8 # revised 2018-08-07
9 #
10 # Copyright © 2004-2018 by William B. Birkett
11  
12 # add development directory
13 2 ▶use lib 'lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # inherit from Shared
16 2 ▶use parent qw(ICC::Shared);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # create new sig_ tag object
19 # parameters: ([text_string])
20 # returns: (ref_to_object)
21 sub new {
22  
23 # get object class
24 1 ▶ my $class = shift();
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
25
26 # create empty sig_ object
27 1 my $self = [
28 {}, # object header
29 ' ' # text string
30 ];
31  
32 # if parameter supplied
33 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
34
35 # save as 4-byte string
36 0 $self->[1] = pack('a4', shift());
37
38 }
39  
40 # bless object
41 1 bless($self, $class);
42
43 # return object reference
44 1 return($self);
45  
46 }
47  
48 # create sig_ tag object from ICC profile
49 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
50 # returns: (ref_to_object)
51 sub new_fh {
52  
53 # get object class
54 1 ▶ my $class = shift();
Subroutine new_fh: called CC=2 SCAR=7.0
Pod undocumented
55  
56 # create empty sig_ object
57 1 my $self = [
58 {}, # object header
59 '' # text string
60 ];
61  
62 # verify 3 parameters
63 1 ▶ (@_ == 3) or croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 1 1
64  
65 # read sig_ data from profile
66 1 _readICCsig_($self, @_);
67  
68 # bless object
69 1 bless($self, $class);
70  
71 # return object reference
72 1 return($self);
73  
74 }
75  
76 # writes sig_ tag object to ICC profile
77 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
78 sub write_fh {
79  
80 # verify 4 parameters
81 1 ▶ (@_ == 4) or croak('wrong number of parameters');
Subroutine write_fh: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or croak("wrong number of parameters") 0 1 1
82  
83 # write sig_ data to profile
84 1 goto &_writeICCsig_;
85  
86 }
87  
88 # get tag size (for writing to profile)
89 # returns: (tag_size)
90 sub size {
91
92 # get parameters
93 3 ▶ my ($self) = @_;
Subroutine size: called CC=1 SCAR=0.0
Pod undocumented
94
95 # return size
96 3 return(12);
97
98 }
99  
100 # get/set text string
101 # parameters: ([text_string])
102 # returns: (text_string)
103 sub text {
104  
105 # get object reference
106 0 ▶ my $self = shift();
Subroutine text: not called CC=2 SCAR=17.9
Pod undocumented
107
108 # if parameter supplied
109 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
110
111 # save it
112 0 $self->[1] = pack('a4', shift());
113
114 }
115
116 # return text string
117 0 return($self->[1]);
118  
119 }
120  
121 # print object contents to string
122 # format is an array structure
123 # parameter: ([format])
124 # returns: (string)
125 sub sdump {
126  
127 # get parameters
128 0 ▶ my ($self, $p) = @_;
Subroutine sdump: not called CC=5 SCAR=34.0
Pod documented
129  
130 # local variables
131 0 my ($s, $fmt);
132  
133 # resolve parameter to an array reference
134 0 ▶ $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : [];
Branch: 2 branches
BranchTrueFalseTotal
defined $p ? : 0 0 0
ref $p eq 'ARRAY' ? : 0 0 0
135  
136 # get format string
137 0 ▶ $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $p->[0] && !ref($p->[0]) ? : 0 0 0
Condition0%0/3
defined $p->[0] and not ref $p->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->[0] and not ref $p->[0]
defined $p->[0] not ref $p->[0]
Truth table0%0/3
A and not(B)
A= defined $p->[0]B= not ref $p->[0]
ABresult
0X0
100
111
138  
139 # set string to object ID
140 0 $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self);
141  
142 # return
143 0 return($s);
144  
145 }
146  
147 # read sig_ tag from ICC profile
148 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
149 sub _readICCsig_ {
150
151 # get parameters
152 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _readICCsig_: called CC=1 SCAR=0.0
153
154 # local variables
155 1 my ($buf);
156
157 # save tag signature
158 1 $self->[0]{'signature'} = $tag->[0];
159
160 # seek start of tag
161 1 seek($fh, $tag->[1], 0);
162
163 # read tag
164 1 read($fh, $buf, 12);
165
166 # unpack text string
167 1 $self->[1] = unpack('x8 a4', $buf);
168
169 }
170  
171 # write sig_ tag to ICC profile
172 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
173 sub _writeICCsig_ {
174  
175 # get parameters
176 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _writeICCsig_: called CC=1 SCAR=0.0
177  
178 # seek start of tag
179 1 seek($fh, $tag->[1], 0);
180  
181 # write tag
182 1 print $fh pack('a4 x4 a4', 'sig ', $self->[1]);
183  
184 }
185  
186 2 1;
« blib/lib/ICC/Support/geo1.pm ↑ Summary blib/lib/ICC/Profile/Generic.pm »