blib/lib/GDS2.pm

filter: Statementstmt 45.4% 859 / 1891 Branchbran 32.2% 298 / 924 Conditioncond 33.3% 79 / 237 MC/DCmcdc 21.7% 28 / 129 Subroutinesub 41.6% 105 / 252 Podpod 75.5% 130 / 172 totaltotal 41.5% 1499 / 3605 CC 545 SCAR 54.3
CC
545
Cov
40%
saveGds2Record
1806.0
printText
1260.0
returnRecordAsPerl
756.0
CRAP 229.3
↑ Summary
1 package GDS2;
2 {
3 6 require 5.010001;
4 6 $GDS2::VERSION = '3.35';
5 ## Note: '@ ( # )' used by the what command E.g. what GDS2.pm
6 6 $GDS2::revision = '@(#) $Id: GDS2.pm,v $ $Revision: 3.35 $ $Date: 2017-10-04 03:27:57-06 $';
7 #
8  
9 =pod
10  
11 =head1 NAME
12  
13 GDS2 - GDS2 stream module
14  
15 =head1 SYNOPSIS
16  
17 This is GDS2, a module for creating programs to read and/or write GDS2 files.
18  
19 Send feedback/suggestions to
20 perl -le '$_=q(Zpbhgnpe@pvnt.uxa);$_=~tr/n-sa-gt-zh-mZ/a-zS/;print;'
21  
22 =head1 COPYRIGHT
23  
24 Author: Ken Schumack (c) 1999-2017. All rights reserved.
25 This module is free software. It may be used, redistributed
26 and/or modified under the terms of the Perl Artistic License.
27 ( see http://www.perl.com/pub/a/language/misc/Artistic.html )
28 Have fun, Ken
29  
30 Schumack@cpan.org
31  
32 =head1 DESCRIPTION
33  
34 GDS2 allows you to read and write GDS2 files record by record in a
35 stream fashion which inherently uses little memory. It is capable but
36 not fast. If you have large files you may be happier using the C/C++
37 http://sourceforge.net/projects/gds2/ which can easily be used by Perl.
38  
39 =cut
40  
41 #
42 # Contributor Modification: Toby Schaffer 2004-01-21
43 # returnUnitsAsArray() added which returns user units and database
44 # units as a 2 element array.
45 #
46 # Contributor Modification: Peter Baumbach 2002-01-11
47 # returnRecordAsPerl() was created to facilitate the creation of
48 # parameterized gds2 data with perl. -Years later Andreas Pawlak
49 # pointed out a endian problem that needed to be addressed.
50 #
51 # POD documentation is sprinkled throughout the file in an
52 # attempt at Literate Programming style (which Perl partly supports ...
53 # see http://www.literateprogramming.com/ )
54 # Search for the strings '=head' or run perldoc on this file.
55  
56 # You can run this file through either pod2man or pod2html to produce
57 # documentation in manual or html file format
58  
59 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 BEGIN
62 {
63 6 ▶ use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 6 ▶ use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 6 ▶ use constant UNKNOWN => -1;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 6 ▶ use constant HAVE_FLOCK => TRUE; ## some systems still may not have this...manually change
Subroutine BEGIN: called CC=1 SCAR=0.0
68 6 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 6 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 }
71  
72 6 if (HAVE_FLOCK)
73 {
74 6 ▶ use Fcntl q(:flock); # import LOCK_* constants
Subroutine BEGIN: called CC=1 SCAR=0.0
75 }
76  
77 6 ▶no strict qw( refs );
Subroutine BEGIN: called CC=1 SCAR=0.0
78  
79 6 my $isLittleEndian = FALSE; #default - was developed on a BigEndian machine
80 6 ▶$isLittleEndian = TRUE if ($Config{'byteorder'} =~ m/^1/); ## Linux mswin32 cygwin vms
Branch: 1 branch
BranchTrueFalseTotal
if $GDS2::Config{"byteorder"} =~ /^1/ 6 0 6
81  
82 ################################################################################
83 ## GDS2 STREAM RECORD DATATYPES
84 6 ▶use constant NO_REC_DATA => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 6 ▶use constant BIT_ARRAY => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 6 ▶use constant INTEGER_2 => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 6 ▶use constant INTEGER_4 => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 6 ▶use constant REAL_4 => 4; ## NOT supported, should not be found in any GDS2
Subroutine BEGIN: called CC=1 SCAR=0.0
89 6 ▶use constant REAL_8 => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 6 ▶use constant ACSII_STRING => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 ################################################################################
92  
93 ################################################################################
94 ## GDS2 STREAM RECORD TYPES
95 6 ▶use constant HEADER => 0; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
96 6 ▶use constant BGNLIB => 1; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
97 6 ▶use constant LIBNAME => 2; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
98 6 ▶use constant UNITS => 3; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
99 6 ▶use constant ENDLIB => 4; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
100 6 ▶use constant BGNSTR => 5; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
101 6 ▶use constant STRNAME => 6; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
102 6 ▶use constant ENDSTR => 7; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
103 6 ▶use constant BOUNDARY => 8; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
104 6 ▶use constant PATH => 9; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
105 6 ▶use constant SREF => 10; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
106 6 ▶use constant AREF => 11; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
107 6 ▶use constant TEXT => 12; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
108 6 ▶use constant LAYER => 13; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
109 6 ▶use constant DATATYPE => 14; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
110 6 ▶use constant WIDTH => 15; ## 4-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
111 6 ▶use constant XY => 16; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
112 6 ▶use constant ENDEL => 17; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
113 6 ▶use constant SNAME => 18; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
114 6 ▶use constant COLROW => 19; ## 2 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
115 6 ▶use constant TEXTNODE => 20; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
116 6 ▶use constant NODE => 21; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
117 6 ▶use constant TEXTTYPE => 22; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
118 6 ▶use constant PRESENTATION => 23; ## Bit Array
Subroutine BEGIN: called CC=1 SCAR=0.0
119 6 ▶use constant SPACING => 24; ## discontinued
Subroutine BEGIN: called CC=1 SCAR=0.0
120 6 ▶use constant STRING => 25; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
121 6 ▶use constant STRANS => 26; ## Bit Array
Subroutine BEGIN: called CC=1 SCAR=0.0
122 6 ▶use constant MAG => 27; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
123 6 ▶use constant ANGLE => 28; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
124 6 ▶use constant UINTEGER => 29; ## UNKNOWN User int, used only in Calma V2.0
Subroutine BEGIN: called CC=1 SCAR=0.0
125 6 ▶use constant USTRING => 30; ## UNKNOWN User string, used only in Calma V2.0
Subroutine BEGIN: called CC=1 SCAR=0.0
126 6 ▶use constant REFLIBS => 31; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
127 6 ▶use constant FONTS => 32; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
128 6 ▶use constant PATHTYPE => 33; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
129 6 ▶use constant GENERATIONS => 34; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
130 6 ▶use constant ATTRTABLE => 35; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
131 6 ▶use constant STYPTABLE => 36; ## ASCII String "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
132 6 ▶use constant STRTYPE => 37; ## 2-byte Signed Integer "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
133 6 ▶use constant EFLAGS => 38; ## BIT_ARRAY Flags for template and exterior data. bits 15 to 0, l to r 0=template,
Subroutine BEGIN: called CC=1 SCAR=0.0
134 ## 1=external data, others unused
135 6 ▶use constant ELKEY => 39; ## INTEGER_4 "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
136 6 ▶use constant LINKTYPE => 40; ## UNKNOWN "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
137 6 ▶use constant LINKKEYS => 41; ## UNKNOWN "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
138 6 ▶use constant NODETYPE => 42; ## INTEGER_2 Nodetype specification. On Calma this could be 0 to 63, GDSII allows 0 to 255.
Subroutine BEGIN: called CC=1 SCAR=0.0
139 ## Of course a 2 byte integer allows up to 65535...
140 6 ▶use constant PROPATTR => 43; ## INTEGER_2 Property number.
Subroutine BEGIN: called CC=1 SCAR=0.0
141 6 ▶use constant PROPVALUE => 44; ## STRING Property value. On GDSII, 128 characters max, unless an SREF, AREF, or NODE,
Subroutine BEGIN: called CC=1 SCAR=0.0
142 ## which may have 512 characters.
143 6 ▶use constant BOX => 45; ## NO_DATA The beginning of a BOX element.
Subroutine BEGIN: called CC=1 SCAR=0.0
144 6 ▶use constant BOXTYPE => 46; ## INTEGER_2 Boxtype specification.
Subroutine BEGIN: called CC=1 SCAR=0.0
145 6 ▶use constant PLEX => 47; ## INTEGER_4 Plex number and plexhead flag. The least significant bit of the most significant
Subroutine BEGIN: called CC=1 SCAR=0.0
146 ## byte is the plexhead flag.
147 6 ▶use constant BGNEXTN => 48; ## INTEGER_4 Path extension beginning for pathtype 4 in Calma CustomPlus. In database units,
Subroutine BEGIN: called CC=1 SCAR=0.0
148 ## may be negative.
149 6 ▶use constant ENDEXTN => 49; ## INTEGER_4 Path extension end for pathtype 4 in Calma CustomPlus. In database units, may be negative.
Subroutine BEGIN: called CC=1 SCAR=0.0
150 6 ▶use constant TAPENUM => 50; ## INTEGER_2 Tape number for multi-reel stream file.
Subroutine BEGIN: called CC=1 SCAR=0.0
151 6 ▶use constant TAPECODE => 51; ## INTEGER_2 Tape code to verify that the reel is from the proper set. 12 bytes that are
Subroutine BEGIN: called CC=1 SCAR=0.0
152 ## supposed to form a unique tape code.
153 6 ▶use constant STRCLASS => 52; ## BIT_ARRAY Calma use only.
Subroutine BEGIN: called CC=1 SCAR=0.0
154 6 ▶use constant RESERVED => 53; ## INTEGER_4 Used to be NUMTYPES per Calma GDSII Stream Format Manual, v6.0.
Subroutine BEGIN: called CC=1 SCAR=0.0
155 6 ▶use constant FORMAT => 54; ## INTEGER_2 Archive or Filtered flag. 0: Archive 1: filtered
Subroutine BEGIN: called CC=1 SCAR=0.0
156 6 ▶use constant MASK => 55; ## STRING Only in filtered streams. Layers and datatypes used for mask in a filtered
Subroutine BEGIN: called CC=1 SCAR=0.0
157 ## stream file. A string giving ranges of layers and datatypes separated by a semicolon.
158 ## There may be more than one mask in a stream file.
159 6 ▶use constant ENDMASKS => 56; ## NO_DATA The end of mask descriptions.
Subroutine BEGIN: called CC=1 SCAR=0.0
160 6 ▶use constant LIBDIRSIZE => 57; ## INTEGER_2 Number of pages in library director, a GDSII thing, it seems to have only been
Subroutine BEGIN: called CC=1 SCAR=0.0
161 ## used when Calma INFORM was creating a new library.
162 6 ▶use constant SRFNAME => 58; ## STRING Calma "Sticks"(c) rule file name.
Subroutine BEGIN: called CC=1 SCAR=0.0
163 6 ▶use constant LIBSECUR => 59; ## INTEGER_2 Access control list stuff for CalmaDOS, ancient. INFORM used this when creating
Subroutine BEGIN: called CC=1 SCAR=0.0
164 ## a new library. Had 1 to 32 entries with group numbers, user numbers and access rights.
165 #################################################################################################
166 6 ▶use vars '$StrSpace';
Subroutine BEGIN: called CC=1 SCAR=0.0
167 6 ▶use vars '$ElmSpace';
Subroutine BEGIN: called CC=1 SCAR=0.0
168 6 $StrSpace='';
169 6 $ElmSpace='';
170  
171 6 my %RecordTypeNumbers=(
172 'HEADER' => HEADER,
173 'BGNLIB' => BGNLIB,
174 'LIBNAME' => LIBNAME,
175 'UNITS' => UNITS,
176 'ENDLIB' => ENDLIB,
177 'BGNSTR' => BGNSTR,
178 'STRNAME' => STRNAME,
179 'ENDSTR' => ENDSTR,
180 'BOUNDARY' => BOUNDARY,
181 'PATH' => PATH,
182 'SREF' => SREF,
183 'AREF' => AREF,
184 'TEXT' => TEXT,
185 'LAYER' => LAYER,
186 'DATATYPE' => DATATYPE,
187 'WIDTH' => WIDTH,
188 'XY' => XY,
189 'ENDEL' => ENDEL,
190 'SNAME' => SNAME,
191 'COLROW' => COLROW,
192 'TEXTNODE' => TEXTNODE,
193 'NODE' => NODE,
194 'TEXTTYPE' => TEXTTYPE,
195 'PRESENTATION'=> PRESENTATION,
196 'SPACING' => SPACING,
197 'STRING' => STRING,
198 'STRANS' => STRANS,
199 'MAG' => MAG,
200 'ANGLE' => ANGLE,
201 'UINTEGER' => UINTEGER,
202 'USTRING' => USTRING,
203 'REFLIBS' => REFLIBS,
204 'FONTS' => FONTS,
205 'PATHTYPE' => PATHTYPE,
206 'GENERATIONS' => GENERATIONS,
207 'ATTRTABLE' => ATTRTABLE,
208 'STYPTABLE' => STYPTABLE,
209 'STRTYPE' => STRTYPE,
210 'EFLAGS' => EFLAGS,
211 'ELKEY' => ELKEY,
212 'LINKTYPE' => LINKTYPE,
213 'LINKKEYS' => LINKKEYS,
214 'NODETYPE' => NODETYPE,
215 'PROPATTR' => PROPATTR,
216 'PROPVALUE' => PROPVALUE,
217 'BOX' => BOX,
218 'BOXTYPE' => BOXTYPE,
219 'PLEX' => PLEX,
220 'BGNEXTN' => BGNEXTN,
221 'ENDEXTN' => ENDEXTN,
222 'TAPENUM' => TAPENUM,
223 'TAPECODE' => TAPECODE,
224 'STRCLASS' => STRCLASS,
225 'RESERVED' => RESERVED,
226 'FORMAT' => FORMAT,
227 'MASK' => MASK,
228 'ENDMASKS' => ENDMASKS,
229 'LIBDIRSIZE' => LIBDIRSIZE,
230 'SRFNAME' => SRFNAME,
231 'LIBSECUR' => LIBSECUR,
232 );
233  
234 6 my @RecordTypeStrings=( ## for ascii print of GDS
235 'HEADER',
236 'BGNLIB',
237 'LIBNAME',
238 'UNITS',
239 'ENDLIB',
240 'BGNSTR',
241 'STRNAME',
242 'ENDSTR',
243 'BOUNDARY',
244 'PATH',
245 'SREF',
246 'AREF',
247 'TEXT',
248 'LAYER',
249 'DATATYPE',
250 'WIDTH',
251 'XY',
252 'ENDEL',
253 'SNAME',
254 'COLROW',
255 'TEXTNODE',
256 'NODE',
257 'TEXTTYPE',
258 'PRESENTATION',
259 'SPACING',
260 'STRING',
261 'STRANS',
262 'MAG',
263 'ANGLE',
264 'UINTEGER',
265 'USTRING',
266 'REFLIBS',
267 'FONTS',
268 'PATHTYPE',
269 'GENERATIONS',
270 'ATTRTABLE',
271 'STYPTABLE',
272 'STRTYPE',
273 'EFLAGS',
274 'ELKEY',
275 'LINKTYPE',
276 'LINKKEYS',
277 'NODETYPE',
278 'PROPATTR',
279 'PROPVALUE',
280 'BOX',
281 'BOXTYPE',
282 'PLEX',
283 'BGNEXTN',
284 'ENDEXTN',
285 'TAPENUM',
286 'TAPECODE',
287 'STRCLASS',
288 'RESERVED',
289 'FORMAT',
290 'MASK',
291 'ENDMASKS',
292 'LIBDIRSIZE',
293 'SRFNAME',
294 'LIBSECUR',
295 );
296 6 my @CompactRecordTypeStrings=( ## for compact ascii print of GDS (GDT format) see http://sourceforge.net/projects/gds2/
297 'gds2{', #HEADER
298 '', #BGNLIB
299 'lib', #LIBNAME
300 '', #UNITS
301 '}', #ENDLIB
302 'cell{', #BGNSTR
303 '', #STRNAME
304 '}', #ENDSTR
305 'b{', #BOUNDARY
306 'p{', #PATH
307 's{', #SREF
308 'a{', #AREF
309 't{', #TEXT
310 '', #LAYER
311 ' dt', #DATATYPE
312 ' w', #WIDTH
313 ' xy(', #XY #)
314 '}', #ENDEL
315 '', #SNAME
316 ' cr', #COLROW
317 ' tn', #TEXTNODE
318 ' no', #NODE
319 ' tt', #TEXTTYPE
320 '', #PRESENTATION'
321 ' sp', #SPACING
322 '', #STRING
323 '', #STRANS
324 ' m', #MAG
325 ' a', #ANGLE
326 ' ui', #UINTEGER
327 ' us', #USTRING
328 ' rl', #REFLIBS
329 ' f', #FONTS
330 ' pt', #PATHTYPE
331 ' gen', #GENERATIONS
332 ' at', #ATTRTABLE
333 ' st', #STYPTABLE
334 ' strt', #STRTYPE
335 ' ef', #EFLAGS
336 ' ek', #ELKEY
337 ' lt', #LINKTYPE
338 ' lk', #LINKKEYS
339 ' nt', #NODETYPE
340 ' ptr', #PROPATTR
341 ' pv', #PROPVALUE
342 ' bx', #BOX
343 ' bt', #BOXTYPE
344 ' px', #PLEX
345 ' bx', #BGNEXTN
346 ' ex', #ENDEXTN
347 ' tnum', #TAPENUM
348 ' tcode', #TAPECODE
349 ' strc', #STRCLASS
350 ' resv', #RESERVED
351 ' fmt', #FORMAT
352 ' msk', #MASK
353 ' emsk', #ENDMASKS
354 ' lds', #LIBDIRSIZE
355 ' srfn', #SRFNAME
356 ' libs', #LIBSECUR
357 );
358  
359 ###################################################
360 6 my %RecordTypeData=(
361 'HEADER' => INTEGER_2,
362 'BGNLIB' => INTEGER_2,
363 'LIBNAME' => ACSII_STRING,
364 'UNITS' => REAL_8,
365 'ENDLIB' => NO_REC_DATA,
366 'BGNSTR' => INTEGER_2,
367 'STRNAME' => ACSII_STRING,
368 'ENDSTR' => NO_REC_DATA,
369 'BOUNDARY' => NO_REC_DATA,
370 'PATH' => NO_REC_DATA,
371 'SREF' => NO_REC_DATA,
372 'AREF' => NO_REC_DATA,
373 'TEXT' => NO_REC_DATA,
374 'LAYER' => INTEGER_2,
375 'DATATYPE' => INTEGER_2,
376 'WIDTH' => INTEGER_4,
377 'XY' => INTEGER_4,
378 'ENDEL' => NO_REC_DATA,
379 'SNAME' => ACSII_STRING,
380 'COLROW' => INTEGER_2,
381 'TEXTNODE' => NO_REC_DATA,
382 'NODE' => NO_REC_DATA,
383 'TEXTTYPE' => INTEGER_2,
384 'PRESENTATION' => BIT_ARRAY,
385 'SPACING' => UNKNOWN, #INTEGER_4, discontinued
386 'STRING' => ACSII_STRING,
387 'STRANS' => BIT_ARRAY,
388 'MAG' => REAL_8,
389 'ANGLE' => REAL_8,
390 'UINTEGER' => UNKNOWN, #INTEGER_4, no longer used
391 'USTRING' => UNKNOWN, #ACSII_STRING, no longer used
392 'REFLIBS' => ACSII_STRING,
393 'FONTS' => ACSII_STRING,
394 'PATHTYPE' => INTEGER_2,
395 'GENERATIONS' => INTEGER_2,
396 'ATTRTABLE' => ACSII_STRING,
397 'STYPTABLE' => ACSII_STRING, # unreleased feature
398 'STRTYPE' => INTEGER_2, #INTEGER_2, unreleased feature
399 'EFLAGS' => BIT_ARRAY,
400 'ELKEY' => INTEGER_4, #INTEGER_4, unreleased feature
401 'LINKTYPE' => INTEGER_2, #unreleased feature
402 'LINKKEYS' => INTEGER_4, #unreleased feature
403 'NODETYPE' => INTEGER_2,
404 'PROPATTR' => INTEGER_2,
405 'PROPVALUE' => ACSII_STRING,
406 'BOX' => NO_REC_DATA,
407 'BOXTYPE' => INTEGER_2,
408 'PLEX' => INTEGER_4,
409 'BGNEXTN' => INTEGER_4,
410 'ENDEXTN' => INTEGER_4,
411 'TAPENUM' => INTEGER_2,
412 'TAPECODE' => INTEGER_2,
413 'STRCLASS' => UNKNOWN,
414 'RESERVED' => INTEGER_4,
415 'FORMAT' => INTEGER_2,
416 'MASK' => ACSII_STRING,
417 'ENDMASKS' => NO_REC_DATA,
418 'LIBDIRSIZE' => UNKNOWN, #INTEGER_2
419 'SRFNAME' => ACSII_STRING,
420 'LIBSECUR' => UNKNOWN, #INTEGER_2,
421 );
422  
423 # This is the default class for the GDS2 object to use when all else fails.
424 6 ▶$GDS2::DefaultClass = 'GDS2' unless defined $GDS2::DefaultClass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $GDS2::DefaultClass 6 0 6
425  
426 6 my $G_gdtString="";
427 6 my $G_epsilon="0.001"; ## to take care of floating point representation problems
428 6 my $G_fltLen=3;
429 { #it's own name space...
430 6 my $fltLenTmp = sprintf("%0.99f",(1.0/3.0)); $fltLenTmp=~s/^0.(3+).*/$1/; $fltLenTmp = length($fltLenTmp) - 10;
431 6 ▶ if ($fltLenTmp > length($G_epsilon)) # try to make smaller if we can...
Branch: 1 branch
BranchTrueFalseTotal
if ($fltLenTmp > length $G_epsilon) 6 0 6
432 {
433 6 $G_epsilon = sprintf("%0.${fltLenTmp}f1",0);
434 6 $G_fltLen = $fltLenTmp;
435 }
436 }
437 6 $G_epsilon *= 1; #ensure it's a number
438  
439 ################################################################################
440  
441 =head1 Examples
442  
443 Layer change:
444 here's a bare bones script to change all layer 59 to 66 given a file to
445 read and a new file to create.
446 #!/usr/bin/perl -w
447 use strict;
448 use GDS2;
449 my $fileName1 = $ARGV[0];
450 my $fileName2 = $ARGV[1];
451 my $gds2File1 = new GDS2(-fileName => $fileName1);
452 my $gds2File2 = new GDS2(-fileName => ">$fileName2");
453 while (my $record = $gds2File1 -> readGds2Record)
454 {
455 if ($gds2File1 -> returnLayer == 59)
456 {
457 $gds2File2 -> printLayer(-num=>66);
458 }
459 else
460 {
461 $gds2File2 -> printRecord(-data=>$record);
462 }
463 }
464  
465  
466 Gds2 dump:
467 here's a complete program to dump the contents of a stream file.
468 #!/usr/bin/perl -w
469 use GDS2;
470 $\="\n";
471 my $gds2File = new GDS2(-fileName=>$ARGV[0]);
472 while ($gds2File -> readGds2Record)
473 {
474 print $gds2File -> returnRecordAsString;
475 }
476  
477  
478 Gds2 dump in GDT format: which is smaller and easier to parse - http://sourceforge.net/projects/gds2/
479 #!/usr/bin/perl -w
480 use GDS2;
481 my $gds2File = new GDS2(-fileName=>$ARGV[0]);
482 while ($gds2File -> readGds2Record)
483 {
484 print $gds2File -> returnRecordAsString(-compact=>1);
485 }
486  
487 Dump from the command line of a bzip2 compressed file:
488 perl -MGDS2 -MFileHandle -MIPC::Open3 -e '$f1=new FileHandle;$f0=new FileHandle;open3($f0,$f1,$f1,"bzcat test.gds.bz2");$gds=new GDS2(-fileHandle=>$f1);while($gds->readGds2Record){print $gds->returnRecordAsString(-compact=>1)}'
489  
490 Create a complete GDS2 stream file from scratch:
491 #!/usr/bin/perl -w
492 use GDS2;
493 my $gds2File = new GDS2(-fileName=>'>test.gds');
494 $gds2File -> printInitLib(-name=>'testlib');
495 $gds2File -> printBgnstr(-name=>'test');
496 $gds2File -> printPath(
497 -layer=>6,
498 -pathType=>0,
499 -width=>2.4,
500 -xy=>[0,0, 10.5,0, 10.5,3.3],
501 );
502 $gds2File -> printSref(
503 -name=>'contact',
504 -xy=>[4,5.5],
505 );
506 $gds2File -> printAref(
507 -name=>'contact',
508 -columns=>2,
509 -rows=>3,
510 -xy=>[0,0, 10,0, 0,15],
511 );
512 $gds2File -> printEndstr;
513 $gds2File -> printBgnstr(-name => 'contact');
514 $gds2File -> printBoundary(
515 -layer=>10,
516 -xy=>[0,0, 1,0, 1,1, 0,1],
517 );
518 $gds2File -> printEndstr;
519 $gds2File -> printEndlib();
520  
521 ################################################################################
522  
523 =head1 METHODS
524  
525 =head2 new - open gds2 file
526  
527 usage:
528 my $gds2File = new GDS2(-fileName => "filename.gds2"); ## to read
529 my $gds2File2 = new GDS2(-fileName => ">filename.gds2"); ## to write
530  
531 -or- provide your own fileHandle:
532  
533 my $gds2File = new GDS2(-fileHandle => $fh); ## e.g. to attach to a compression/decompression pipe
534  
535 =cut
536  
537 sub new
538 8 ▶{
Subroutine new: called CC=18 SCAR=32.5
Pod documented
539 8 my($class,%arg) = @_;
540 8 my $self = {};
541 8 ▶ bless $self,$class || ref $class || $GDS2::DefaultClass;
Condition33%2/6
$class || ref $class || $GDS2::DefaultClass
l!l&&r!l&&!r
800
$class or ref $class
l!l&&r!l&&!r
800
MC/DC0%0/3
$class || ref $class || $GDS2::DefaultClass
$class ref $class $GDS2::DefaultClass
Truth table25%1/4
A or B || C
A= $classB= ref $classC= $GDS2::DefaultClass
ABCresult
1XX1
01X1
0011
0000
542  
543 8 my $fileName = $arg{'-fileName'};
544 8 ▶ $fileName = "" unless (defined $fileName);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fileName 0 8 8
545  
546 8 my $fileHandle = $arg{'-fileHandle'};
547 8 ▶ $fileHandle = "" unless (defined $fileHandle);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fileHandle 8 0 8
548  
549 8 ▶ if ($fileName && $fileHandle)
Branch: 1 branch
BranchTrueFalseTotal
if ($fileName and $fileHandle) 0 8 8
Condition33%1/3
$fileName and $fileHandle
!ll&&!rl&&r
080
MC/DC0%0/2
$fileName and $fileHandle
$fileName $fileHandle
Truth table33%1/3
A and B
A= $fileNameB= $fileHandle
ABresult
0X0
100
111
550 {
551 0 die "new expects a gds2 file name -OR- a file handle. Do not give both.";
552 }
553 8 ▶ unless ($fileName || $fileHandle)
Branch: 1 branch
BranchTrueFalseTotal
unless ($fileName or $fileHandle) 0 8 8
Condition33%1/3
$fileName or $fileHandle
l!l&&r!l&&!r
800
MC/DC0%0/2
$fileName or $fileHandle
$fileName $fileHandle
Truth table33%1/3
A or B
A= $fileNameB= $fileHandle
ABresult
1X1
011
000
554 {
555 0 die "new expects a -fileName => 'name' OR and -fileHandle => fh $!";
556 }
557 8 my $lockMode = LOCK_SH; ## default
558 8 ▶ if ($fileName)
Branch: 1 branch
BranchTrueFalseTotal
if ($fileName) 8 0 8
559 {
560 8 my $openModStr = substr($fileName,0,2); ### looking for > or >>
561 8 $openModStr =~ s|^\s+||;
562 8 $openModStr =~ s|[^\+>]+||g;
563 8 my $openModeNum = O_RDONLY;
564 8 ▶ if ($openModStr =~ m|^\+|)
Branch: 1 branch
BranchTrueFalseTotal
if ($openModStr =~ /^\+/) 0 8 8
565 {
566 0 warn("Ignoring '+' in open mode"); ## not handling this yet...
567 0 $openModStr =~ s|\++||;
568 }
569 8 ▶ if ($openModStr eq '>')
Branch: 2 branches
BranchTrueFalseTotal
if ($openModStr eq '>') { } 5 3 8
elsif ($openModStr eq '>>') { } 0 3 3
570 {
571 5 $openModeNum = O_WRONLY|O_CREAT;
572 5 $lockMode = LOCK_EX;
573 5 $fileName =~ s|^$openModStr||;
574 }
575 elsif ($openModStr eq '>>')
576 {
577 0 $openModeNum = O_WRONLY|O_APPEND;
578 0 $lockMode = LOCK_EX;
579 0 $fileName =~ s|^$openModStr||;
580 }
581 8 $fileHandle = new IO::File;
582 8 ▶ $fileHandle -> open("$fileName",$openModeNum) or die "Unable to open $fileName because $!";
Branch: 1 branch
BranchTrueFalseTotal
$fileHandle->open("$fileName", $openModeNum) or die "Unable to open $fileName because $!" 8 0 8
583 8 if (HAVE_FLOCK)
584 {
585 8 ▶ flock($fileHandle,$lockMode) or die "File lock on $fileName failed because $!";
Branch: 1 branch
BranchTrueFalseTotal
flock $fileHandle, $lockMode or die "File lock on $fileName failed because $!" 8 0 8
586 }
587 }
588 8 my $resolution = $arg{'-resolution'};
589 8 ▶ unless (defined $resolution)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $resolution) 8 0 8
590 {
591 8 $resolution=1000;
592 }
593 8 ▶ die "new expects a positive integer resolution. ($resolution) $!" if (($resolution <= 0) || ($resolution !~ m|^\d+$|));
Branch: 1 branch
BranchTrueFalseTotal
if $resolution <= 0 or not $resolution =~ /^\d+$/ 0 8 8
Condition33%1/3
$resolution <= 0 or not $resolution =~ /^\d+$/
l!l&&r!l&&!r
008
MC/DC0%0/2
$resolution <= 0 or not $resolution =~ /^\d+$/
$resolution <= 0 not $resolution =~ /^\d+$/
Truth table33%1/3
A or not(B)
A= $resolution <= 0B= not $resolution =~ /^\d+$/
ABresult
1X1
011
000
594 8 binmode $fileHandle,':raw';
595 8 $self -> {'Fd'} = $fileHandle -> fileno;
596 8 $self -> {'FileHandle'} = $fileHandle;
597 8 $self -> {'FileName'} = $fileName; ## the gds2 filename
598 8 $self -> {'BytesDone'} = 0; ## total file size so far
599 8 $self -> {'EOLIB'} = FALSE; ## end of library flag
600 8 $self -> {'INHEADER'} = UNKNOWN; ## in header? flag TRUE | FALSE | UNKNOWN
601 8 $self -> {'INDATA'} = FALSE; ## in data? flag TRUE | FALSE
602 8 $self -> {'Length'} = 0; ## length of data
603 8 $self -> {'DataType'} = UNKNOWN; ## one of 7 gds datatypes
604 8 $self -> {'UUnits'} = -1.0; ## for gds2 file e.g. 0.001
605 8 $self -> {'DBUnits'} = -1.0; ## for gds2 file e.g. 1e-9
606 8 $self -> {'Record'} = ''; ## the whole record as found in gds2 file
607 8 $self -> {'RecordType'} = UNKNOWN;
608 8 $self -> {'DataIndex'} = 0;
609 8 $self -> {'RecordData'} = ();
610 8 $self -> {'CurrentDataList'} = '';
611 8 $self -> {'InBoundary'} = FALSE; ##
612 8 $self -> {'InTxt'} = FALSE; ##
613 8 $self -> {'DateFld'} = 0; ##
614 8 $self -> {'Resolution'} = $resolution;
615 8 $self -> {'UsingPrettyPrint'} = FALSE; ## print as string ...
616 8 $self;
617 }
618 ################################################################################
619  
620 #######
621 #private method to check how accurately users perl can do math
622 sub getG_epsilon
623 4 ▶{
Subroutine getG_epsilon: called CC=1 SCAR=0.0
Pod undocumented
624 4 my($self,%arg) = @_;
625 4 $G_epsilon;
626 }
627 ################################################################################
628  
629 #######
630 #private method to check how accurately users perl can do math
631 sub getG_fltLen
632 4 ▶{
Subroutine getG_fltLen: called CC=1 SCAR=0.0
Pod undocumented
633 4 my($self,%arg) = @_;
634 4 $G_fltLen;
635 }
636 ################################################################################
637  
638 #######
639 #private method to report Endianness
640 sub endianness
641 2 ▶{
Subroutine endianness: called CC=1 SCAR=0.0
Pod undocumented
642 2 my($self,%arg) = @_;
643 2 $isLittleEndian;
644 }
645 ################################################################################
646  
647 #######
648 #private method to clean up number
649 sub cleanExpNum($)
650 3 ▶{
Subroutine cleanExpNum: called CC=1 SCAR=0.0
Pod undocumented
651 3 my $num = shift;
652 3 $num = sprintf("%0.${G_fltLen}e",$num);
653 3 $num =~ s/([1-9])0+e/$1e/;
654 3 $num =~ s/(\d)\.0+e/$1e/;
655 3 $num;
656 }
657 ################################################################################
658  
659 #######
660 #private method to clean up number
661 sub cleanFloatNum($)
662 189 ▶{
Subroutine cleanFloatNum: called CC=1 SCAR=0.0
Pod undocumented
663 189 my $num = shift;
664 189 $num = sprintf("%0.${G_fltLen}f",$num);
665 189 $num =~ s/([1-9])0+$/$1/;
666 189 $num =~ s/(\d)\.0+$/$1/;
667 189 $num;
668 }
669 ################################################################################
670  
671 =head2 fileNum - file number...
672  
673 usage:
674  
675 =cut
676  
677 sub fileNum
678 0 ▶{
Subroutine fileNum: not called CC=1 SCAR=6.9
Pod documented
679 0 my($self,%arg) = @_;
680 0 int($self -> {'Fd'});
681 }
682 ################################################################################
683  
684 =head2 close - close gds2 file
685  
686 usage:
687 $gds2File -> close;
688 -or-
689 $gds2File -> close(-markEnd=>1); ## -- some systems have trouble closing files
690 $gds2File -> close(-pad=>2048); ## -- pad end with \0's till file size is a
691 ## multiple of number. Note: old reel to reel tapes on Calma
692 ## systems used 2048 byte blocks
693  
694 =cut
695  
696 sub close
697 5 ▶{
Subroutine close: called CC=7 SCAR=20.6
Pod documented
698 5 my($self,%arg) = @_;
699 5 my $markEnd = $arg{'-markEnd'};
700 5 my $pad = $arg{'-pad'};
701 5 ▶ if ((defined $markEnd)&&($markEnd))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $markEnd and $markEnd) 0 5 5
Condition33%1/3
defined $markEnd and $markEnd
!ll&&!rl&&r
500
MC/DC0%0/2
defined $markEnd and $markEnd
defined $markEnd $markEnd
Truth table33%1/3
A and B
A= defined $markEndB= $markEnd
ABresult
0X0
100
111
702 {
703 0 my $fh = $self -> {'FileHandle'};
704 0 print $fh "\x1a\x04"; # a ^Z and a ^D
705 0 $self -> {'BytesDone'} += 2;
706 }
707 5 ▶ if ((defined $pad)&&($pad > 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pad and $pad > 0) 1 4 5
Condition66%2/3
defined $pad and $pad > 0
!ll&&!rl&&r
401
MC/DC50%1/2
defined $pad and $pad > 0
defined $pad $pad > 0
Truth table66%2/3
A and B
A= defined $padB= $pad > 0
ABresult
0X0
100
111
708 {
709 1 my $fh = $self -> {'FileHandle'};
710 1 $fh -> flush;
711 1 seek($fh,0,SEEK_END);
712 1 my $fileSize = tell($fh);
713 1 my $padSize = $pad - ($fileSize % $pad);
714 1 ▶ $padSize=0 if ($padSize == $pad);
Branch: 1 branch
BranchTrueFalseTotal
if $padSize == $pad 0 1 1
715 1 ▶ for (my $i=0; $i < $padSize; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $padSize) 1702 1 1703
716 {
717 1702 print $fh "\0"; ## a null
718 }
719 }
720 5 $self -> {'FileHandle'} -> close;
721 }
722 ################################################################################
723  
724 ################################################################################
725  
726 =head1 High Level Write Methods
727  
728 =cut
729  
730 ################################################################################
731  
732 =head2 printInitLib() - Does all the things needed to start a library, writes HEADER,BGNLIB,LIBNAME,and UNITS records
733  
734 The default is to create a library with a default unit of 1 micron that has a resolution of 1000. To get this set uUnit to 0.001 (1/1000) and the dbUnit to 1/1000th of a micron (1e-9).
735 usage:
736 $gds2File -> printInitLib(-name => "testlib", ## required
737 -isoDate => 0|1 ## (optional) use ISO 4 digit date 2001 vs 101
738 -uUnit => real number ## (optional) default is 0.001
739 -dbUnit => real number ## (optional) default is 1e-9
740 );
741  
742 ## defaults to current date for library date
743  
744 note:
745 remember to close library with printEndlib()
746  
747 =cut
748  
749 sub printInitLib
750 2 ▶{
Subroutine printInitLib: called CC=7 SCAR=21.0
Pod documented
751 2 my($self,%arg) = @_;
752 2 my $libName = $arg{'-name'};
753 2 ▶ unless (defined $libName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $libName) 0 2 2
754 {
755 0 die "printInitLib expects a library name. Missing -name => 'name' $!";
756 }
757 #################################################
758 2 my $isoDate = $arg{'-isoDate'};
759 2 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 2 0 2
elsif ($isoDate != 0) { } 0 0 0
760 {
761 2 $isoDate = FALSE;
762 }
763 elsif ($isoDate != 0)
764 {
765 0 $isoDate = TRUE;
766 }
767  
768 #################################################
769 2 my $uUnit = $arg{'-uUnit'};
770 2 ▶ if (! defined $uUnit)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $uUnit) { } 2 0 2
771 {
772 2 $uUnit = 0.001;
773 }
774 else
775 {
776 0 $self -> {'Resolution'} = cleanFloatNum(1 / $uUnit); ## default is 1000 - already set in new()
777 }
778 2 $self -> {'UUnits'} = $uUnit;
779  
780 #################################################
781 2 my $dbUnit = $arg{'-dbUnit'};
782 2 ▶ $dbUnit = 1e-9 unless (defined $dbUnit);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dbUnit 2 0 2
783 2 $self -> {'DBUnits'} = $dbUnit;
784 #################################################
785  
786 2 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
787 2 $mon++;
788 2 ▶ $year += 1900 if ($isoDate); ## Cadence likes year left "as is". GDS format supports year number up to 65535 -- 101 vs 2001
Branch: 1 branch
BranchTrueFalseTotal
if $isoDate 0 2 2
789 2 $self -> printGds2Record(-type => 'HEADER',-data => 3); ## GDS2 HEADER
790 2 $self -> printGds2Record(-type => 'BGNLIB',-data => [$year,$mon,$mday,$hour,$min,$sec,$year,$mon,$mday,$hour,$min,$sec]);
791 2 $self -> printGds2Record(-type => 'LIBNAME',-data => $libName);
792 2 $self -> printGds2Record(-type => 'UNITS',-data => [$uUnit,$dbUnit]);
793 }
794 ################################################################################
795  
796 =head2 printBgnstr - Does all the things needed to start a structure definition
797  
798 usage:
799 $gds2File -> printBgnstr(-name => "nand3" ## writes BGNSTR and STRNAME records
800 -isoDate => 1|0 ## (optional) use ISO 4 digit date 2001 vs 101
801 );
802  
803 note:
804 remember to close with printEndstr()
805  
806 =cut
807  
808 sub printBgnstr
809 4 ▶{
Subroutine printBgnstr: called CC=7 SCAR=22.1
Pod documented
810 4 my($self,%arg) = @_;
811  
812 4 my $strName = $arg{'-name'};
813 4 ▶ unless (defined $strName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $strName) 0 4 4
814 {
815 0 die "bgnStr expects a structure name. Missing -name => 'name' $!";
816 }
817 4 my $createTime = $arg{'-createTime'};
818 4 my $isoDate = $arg{'-isoDate'};
819 4 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 4 0 4
elsif ($isoDate != 0) { } 0 0 0
820 {
821 4 $isoDate = FALSE;
822 }
823 elsif ($isoDate != 0)
824 {
825 0 $isoDate = TRUE;
826 }
827 4 my ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst);
828 4 ▶ if (defined $createTime)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $createTime) { } 0 4 4
829 {
830 0 ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime($createTime);
831 }
832 else
833 {
834 4 ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime(time);
835 }
836 4 $cmon++;
837  
838 4 my $modTime = $arg{'-modTime'};
839 4 my ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst);
840 4 ▶ if (defined $modTime)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $modTime) { } 0 4 4
841 {
842 0 ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst) = localtime($modTime);
843 }
844 else
845 {
846 4 ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst) = localtime(time);
847 }
848 4 $mmon++;
849  
850 4 ▶ if ($isoDate)
Branch: 1 branch
BranchTrueFalseTotal
if ($isoDate) 0 4 4
851 {
852 0 $cyear += 1900; ## 2001 vs 101
853 0 $myear += 1900;
854 }
855 4 $self -> printGds2Record(-type => 'BGNSTR',-data => [$cyear,$cmon,$cmday,$chour,$cmin,$csec,$myear,$mmon,$mmday,$mhour,$mmin,$msec]);
856 4 $self -> printGds2Record(-type => 'STRNAME',-data => $strName);
857 }
858 ################################################################################
859  
860 =head2 printPath - prints a gds2 path
861  
862 usage:
863 $gds2File -> printPath(
864 -layer=>#,
865 -dataType=>#, ##optional
866 -pathType=>#,
867 -width=>#.#,
868 -unitWidth=>#, ## (optional) directly specify width in data base units (vs -width which is multipled by resolution)
869  
870 -xy=>\@array, ## array of reals
871 # -or-
872 -xyInt=>\@array, ## array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
873 );
874  
875 note:
876 layer defaults to 0 if -layer not used
877 pathType defaults to 0 if -pathType not used
878 pathType 0 = square end
879 1 = round end
880 2 = square - extended 1/2 width
881 4 = custom plus variable path extension...
882 width defaults to 0.0 if -width not used
883  
884 =cut
885  
886 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
887 # <path>::= PATH [ELFLAGS] [PLEX] LAYER DATATYPE [PATHTYPE] [WIDTH] XY
888 sub printPath
889 2 ▶{
Subroutine printPath: called CC=38 SCAR=60.2
Pod documented
890 2 my($self,%arg) = @_;
891 2 my $resolution = $self -> {'Resolution'};
892 2 my $layer = $arg{'-layer'};
893 2 ▶ $layer=0 unless ( defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 2 2
894  
895 2 my $dataType = $arg{'-dataType'};
896 2 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 2 0 2
897  
898 2 my $pathType = $arg{'-pathType'};
899 2 ▶ $pathType=0 unless (defined $pathType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pathType 0 2 2
900  
901 2 my $bgnExtn = $arg{'-bgnExtn'};
902 2 ▶ $bgnExtn=0 unless (defined $bgnExtn);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bgnExtn 2 0 2
903  
904 2 my $endExtn = $arg{'-endExtn'};
905 2 ▶ $endExtn=0 unless (defined $endExtn);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $endExtn 2 0 2
906  
907 2 my $unitWidth = $arg{'-unitWidth'};
908 2 my $widthReal = $arg{'-width'};
909 2 my $width = 0;
910 2 ▶ if ((defined $unitWidth)&&($unitWidth >= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $unitWidth and $unitWidth >= 0) 0 2 2
Condition33%1/3
defined $unitWidth and $unitWidth >= 0
!ll&&!rl&&r
200
MC/DC0%0/2
defined $unitWidth and $unitWidth >= 0
defined $unitWidth $unitWidth >= 0
Truth table33%1/3
A and B
A= defined $unitWidthB= $unitWidth >= 0
ABresult
0X0
100
111
911 {
912 0 $width=int($unitWidth);
913 }
914 2 ▶ if ((defined $widthReal)&&($widthReal >= 0.0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $widthReal and $widthReal >= 0) 2 0 2
Condition33%1/3
defined $widthReal and $widthReal >= 0
!ll&&!rl&&r
002
MC/DC0%0/2
defined $widthReal and $widthReal >= 0
defined $widthReal $widthReal >= 0
Truth table33%1/3
A and B
A= defined $widthRealB= $widthReal >= 0
ABresult
0X0
100
111
915 {
916 2 $width = int(($widthReal*$resolution)+$G_epsilon);
917 }
918 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
919 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
920 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
921 2 my @xyTmp=(); ##don't pollute array passed in
922 2 ▶ if (! ((defined $xy) || (defined $xyInt)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
923 {
924 0 die "printPath expects an xy array reference. Missing -xy => \\\@array $!";
925 }
926 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
927 {
928 0 $xy = $xyInt;
929 0 $resolution=1;
930 }
931 2 $self -> printGds2Record(-type => 'PATH');
932 2 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
933 2 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
934 2 ▶ $self -> printGds2Record(-type => 'PATHTYPE',-data => $pathType) if ($pathType);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType 0 2 2
935 2 ▶ $self -> printGds2Record(-type => 'WIDTH',-data => $width) if ($width);
Branch: 1 branch
BranchTrueFalseTotal
if $width 2 0 2
936 2 ▶ if ($pathType == 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($pathType == 4) 0 2 2
937 {
938 0 $self -> printGds2Record(-type => 'BGNEXTN',-data => $bgnExtn); ## int used with resolution
939 0 $self -> printGds2Record(-type => 'ENDEXTN',-data => $endExtn); ## int used with resolution
940 }
941 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 12 2 14
942 {
943 12 ▶ if ($xy -> [$i] >= 0) { push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 12 0 12
944 0 else { push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
945 }
946 2 ▶ if ($bgnExtn || $endExtn) ## we have to convert
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnExtn or $endExtn) 0 2 2
Condition33%1/3
$bgnExtn or $endExtn
l!l&&r!l&&!r
002
MC/DC0%0/2
$bgnExtn or $endExtn
$bgnExtn $endExtn
Truth table33%1/3
A or B
A= $bgnExtnB= $endExtn
ABresult
1X1
011
000
947 {
948 0 my $bgnX1 = $xyTmp[0];
949 0 my $bgnY1 = $xyTmp[1];
950 0 my $bgnX2 = $xyTmp[2];
951 0 my $bgnY2 = $xyTmp[3];
952 0 my $endX1 = $xyTmp[$#xyTmp - 1];
953 0 my $endY1 = $xyTmp[$#xyTmp];
954 0 my $endX2 = $xyTmp[$#xyTmp - 3];
955 0 my $endY2 = $xyTmp[$#xyTmp - 2];
956 0 ▶ if ($bgnExtn)
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnExtn) 0 0 0
957 {
958 0 ▶ if ($bgnX1 == $bgnX2) #vertical ...modify 1st Y
Branch: 2 branches
BranchTrueFalseTotal
if ($bgnX1 == $bgnX2) { } 0 0 0
elsif ($bgnY1 == $bgnY2) { } 0 0 0
959 {
960 0 ▶ if ($bgnY1 < $bgnY2) ## points down
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnY1 < $bgnY2) { } 0 0 0
961 {
962 0 $xyTmp[1] -= $bgnExtn;
963 0 ▶ $xyTmp[1] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
964 }
965 else ## points up
966 {
967 0 $xyTmp[1] += $bgnExtn;
968 0 ▶ $xyTmp[1] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
969 }
970 }
971 elsif ($bgnY1 == $bgnY2) #horizontal ...modify 1st X
972 {
973 0 ▶ if ($bgnX1 < $bgnX2) ## points left
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnX1 < $bgnX2) { } 0 0 0
974 {
975 0 $xyTmp[0] -= $bgnExtn;
976 0 ▶ $xyTmp[0] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
977 }
978 else ## points up
979 {
980 0 $xyTmp[0] += $bgnExtn;
981 0 ▶ $xyTmp[0] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
982 }
983 }
984 }
985  
986 0 ▶ if ($endExtn)
Branch: 1 branch
BranchTrueFalseTotal
if ($endExtn) 0 0 0
987 {
988 0 ▶ if ($endX1 == $endX2) #vertical ...modify last Y
Branch: 2 branches
BranchTrueFalseTotal
if ($endX1 == $endX2) { } 0 0 0
elsif ($endY1 == $endY2) { } 0 0 0
989 {
990 0 ▶ if ($endY1 < $endY2) ## points down
Branch: 1 branch
BranchTrueFalseTotal
if ($endY1 < $endY2) { } 0 0 0
991 {
992 0 $xyTmp[$#xyTmp] -= $endExtn;
993 0 ▶ $xyTmp[$#xyTmp] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
994 }
995 else ## points up
996 {
997 0 $xyTmp[$#xyTmp] += $endExtn;
998 0 ▶ $xyTmp[$#xyTmp] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
999 }
1000 }
1001 elsif ($endY1 == $endY2) #horizontal ...modify last X
1002 {
1003 0 ▶ if ($endX1 < $endX2) ## points left
Branch: 1 branch
BranchTrueFalseTotal
if ($endX1 < $endX2) { } 0 0 0
1004 {
1005 0 $xyTmp[$#xyTmp - 1] -= $endExtn;
1006 0 ▶ $xyTmp[$#xyTmp - 1] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
1007 }
1008 else ## points up
1009 {
1010 0 $xyTmp[$#xyTmp - 1] += $endExtn;
1011 0 ▶ $xyTmp[$#xyTmp - 1] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
1012 }
1013 }
1014 }
1015 }
1016 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1017 2 $self -> printGds2Record(-type => 'ENDEL');
1018 }
1019 ################################################################################
1020  
1021 =head2 printBoundary - prints a gds2 boundary
1022  
1023 usage:
1024 $gds2File -> printBoundary(
1025 -layer=>#,
1026 -dataType=>#,
1027  
1028 -xy=>\@array, ## ref to array of reals
1029 # -or-
1030 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1031 );
1032  
1033 note:
1034 layer defaults to 0 if -layer not used
1035 dataType defaults to 0 if -dataType not used
1036  
1037 =cut
1038  
1039 # <boundary>::= BOUNDARY [ELFLAGS] [PLEX] LAYER DATATYPE XY
1040 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1041 sub printBoundary
1042 2 ▶{
Subroutine printBoundary: called CC=13 SCAR=29.9
Pod documented
1043 2 my($self,%arg) = @_;
1044 2 my $resolution = $self -> {'Resolution'};
1045 2 my $layer = $arg{'-layer'};
1046 2 ▶ $layer = 0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 2 2
1047 2 my $dataType = $arg{'-dataType'};
1048 2 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 2 0 2
1049 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1050 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1051 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1052 2 my @xyTmp = (); ##don't pollute array passed in
1053 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1054 {
1055 0 die "printBoundary expects an xy array reference. Missing -xy => \\\@array $!";
1056 }
1057 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1058 {
1059 0 $xy = $xyInt;
1060 0 $resolution=1;
1061 }
1062 2 $self -> printGds2Record(-type => 'BOUNDARY');
1063 2 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
1064 2 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
1065 2 ▶ if (my $numPoints=$#$xy+1 < 6)
Branch: 1 branch
BranchTrueFalseTotal
if (my $numPoints = $xy->$#* + 1 < 6) 0 2 2
1066 {
1067 0 die "printBoundary expects an xy array of at leasts 3 coordinates $!";
1068 }
1069 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 16 2 18
1070 {
1071 16 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 16 0 16
1072 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1073 }
1074 ## gds expects square to have 5 coords (closure)
1075 2 ▶ if (($xy -> [0] != ($xy -> [($#$xy - 1)])) || ($xy -> [1] != ($xy -> [$#$xy])))
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]) 2 0 2
Condition33%1/3
$xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]
l!l&&r!l&&!r
020
MC/DC0%0/2
$xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]
$xy->[0] != $$xy[$xy->$#* - 1] $xy->[1] != $$xy[$xy->$#*]
Truth table33%1/3
A or B
A= $xy->[0] != $$xy[$xy->$#* - 1]B= $xy->[1] != $$xy[$xy->$#*]
ABresult
1X1
011
000
1076 {
1077 2 ▶ if ($xy -> [0] >= 0) {push @xyTmp,int((($xy -> [0])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[0] >= 0) { } 2 0 2
1078 0 else {push @xyTmp,int((($xy -> [0])*$resolution)-$G_epsilon);}
1079 2 ▶ if ($xy -> [1] >= 0) {push @xyTmp,int((($xy -> [1])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[1] >= 0) { } 2 0 2
1080 0 else {push @xyTmp,int((($xy -> [1])*$resolution)-$G_epsilon);}
1081 }
1082 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1083 2 $self -> printGds2Record(-type => 'ENDEL');
1084 }
1085 ################################################################################
1086  
1087 =head2 printSref - prints a gds2 Structure REFerence
1088  
1089 usage:
1090 $gds2File -> printSref(
1091 -name=>string, ## Name of structure
1092  
1093 -xy=>\@array, ## ref to array of reals
1094 # -or-
1095 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better than -xy if you are modifying an existing GDS2 file)
1096  
1097 -angle=>#.#, ## (optional) Default is 0.0
1098 -mag=>#.#, ## (optional) Default is 1.0
1099 -reflect=>0|1 ## (optional)
1100 );
1101  
1102 note:
1103 best not to specify angle or mag if not needed
1104  
1105 =cut
1106  
1107 #<SREF>::= SREF [ELFLAGS] [PLEX] SNAME [<strans>] XY
1108 # <strans>::= STRANS [MAG] [ANGLE]
1109 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1110 sub printSref
1111 2 ▶{
Subroutine printSref: called CC=15 SCAR=35.8
Pod documented
1112 2 my($self,%arg) = @_;
1113 2 my $useSTRANS=FALSE;
1114 2 my $resolution = $self -> {'Resolution'};
1115 2 my $sname = $arg{'-name'};
1116 2 ▶ unless (defined $sname)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sname) 0 2 2
1117 {
1118 0 die "printSref expects a name string. Missing -name => 'text' $!";
1119 }
1120 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1121 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1122 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1123 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1124 {
1125 0 die "printSref expects an xy array reference. Missing -xy => \\\@array $!";
1126 }
1127 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1128 {
1129 0 $xy = $xyInt;
1130 0 $resolution=1;
1131 }
1132 2 $self -> printGds2Record(-type => 'SREF');
1133 2 $self -> printGds2Record(-type => 'SNAME',-data => $sname);
1134 2 my $reflect = $arg{'-reflect'};
1135 2 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 2 0 2
Condition33%1/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table33%1/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1136 {
1137 2 $reflect = 0;
1138 }
1139 else
1140 {
1141 0 $reflect = 1;
1142 0 $useSTRANS = TRUE;
1143 }
1144 2 my $mag = $arg{'-mag'};
1145 2 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 2 0 2
Condition33%1/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table33%1/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1146 {
1147 2 $mag=0;
1148 }
1149 else
1150 {
1151 0 $mag = cleanFloatNum($mag);
1152 0 $useSTRANS=TRUE;
1153 }
1154 2 my $angle = $arg{'-angle'};
1155 2 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 2 0 2
1156 {
1157 2 $angle = -1; #not really... just means not specified
1158 }
1159 else
1160 {
1161 0 $angle = posAngle($angle);
1162 0 $useSTRANS = TRUE;
1163 }
1164 2 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 2 2
1165 {
1166 0 my $data = $reflect.'0'x15; ## 16 'bit' string
1167 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
1168 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1169 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1170 }
1171 2 my @xyTmp=(); ##don't pollute array passed in
1172 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 4 2 6
1173 {
1174 4 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 4 0 4
1175 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1176 }
1177 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1178 2 $self -> printGds2Record(-type => 'ENDEL');
1179 }
1180 ################################################################################
1181  
1182 =head2 printAref - prints a gds2 Array REFerence
1183  
1184 usage:
1185 $gds2File -> printAref(
1186 -name=>string, ## Name of structure
1187 -columns=>#, ## Default is 1
1188 -rows=>#, ## Default is 1
1189  
1190 -xy=>\@array, ## ref to array of reals
1191 # -or-
1192 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1193  
1194 -angle=>#.#, ## (optional) Default is 0.0
1195 -mag=>#.#, ## (optional) Default is 1.0
1196 -reflect=>0|1 ## (optional)
1197 );
1198  
1199 note:
1200 best not to specify angle or mag if not needed
1201 xyList: 1st coord: origin, 2nd coord: X of col * xSpacing + origin, 3rd coord: Y of row * ySpacing + origin
1202  
1203 =cut
1204  
1205 #<AREF>::= AREF [ELFLAGS] [PLEX] SNAME [<strans>] COLROW XY
1206 # <strans>::= STRANS [MAG] [ANGLE]
1207 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1208 sub printAref
1209 2 ▶{
Subroutine printAref: called CC=19 SCAR=39.3
Pod documented
1210 2 my($self,%arg) = @_;
1211 2 my $useSTRANS=FALSE;
1212 2 my $resolution = $self -> {'Resolution'};
1213 2 my $sname = $arg{'-name'};
1214 2 ▶ unless (defined $sname)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sname) 0 2 2
1215 {
1216 0 die "printAref expects a sname string. Missing -name => 'text' $!";
1217 }
1218 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1219 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1220 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1221 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1222 {
1223 0 die "printAref expects an xy array reference. Missing -xy => \\\@array $!";
1224 }
1225 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1226 {
1227 0 $xy = $xyInt;
1228 0 $resolution=1;
1229 }
1230 2 $self -> printGds2Record(-type => 'AREF');
1231 2 $self -> printGds2Record(-type => 'SNAME',-data => $sname);
1232 2 my $reflect = $arg{'-reflect'};
1233 2 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 2 0 2
Condition33%1/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table33%1/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1234 {
1235 2 $reflect = 0;
1236 }
1237 else
1238 {
1239 0 $reflect = 1;
1240 0 $useSTRANS=TRUE;
1241 }
1242 2 my $mag = $arg{'-mag'};
1243 2 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 2 0 2
Condition33%1/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table33%1/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1244 {
1245 2 $mag = 0;
1246 }
1247 else
1248 {
1249 0 $mag = cleanFloatNum($mag);
1250 0 $useSTRANS=TRUE;
1251 }
1252 2 my $angle = $arg{'-angle'};
1253 2 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 2 0 2
1254 {
1255 2 $angle = -1; #not really... just means not specified
1256 }
1257 else
1258 {
1259 0 $angle = posAngle($angle);
1260 0 $useSTRANS = TRUE;
1261 }
1262 2 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 2 2
1263 {
1264 0 my $data=$reflect.'0'x15; ## 16 'bit' string
1265 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
1266 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1267 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1268 }
1269 2 my $columns = $arg{'-columns'};
1270 2 ▶ if ((! defined $columns)||($columns <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $columns or $columns <= 0) { } 0 2 2
Condition33%1/3
not defined $columns or $columns <= 0
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $columns or $columns <= 0
not defined $columns $columns <= 0
Truth table33%1/3
not(A) or B
A= not defined $columnsB= $columns <= 0
ABresult
1X1
011
000
1271 {
1272 0 $columns=1;
1273 }
1274 else
1275 {
1276 2 $columns = int($columns);
1277 }
1278 2 my $rows = $arg{'-rows'};
1279 2 ▶ if ((! defined $rows)||($rows <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $rows or $rows <= 0) { } 0 2 2
Condition33%1/3
not defined $rows or $rows <= 0
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $rows or $rows <= 0
not defined $rows $rows <= 0
Truth table33%1/3
not(A) or B
A= not defined $rowsB= $rows <= 0
ABresult
1X1
011
000
1280 {
1281 0 $rows=1;
1282 }
1283 else
1284 {
1285 2 $rows = int($rows);
1286 }
1287 2 $self -> printGds2Record(-type => 'COLROW',-data => [$columns,$rows]);
1288 2 my @xyTmp=(); ##don't pollute array passed in
1289 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 8 2 10
1290 {
1291 8 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 8 0 8
1292 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1293 }
1294 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1295 2 $self -> printGds2Record(-type => 'ENDEL');
1296 }
1297 ################################################################################
1298  
1299 =head2 printText - prints a gds2 Text
1300  
1301 usage:
1302 $gds2File -> printText(
1303 -string=>string,
1304 -layer=>#, ## Default is 0
1305 -textType=>#, ## Default is 0
1306 -font=>#, ## 0-3
1307 -top, or -middle, -bottom, ##optional vertical presentation
1308 -left, or -center, or -right, ##optional horizontal presentation
1309  
1310 -xy=>\@array, ## ref to array of reals
1311 # -or-
1312 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1313  
1314 -x=>#.#, ## optional way of passing in x value
1315 -y=>#.#, ## optional way of passing in y value
1316 -angle=>#.#, ## (optional) Default is 0.0
1317 -mag=>#.#, ## (optional) Default is 1.0
1318 -reflect=>#, ## (optional) Default is 0
1319 );
1320  
1321 note:
1322 best not to specify reflect, angle or mag if not needed
1323  
1324 =cut
1325  
1326 #<text>::= TEXT [ELFLAGS] [PLEX] LAYER <textbody>
1327 # <textbody>::= TEXTTYPE [PRESENTATION] [PATHTYPE] [WIDTH] [<strans>] XY STRING
1328 # <strans>::= STRANS [MAG] [ANGLE]
1329 ################################################################################
1330 sub printText
1331 0 ▶{
Subroutine printText: not called CC=35 SCAR=71.4
Pod documented
1332 0 my($self,%arg) = @_;
1333 0 my $useSTRANS = FALSE;
1334 0 my $string = $arg{'-string'};
1335 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
1336 {
1337 0 die "printText expects a string. Missing -string => 'text' $!";
1338 }
1339 0 my $resolution = $self -> {'Resolution'};
1340 0 my $x = $arg{'-x'};
1341 0 my $y = $arg{'-y'};
1342 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1343 0 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1344 0 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1345 0 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 0 0
1346 {
1347 0 $xy = $xyInt;
1348 0 $resolution=1;
1349 }
1350 0 ▶ if (defined $xy)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xy) 0 0 0
1351 {
1352 0 $x = $xy -> [0];
1353 0 $y = $xy -> [1];
1354 }
1355  
1356 0 my $x2 = $arg{'-x'};
1357 0 ▶ if (defined $x2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x2) 0 0 0
1358 {
1359 0 $x = $x2;
1360 }
1361 0 ▶ unless (defined $x)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $x) 0 0 0
1362 {
1363 0 die "printText expects a x coord. Missing -xy=>\@array or -x => 'num' $!";
1364 }
1365 0 ▶ if ($x>=0) {$x = int(($x*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($x >= 0) { } 0 0 0
1366 0 else {$x = int(($x*$resolution)-$G_epsilon);}
1367  
1368 0 my $y2 = $arg{'-y'};
1369 0 ▶ if (defined $y2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $y2) 0 0 0
1370 {
1371 0 $y = $y2;
1372 }
1373 0 ▶ unless (defined $y)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $y) 0 0 0
1374 {
1375 0 die "printText expects a y coord. Missing -xy=>\@array or -y => 'num' $!";
1376 }
1377 0 ▶ if ($y>=0) {$y = int(($y*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($y >= 0) { } 0 0 0
1378 0 else {$y = int(($y*$resolution)-$G_epsilon);}
1379  
1380 0 my $layer = $arg{'-layer'};
1381 0 ▶ $layer = 0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 0 0
1382 0 my $textType = $arg{'-textType'};
1383 0 ▶ $textType=0 unless (defined $textType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $textType 0 0 0
1384 0 my $reflect = $arg{'-reflect'};
1385 0 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 0 0 0
Condition0%0/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table0%0/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1386 {
1387 0 $reflect = 0;
1388 }
1389 else
1390 {
1391 0 $reflect = 1;
1392 0 $useSTRANS = TRUE;
1393 }
1394  
1395 0 my $font = $arg{'-font'};
1396 0 ▶ if ((! defined $font) || ($font < 0) || ($font > 3))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $font or $font < 0 or $font > 3) 0 0 0
Condition0%0/6
not defined $font or $font < 0 or $font > 3
l!l&&r!l&&!r
000
not defined $font or $font < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $font or $font < 0 or $font > 3
not defined $font $font < 0 $font > 3
Truth table0%0/4
not(A) or B or C
A= not defined $fontB= $font < 0C= $font > 3
ABCresult
1XX1
01X1
0011
0000
1397 {
1398 0 $font = 0;
1399 }
1400 0 $font = sprintf("%02d",$font);
1401  
1402 0 my $vertical;
1403 0 my $top = $arg{'-top'};
1404 0 my $middle = $arg{'-middle'};
1405 0 my $bottom = $arg{'-bottom'};
1406 0 ▶ if (defined $top) {$vertical = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $top) { } 0 0 0
elsif (defined $bottom) { } 0 0 0
1407 0 elsif (defined $bottom) {$vertical = '10';}
1408 0 else {$vertical = '01';} ## middle
1409 0 my $horizontal;
1410 0 my $left = $arg{'-left'};
1411 0 my $center = $arg{'-center'};
1412 0 my $right = $arg{'-right'};
1413 0 ▶ if (defined $left) {$horizontal = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $left) { } 0 0 0
elsif (defined $right) { } 0 0 0
1414 0 elsif (defined $right) {$horizontal = '10';}
1415 0 else {$horizontal = '01';} ## center
1416 0 my $presString = '0'x10;
1417 0 $presString .= "$font$vertical$horizontal";
1418  
1419 0 my $mag = $arg{'-mag'};
1420 0 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 0 0 0
Condition0%0/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table0%0/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1421 {
1422 0 $mag=0;
1423 }
1424 else
1425 {
1426 0 $mag = cleanFloatNum($mag);
1427 }
1428 0 my $angle = $arg{'-angle'};
1429 0 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 0 0 0
1430 {
1431 0 $angle = -1; #not really... just means not specified
1432 }
1433 else
1434 {
1435 0 $angle=posAngle($angle);
1436 }
1437 0 $self -> printGds2Record(-type=>'TEXT');
1438 0 $self -> printGds2Record(-type=>'LAYER',-data=>$layer);
1439 0 $self -> printGds2Record(-type=>'TEXTTYPE',-data=>$textType);
1440 0 ▶ $self -> printGds2Record(-type => 'PRESENTATION',-data => $presString) if (defined $font || defined $top || defined $middle || defined $bottom || defined $bottom || defined $left || defined $center || defined $right);
Branch: 1 branch
BranchTrueFalseTotal
if defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right 0 0 0
Condition0%0/21
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle
l!l&&r!l&&!r
000
defined $font or defined $top
l!l&&r!l&&!r
000
MC/DC0%0/8
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right
defined $font defined $top defined $middle defined $bottom defined $bottom defined $left defined $center defined $right
Truth table0%0/9
A or B or C or D or E or F or G or H
A= defined $fontB= defined $topC= defined $middleD= defined $bottomE= defined $bottomF= defined $leftG= defined $centerH= defined $right
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
1441 0 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 0 0
1442 {
1443 0 my $data=$reflect.'0'x15; ## 16 'bit' string
1444 0 $self -> printGds2Record(-type=>'STRANS',-data=>$data);
1445 }
1446 0 ▶ $self -> printGds2Record(-type=>'MAG',-data=>$mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1447 0 ▶ $self -> printGds2Record(-type=>'ANGLE',-data=>$angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1448 0 $self -> printGds2Record(-type=>'XY',-data=>[$x,$y]);
1449 0 $self -> printGds2Record(-type=>'STRING',-data=>$string);
1450 0 $self -> printGds2Record(-type=>'ENDEL');
1451 }
1452 ################################################################################
1453  
1454 =head1 Low Level Generic Write Methods
1455  
1456 =cut
1457  
1458 ################################################################################
1459  
1460 =head2 saveGds2Record() - low level method to create a gds2 record given record type
1461 and data (if required). Data of more than one item should be given as a list.
1462  
1463 NOTE: THIS ONLY USES GDS2 OBJECT TO GET RESOLUTION
1464  
1465 usage:
1466 saveGds2Record(
1467 -type=>string,
1468 -data=>data_If_Needed, ##optional for some types
1469 -scale=>#.#, ##optional number to scale data to. I.E -scale=>0.5 #default is NOT to scale
1470 -snap=>#.#, ##optional number to snap data to I.E. -snap=>0.005 #default is 1 resolution unit, typically 0.001
1471 );
1472  
1473 examples:
1474 my $gds2File = new GDS2(-fileName => ">$fileName");
1475 my $record = $gds2File -> saveGds2Record(-type=>'header',-data=>3);
1476 $gds2FileOut -> printGds2Record(-type=>'record',-data=>$record);
1477  
1478  
1479 =cut
1480  
1481 sub saveGds2Record
1482 0 ▶{
Subroutine saveGds2Record: not called CC=42 SCAR=75.0
Pod documented
1483 0 my ($self,%arg) = @_;
1484 0 my $record = '';
1485  
1486 0 my $type = $arg{'-type'};
1487 0 ▶ if (! defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type) { } 0 0 0
1488 {
1489 0 die "saveGds2Record expects a type name. Missing -type => 'name' $!";
1490 }
1491 else
1492 {
1493 0 $type = uc $type;
1494 }
1495  
1496 0 my $saveEnd = $\;
1497 0 $\ = '';
1498  
1499 0 my @data = $arg{'-data'};
1500 0 my $dataString = $arg{'-asciiData'};
1501 0 ▶ die "saveGds2Record can not handle both -data and -asciiData options $!" if ((defined $dataString)&&((defined $data[0])&&($data[0] ne '')));
Branch: 1 branch
BranchTrueFalseTotal
if defined $dataString and (defined $data[0] and $data[0] ne "") 0 0 0
Condition0%0/6
defined $dataString and (defined $data[0] and $data[0] ne "")
!ll&&!rl&&r
000
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined $dataString and (defined $data[0] and $data[0] ne "")
defined $dataString defined $data[0] $data[0] ne ""
Truth table0%0/4
A and B and C
A= defined $dataStringB= defined $data[0]C= $data[0] ne ""
ABCresult
0XX0
10X0
1100
1111
1502  
1503 0 my $data = '';
1504 0 ▶ if ($type eq 'RECORD') ## special case...
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'RECORD') { } 0 0 0
1505 {
1506 0 return $data[0];
1507 }
1508 else
1509 {
1510 0 my $numDataElements = 0;
1511 0 my $resolution = $self -> {'Resolution'};
1512  
1513 0 my $scale = $arg{'-scale'};
1514 0 ▶ if (! defined $scale)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 0 0 0
1515 {
1516 0 $scale = 1;
1517 }
1518 0 ▶ if ($scale <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($scale <= 0) 0 0 0
1519 {
1520 0 die "saveGds2Record expects a positive scale -scale => $scale $!";
1521 }
1522  
1523 0 my $snap = $arg{'-snap'};
1524 0 ▶ if (! defined $snap) ## default is one resolution unit
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $snap) { } 0 0 0
1525 {
1526 0 $snap = 1;
1527 }
1528 else
1529 {
1530 0 $snap = $snap*$resolution; ## i.e. 0.001 -> 1
1531 }
1532 0 ▶ if ($snap < 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($snap < 1) 0 0 0
1533 {
1534 0 die "saveGds2Record expects a snap >= 1/resolution -snap => $snap $!";
1535 }
1536  
1537 0 ▶ if ((defined $data[0])&&($data[0] ne ''))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0] and $data[0] ne "") 0 0 0
Condition0%0/3
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data[0] and $data[0] ne ""
defined $data[0] $data[0] ne ""
Truth table0%0/3
A and B
A= defined $data[0]B= $data[0] ne ""
ABresult
0X0
100
111
1538 {
1539 0 $data = $data[0];
1540 0 $numDataElements = @$data;
1541 0 ▶ if ($numDataElements) ## passed in anonymous array
Branch: 1 branch
BranchTrueFalseTotal
if ($numDataElements) { } 0 0 0
1542 {
1543 0 @data = @$data; ## deref
1544 }
1545 else
1546 {
1547 0 $numDataElements = @data;
1548 }
1549 }
1550  
1551 0 my $recordDataType = $RecordTypeData{$type};
1552 0 ▶ if (defined $dataString)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dataString) 0 0 0
1553 {
1554 0 $dataString =~ s|^\s+||; ## clean-up
1555 0 $dataString =~ s|\s+$||;
1556 0 ▶ $dataString =~ s|\s+| |g if ($dataString !~ m|'|); ## don't compress spaces in strings...
Branch: 1 branch
BranchTrueFalseTotal
unless $dataString =~ /'/ 0 0 0
1557 0 $dataString =~ s|'$||; #'for strings
1558 0 $dataString =~ s|^'||; #'for strings
1559 0 ▶ if (($recordDataType == BIT_ARRAY)||($recordDataType == ACSII_STRING))
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 1 or $recordDataType == 6) { } 0 0 0
Condition0%0/3
$recordDataType == 1 or $recordDataType == 6
l!l&&r!l&&!r
000
MC/DC0%0/2
$recordDataType == 1 or $recordDataType == 6
$recordDataType == 1 $recordDataType == 6
Truth table0%0/3
A or B
A= $recordDataType == 1B= $recordDataType == 6
ABresult
1X1
011
000
1560 {
1561 0 $data = $dataString;
1562 }
1563 else
1564 {
1565 0 $dataString =~ s|\s*[\s,;:/\\]+\s*| |g; ## incase commas etc... (non-std) were added by hand
1566 0 @data = split(' ',$dataString);
1567 0 $numDataElements = @data;
1568 0 ▶ if ($recordDataType == INTEGER_4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 3) 0 0 0
1569 {
1570 0 my @xyTmp = ();
1571 0 ▶ for(my $i=0;$i<$numDataElements;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $numDataElements) 0 0 0
1572 {
1573 0 ▶ if ($data[$i]>=0) {push @xyTmp,int((($data[$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i] >= 0) { } 0 0 0
1574 0 else {push @xyTmp,int((($data[$i])*$resolution)-$G_epsilon);}
1575 }
1576 0 @data=@xyTmp;
1577 }
1578 }
1579 }
1580 0 my $byte;
1581 0 my $length = 0;
1582 0 ▶ if ($recordDataType == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 2) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
1583 {
1584 0 $length = 2;
1585 }
1586 elsif ($recordDataType == INTEGER_2)
1587 {
1588 0 $length = 2 * $numDataElements;
1589 }
1590 elsif ($recordDataType == INTEGER_4)
1591 {
1592 0 $length = 4 * $numDataElements;
1593 }
1594 elsif ($recordDataType == REAL_8)
1595 {
1596 0 $length = 8 * $numDataElements;
1597 }
1598 elsif ($recordDataType == ACSII_STRING)
1599 {
1600 0 my $slen = length $data;
1601 0 $length = $slen + ($slen % 2); ## needs to be an even number
1602 }
1603  
1604 0 my $recordLength = pack 'S',($length + 4); #1 2 bytes for length 3rd for recordType 4th for dataType
1605 0 $record .= $recordLength;
1606 0 my $recordType = pack 'C',$RecordTypeNumbers{$type};
1607 0 $record .= $recordType;
1608  
1609 0 my $dataType = pack 'C',$RecordTypeData{$type};
1610 0 $record .= $dataType;
1611  
1612 0 ▶ if ($recordDataType == BIT_ARRAY) ## bit array
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 2) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
1613 {
1614 0 my $bitLength = $length * 8;
1615 0 $record .= pack("B$bitLength",$data);
1616 }
1617 elsif ($recordDataType == INTEGER_2) ## 2 byte signed integer
1618 {
1619 0 foreach my $num (@data)
1620 {
1621 0 $record .= pack('s',$num);
1622 }
1623 }
1624 elsif ($recordDataType == INTEGER_4) ## 4 byte signed integer
1625 {
1626 0 foreach my $num (@data)
1627 {
1628 0 ▶ $num = scaleNum($num,$scale) if ($scale != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $scale != 1 0 0 0
1629 0 ▶ $num = snapNum($num,$snap) if ($snap != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $snap != 1 0 0 0
1630 0 $record .= pack('i',$num);
1631 }
1632 }
1633 elsif ($recordDataType == REAL_8) ## 8 byte real
1634 {
1635 0 foreach my $num (@data)
1636 {
1637 0 my $real = $num;
1638 0 my $negative = FALSE;
1639 0 ▶ if($num < 0.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 0 0
1640 {
1641 0 $negative = TRUE;
1642 0 $real = 0 - $num;
1643 }
1644  
1645 0 my $exponent = 0;
1646 0 ▶ while($real >= 1.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 1) 0 0 0
1647 {
1648 0 $exponent++;
1649 0 $real = ($real / 16.0);
1650 }
1651  
1652 0 ▶ if ($real != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real != 0) 0 0 0
1653 {
1654 0 ▶ while($real < 0.0625)
Branch: 1 branch
BranchTrueFalseTotal
if ($real < "0.0625") 0 0 0
1655 {
1656 0 --$exponent;
1657 0 $real = ($real * 16.0);
1658 }
1659 }
1660  
1661 0 ▶ if($negative) { $exponent += 192; }
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 0 0
1662 0 else { $exponent += 64; }
1663 0 $record .= pack('C',$exponent);
1664  
1665 0 ▶ for (my $i=1; $i<=7; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 7) 0 0 0
1666 {
1667 0 ▶ if ($real>=0) {$byte = int(($real*256.0)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 0) { } 0 0 0
1668 0 else {$byte = int(($real*256.0)-$G_epsilon);}
1669 0 $record .= pack('C',$byte);
1670 0 $real = $real * 256.0 - ($byte + 0.0);
1671 }
1672 }
1673 }
1674 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
1675 {
1676 0 $record .= pack("a$length",$data);
1677 }
1678 }
1679 0 $\=$saveEnd;
1680 0 $record;
1681 }
1682 ################################################################################
1683  
1684 =head2 printGds2Record() - low level method to print a gds2 record given record type
1685 and data (if required). Data of more than one item should be given as a list.
1686  
1687 usage:
1688 printGds2Record(
1689 -type=>string,
1690 -data=>data_If_Needed, ##optional for some types
1691 -scale=>#.#, ##optional number to scale data to. I.E -scale=>0.5 #default is NOT to scale
1692 -snap=>#.#, ##optional number to snap data to I.E. -snap=>0.005 #default is 1 resolution unit, typically 0.001
1693 );
1694  
1695 examples:
1696 my $gds2File = new GDS2(-fileName => ">$fileName");
1697  
1698 $gds2File -> printGds2Record(-type=>'header',-data=>3);
1699 $gds2File -> printGds2Record(-type=>'bgnlib',-data=>[99,12,1,22,33,0,99,12,1,22,33,9]);
1700 $gds2File -> printGds2Record(-type=>'libname',-data=>"testlib");
1701 $gds2File -> printGds2Record(-type=>'units',-data=>[0.001, 1e-9]);
1702 $gds2File -> printGds2Record(-type=>'bgnstr',-data=>[99,12,1,22,33,0,99,12,1,22,33,9]);
1703 ...
1704 $gds2File -> printGds2Record(-type=>'endstr');
1705 $gds2File -> printGds2Record(-type=>'endlib');
1706  
1707 Note: the special record type of 'record' can be used to copy a complete record
1708 just read in:
1709 while (my $record = $gds2FileIn -> readGds2Record())
1710 {
1711 $gds2FileOut -> printGds2Record(-type=>'record',-data=>$record);
1712 }
1713  
1714 =cut
1715  
1716 sub printGds2Record
1717 317 ▶{
Subroutine printGds2Record: called CC=62 SCAR=55.0
Pod documented
1718 317 my ($self,%arg) = @_;
1719  
1720 317 my $type = $arg{'-type'};
1721 317 ▶ unless (defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) { } 317 0 317
1722 {
1723 0 die "printGds2Record expects a type name. Missing -type => 'name' $!";
1724 }
1725 else
1726 {
1727 317 $type = uc $type;
1728 }
1729 317 my @data = $arg{'-data'};
1730 317 my $dataString = $arg{'-asciiData'};
1731 317 ▶ die "printGds2Record can not handle both -data and -asciiData options $!" if ((defined $dataString)&&((defined $data[0])&&($data[0] ne '')));
Branch: 1 branch
BranchTrueFalseTotal
if defined $dataString and (defined $data[0] and $data[0] ne "") 0 317 317
Condition50%3/6
defined $dataString and (defined $data[0] and $data[0] ne "")
!ll&&!rl&&r
622550
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
25500
MC/DC0%0/3
defined $dataString and (defined $data[0] and $data[0] ne "")
defined $dataString defined $data[0] $data[0] ne ""
Truth table50%2/4
A and B and C
A= defined $dataStringB= defined $data[0]C= $data[0] ne ""
ABCresult
0XX0
10X0
1100
1111
1732  
1733 317 my $fh = $self -> {'FileHandle'};
1734 317 my $saveEnd=$\;
1735 317 $\='';
1736  
1737 317 my $data = '';
1738 317 ▶ @data = () unless (defined $data[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data[0] 277 40 317
1739 317 my $recordLength; ## 1st 2 bytes for length 3rd for recordType 4th for dataType
1740 317 ▶ if ($type eq 'RECORD') ## special case...
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'RECORD') { } 0 317 317
1741 {
1742 0 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) { } 0 0 0
1743 {
1744 0 my $length = substr($data[0],0,2);
1745 0 $recordLength = unpack 'v',$length;
1746 0 $self -> {'BytesDone'} += $recordLength;
1747 0 $length = reverse $length;
1748 0 print($fh $length);
1749  
1750 0 my $recordType = substr($data[0],2,1);
1751 0 print($fh $recordType);
1752 0 $recordType = unpack 'C',$recordType;
1753 0 $type = $RecordTypeStrings[$recordType]; ## will use code below.....
1754  
1755 0 my $dataType = substr($data[0],3,1);
1756 0 print($fh $dataType);
1757 0 $dataType = unpack 'C',$dataType;
1758 0 ▶ if ($recordLength > 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordLength > 4) 0 0 0
1759 {
1760 0 my $lengthLeft = $recordLength - 4; ## length left
1761 0 my $recordDataType = $RecordTypeData{$type};
1762  
1763 0 ▶ if (($recordDataType == INTEGER_2) || ($recordDataType == BIT_ARRAY))
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 2 or $recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
elsif ($recordDataType == 4) { } 0 0 0
Condition0%0/3
$recordDataType == 2 or $recordDataType == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$recordDataType == 2 or $recordDataType == 1
$recordDataType == 2 $recordDataType == 1
Truth table0%0/3
A or B
A= $recordDataType == 2B= $recordDataType == 1
ABresult
1X1
011
000
1764 {
1765 0 my $binData = unpack 'b*',$data[0];
1766 0 my $intData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1767  
1768 0 my ($byteInt2String,$byte2);
1769 0 ▶ for(my $i=0; $i<($lengthLeft/2); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 2) 0 0 0
1770 {
1771 0 $byteInt2String = reverse(substr($intData,0,16,''));
1772 0 $byte2=pack 'B16',reverse($byteInt2String);
1773 0 print($fh $byte2);
1774 }
1775 }
1776 elsif ($recordDataType == INTEGER_4)
1777 {
1778 0 my $binData = unpack 'b*',$data[0];
1779 0 my $intData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1780 0 my ($byteInt4String,$byte4);
1781 0 ▶ for(my $i=0; $i<($lengthLeft/4); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 4) 0 0 0
1782 {
1783 0 $byteInt4String = reverse(substr($intData,0,32,''));
1784 0 $byte4=pack 'B32',reverse($byteInt4String);
1785 0 print($fh $byte4);
1786 }
1787 }
1788 elsif ($recordDataType == REAL_8)
1789 {
1790 0 my $binData = unpack 'b*',$data[0];
1791 0 my $realData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1792 0 my ($bit64String,$mantissa,$byteString,$byte);
1793 0 ▶ for(my $i=0; $i<($lengthLeft/8); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 8) 0 0 0
1794 {
1795 0 $bit64String = substr($realData,($i*64),64);
1796 0 print($fh pack 'b8',$bit64String);
1797 0 $mantissa = substr($bit64String,8,56);
1798 0 ▶ for(my $j=0; $j<7; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 7) 0 0 0
1799 {
1800 0 $byteString = substr($mantissa,($j*8),8);
1801 0 $byte=pack 'b8',$byteString;
1802 0 print($fh $byte);
1803 }
1804 }
1805 }
1806 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
1807 {
1808 0 print($fh pack("a$lengthLeft",substr($data[0],4)));
1809 }
1810 elsif ($recordDataType == REAL_4) ## 4 byte real
1811 {
1812 0 die "4-byte reals are not supported $!";
1813 }
1814 }
1815 }
1816 else
1817 {
1818 0 print($fh $data[0]);
1819 0 $recordLength = length $data[0];
1820 0 $self -> {'BytesDone'} += $recordLength;
1821 }
1822 }
1823 else #if ($type ne 'RECORD')
1824 {
1825 317 my $numDataElements = 0;
1826 317 my $resolution = $self -> {'Resolution'};
1827 317 my $uUnits = $self -> {'UUnits'};
1828  
1829 317 my $scale = $arg{'-scale'};
1830 317 ▶ if (! defined $scale)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 317 0 317
1831 {
1832 317 $scale = 1;
1833 }
1834 317 ▶ if ($scale <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($scale <= 0) 0 317 317
1835 {
1836 0 die "printGds2Record expects a positive scale -scale => $scale $!";
1837 }
1838  
1839 317 my $snap = $arg{'-snap'};
1840 317 ▶ if (! defined $snap) ## default is one resolution unit
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $snap) { } 317 0 317
1841 {
1842 317 $snap = 1;
1843 }
1844 else
1845 {
1846 0 $snap = int(($snap*$resolution)+$G_epsilon); ## i.e. 0.001 -> 1
1847 }
1848 317 ▶ if ($snap < 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($snap < 1) 0 317 317
1849 {
1850 0 die "printGds2Record expects a snap >= 1/resolution -snap => $snap $!";
1851 }
1852  
1853 317 ▶ if ((defined $data[0])&&($data[0] ne ''))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0] and $data[0] ne "") 40 277 317
Condition66%2/3
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
277040
MC/DC50%1/2
defined $data[0] and $data[0] ne ""
defined $data[0] $data[0] ne ""
Truth table66%2/3
A and B
A= defined $data[0]B= $data[0] ne ""
ABresult
0X0
100
111
1854 {
1855 40 $data = $data[0];
1856 40 $numDataElements = @$data;
1857 40 ▶ if ($numDataElements) ## passed in anonymous array
Branch: 1 branch
BranchTrueFalseTotal
if ($numDataElements) { } 18 22 40
1858 {
1859 18 @data = @$data; ## deref
1860 }
1861 else
1862 {
1863 22 $numDataElements = @data;
1864 }
1865 }
1866  
1867 317 my $recordDataType = $RecordTypeData{$type};
1868  
1869 317 ▶ if (defined $dataString)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dataString) 255 62 317
1870 {
1871 255 $dataString=~s|^\s+||; ## clean-up
1872 255 $dataString=~s|\s+$||;
1873 255 ▶ $dataString=~s|\s+| |g if ($dataString !~ m|'|); ## don't compress spaces in strings...
Branch: 1 branch
BranchTrueFalseTotal
unless $dataString =~ /'/ 225 30 255
1874 255 $dataString=~s|'$||; #'# for strings
1875 255 $dataString=~s|^'||; #'# for strings
1876 255 ▶ if (($recordDataType == BIT_ARRAY)||($recordDataType == ACSII_STRING))
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 1 or $recordDataType == 6) { } 57 198 255
Condition100%3/3
$recordDataType == 1 or $recordDataType == 6
l!l&&r!l&&!r
2730198
MC/DC100%2/2
$recordDataType == 1 or $recordDataType == 6
$recordDataType == 1 $recordDataType == 6
Truth table100%3/3
A or B
A= $recordDataType == 1B= $recordDataType == 6
ABresult
1X1
011
000
1877 {
1878 57 $data = $dataString;
1879 }
1880 else
1881 {
1882 198 $dataString=~s|\s*[\s,;:/\\]+\s*| |g; ## in case commas etc... (non-std) were added by hand
1883 198 @data = split(' ',$dataString);
1884 198 $numDataElements = @data;
1885 198 ▶ if ($recordDataType == INTEGER_4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 3) 33 165 198
1886 {
1887 33 my @xyTmp=();
1888 33 ▶ for(my $i=0;$i<$numDataElements;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $numDataElements) 165 33 198
1889 {
1890 165 ▶ if ($data[$i]>=0) {push @xyTmp,int((($data[$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i] >= 0) { } 126 39 165
1891 39 else {push @xyTmp,int((($data[$i])*$resolution)-$G_epsilon);}
1892 }
1893 33 @data=@xyTmp;
1894 }
1895 }
1896 }
1897 317 my $byte;
1898 317 my $length = 0;
1899 317 ▶ if ($recordDataType == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 27 290 317
elsif ($recordDataType == 2) { } 87 203 290
elsif ($recordDataType == 3) { } 43 160 203
elsif ($recordDataType == 5) { } 26 134 160
elsif ($recordDataType == 6) { } 40 94 134
1900 {
1901 27 $length = 2;
1902 }
1903 elsif ($recordDataType == INTEGER_2)
1904 {
1905 87 $length = 2 * $numDataElements;
1906 }
1907 elsif ($recordDataType == INTEGER_4)
1908 {
1909 43 $length = 4 * $numDataElements;
1910 }
1911 elsif ($recordDataType == REAL_8)
1912 {
1913 26 $length = 8 * $numDataElements;
1914 }
1915 elsif ($recordDataType == ACSII_STRING)
1916 {
1917 40 my $slen = length $data;
1918 40 $length = $slen + ($slen % 2); ## needs to be an even number
1919 }
1920 317 $self -> {'BytesDone'} += $length;
1921 317 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) { } 317 0 317
1922 {
1923 317 $recordLength = pack 'v',($length + 4);
1924 317 $recordLength = reverse $recordLength;
1925 }
1926 else
1927 {
1928 0 $recordLength = pack 'S',($length + 4);
1929 }
1930 317 print($fh $recordLength);
1931  
1932 317 my $recordType = pack 'C',$RecordTypeNumbers{$type};
1933 317 ▶ $recordType = reverse $recordType if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 317 0 317
1934 317 print($fh $recordType);
1935  
1936 317 my $dataType = pack 'C',$RecordTypeData{$type};
1937 317 ▶ $dataType = reverse $dataType if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 317 0 317
1938 317 print($fh $dataType);
1939  
1940 317 ▶ if ($recordDataType == BIT_ARRAY) ## bit array
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 27 290 317
elsif ($recordDataType == 2) { } 87 203 290
elsif ($recordDataType == 3) { } 43 160 203
elsif ($recordDataType == 5) { } 26 134 160
elsif ($recordDataType == 6) { } 40 94 134
1941 {
1942 27 my $bitLength = $length * 8;
1943 27 my $value = pack("B$bitLength",$data);
1944 27 print($fh $value);
1945 }
1946 elsif ($recordDataType == INTEGER_2) ## 2 byte signed integer
1947 {
1948 87 my $value;
1949 87 foreach my $num (@data)
1950 {
1951 287 $value = pack('s',$num);
1952 287 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 287 0 287
1953 287 print($fh $value);
1954 }
1955 }
1956 elsif ($recordDataType == INTEGER_4) ## 4 byte signed integer
1957 {
1958 43 my $value;
1959 43 foreach my $num (@data)
1960 {
1961 211 ▶ $num = scaleNum($num,$scale) if ($scale != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $scale != 1 0 211 211
1962 211 ▶ $num = snapNum($num,$snap) if ($snap != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $snap != 1 0 211 211
1963 211 $value = pack('i',$num);
1964 211 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 211 0 211
1965 211 print($fh $value);
1966 }
1967 }
1968 elsif ($recordDataType == REAL_8) ## 8 byte real
1969 {
1970 26 my ($real,$negative,$exponent,$value);
1971 26 foreach my $num (@data)
1972 {
1973 31 $real = $num;
1974 31 $negative = FALSE;
1975 31 ▶ if($num < 0.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 31 31
1976 {
1977 0 $negative = TRUE;
1978 0 $real = 0 - $num;
1979 }
1980  
1981 31 $exponent = 0;
1982 31 ▶ while($real >= 1.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 1) 15 31 46
1983 {
1984 15 $exponent++;
1985 15 $real = ($real / 16.0);
1986 }
1987  
1988 31 ▶ if ($real != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real != 0) 31 0 31
1989 {
1990 31 ▶ while($real < 0.0625)
Branch: 1 branch
BranchTrueFalseTotal
if ($real < "0.0625") 45 31 76
1991 {
1992 45 --$exponent;
1993 45 $real = ($real * 16.0);
1994 }
1995 }
1996 0 ▶ if($negative) { $exponent += 192; }
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 31 31
1997 31 else { $exponent += 64; }
1998 31 $value = pack('C',$exponent);
1999 31 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 31 0 31
2000 31 print($fh $value);
2001  
2002 31 ▶ for (my $i=1; $i<=7; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 7) 217 31 248
2003 {
2004 217 ▶ if ($real>=0) {$byte = int(($real*256.0)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 0) { } 217 0 217
2005 0 else {$byte = int(($real*256.0)-$G_epsilon);}
2006 217 my $value = pack('C',$byte);
2007 217 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 217 0 217
2008 217 print($fh $value);
2009 217 $real = $real * 256.0 - ($byte + 0.0);
2010 }
2011 }
2012 }
2013 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
2014 {
2015 40 print($fh pack("a$length",$data));
2016 }
2017 }
2018 317 $\=$saveEnd;
2019 }
2020 ################################################################################
2021  
2022 =head2 printRecord - prints a record just read
2023  
2024 usage:
2025 $gds2File -> printRecord(
2026 -data => $record
2027 );
2028  
2029 =cut
2030  
2031 sub printRecord
2032 0 ▶{
Subroutine printRecord: not called CC=3 SCAR=24.8
Pod documented
2033 0 my ($self,%arg) = @_;
2034 0 my $record = $arg{'-data'};
2035 0 ▶ if (! defined $record)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record) 0 0 0
2036 {
2037 0 die "printGds2Record expects a data record. Missing -data => \$record $!";
2038 }
2039 0 my $type = $arg{'-type'};
2040 0 ▶ if (defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 0 0 0
2041 {
2042 0 die "printRecord does not take -type. Perhaps you meant to use printGds2Record? $!";
2043 }
2044 0 $self -> printGds2Record(-type=>'record',-data=>$record);
2045 }
2046 ################################################################################
2047  
2048 ################################################################################
2049  
2050 =head1 Low Level Generic Read Methods
2051  
2052 =cut
2053  
2054 ################################################################################
2055  
2056 =head2 readGds2Record - reads record header and data section
2057  
2058 usage:
2059 while ($gds2File -> readGds2Record)
2060 {
2061 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2062 {
2063 $layersFound[$gds2File -> layer] = 1;
2064 }
2065 }
2066  
2067 =cut
2068  
2069 sub readGds2Record
2070 172 ▶{
Subroutine readGds2Record: called CC=2 SCAR=6.9
Pod documented
2071 172 my $self = shift;
2072 172 ▶ return "" if ($self -> {'EOLIB'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"EOLIB"} 2 170 172
2073 170 $self -> readGds2RecordHeader();
2074 170 $self -> readGds2RecordData();
2075 170 $self -> {'INHEADER'} = FALSE;
2076 170 $self -> {'INDATA'} = TRUE; ## actually just done w/ it
2077 170 $self -> {'Record'};
2078 }
2079 ################################################################################
2080  
2081 =head2 readGds2RecordHeader - only reads gds2 record header section (2 bytes)
2082  
2083 slightly faster if you just want a certain thing...
2084 usage:
2085 while ($gds2File -> readGds2RecordHeader)
2086 {
2087 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2088 {
2089 $gds2File -> readGds2RecordData;
2090 $layersFound[$gds2File -> returnLayer] = 1;
2091 }
2092 }
2093  
2094 =cut
2095  
2096 sub readGds2RecordHeader
2097 256 ▶{
Subroutine readGds2RecordHeader: called CC=24 SCAR=31.8
Pod documented
2098 256 my $self = shift;
2099  
2100 256 ▶ $self -> skipGds2RecordData() if ((! $self -> {'INDATA'}) && ($self -> {'INHEADER'} != UNKNOWN)) ; # need to read record data before header unless 1st time
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"INDATA"} and $self->{"INHEADER"} != -1 24 232 256
Condition100%3/3
not $self->{"INDATA"} and $self->{"INHEADER"} != -1
!ll&&!rl&&r
229324
MC/DC100%2/2
not $self->{"INDATA"} and $self->{"INHEADER"} != -1
not $self->{"INDATA"} $self->{"INHEADER"} != -1
Truth table100%3/3
not(A) and B
A= not $self->{"INDATA"}B= $self->{"INHEADER"} != -1
ABresult
0X0
100
111
2101 256 $self -> {'Record'} = '';
2102 256 $self -> {'RecordType'} = UNKNOWN;
2103 256 $self -> {'INHEADER'} = TRUE; ## will actually be just just done with it by the time we can check this ...
2104 256 $self -> {'INDATA'} = FALSE;
2105 256 ▶ return '' if ($self -> {'EOLIB'}); ## no sense reading null padding..
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"EOLIB"} 1 255 256
2106  
2107 255 my $buffer = '';
2108 255 ▶ return 0 if (! read($self -> {'FileHandle'},$buffer,4));
Branch: 1 branch
BranchTrueFalseTotal
unless read $self->{"FileHandle"}, $buffer, 4 0 255 255
2109 255 my $data;
2110 #if (read($self -> {'FileHandle'},$data,2)) ### length
2111 255 $data = substr($buffer,0,2);
2112 {
2113 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2114 255 $self -> {'Record'} = $data;
2115 255 $self -> {'Length'} = unpack 'S',$data;
2116 255 $self -> {'BytesDone'} += $self -> {'Length'};
2117 }
2118  
2119 #if (read($self -> {'FileHandle'},$data,1)) ## record type
2120 255 $data = substr($buffer,2,1);
2121 {
2122 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2123 255 $self -> {'Record'} .= $data;
2124 255 $self -> {'RecordType'} = unpack 'C',$data;
2125 255 ▶ $self -> {'EOLIB'} = TRUE if (($self -> {'RecordType'}) == ENDLIB);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 4 3 252 255
2126  
2127 255 ▶ if ($self -> {'UsingPrettyPrint'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"UsingPrettyPrint"}) 252 3 255
2128 {
2129 252 ▶ putStrSpace('') if (($self -> {'RecordType'}) == ENDSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 7 9 243 252
2130 252 ▶ putStrSpace(' ') if (($self -> {'RecordType'}) == BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 5 9 243 252
2131  
2132 putElmSpace(' ') if ((($self -> {'RecordType'}) == TEXT) || (($self -> {'RecordType'}) == PATH) ||
2133 (($self -> {'RecordType'}) == BOUNDARY) || (($self -> {'RecordType'}) == SREF) ||
2134 252 ▶ (($self -> {'RecordType'}) == AREF));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 30 222 252
Condition91%11/12
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
300222
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
219222
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
129231
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
93240
MC/DC80%4/5
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table83%5/6
A or B or C or D or E
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2135 252 ▶ if (($self -> {'RecordType'}) == ENDEL)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"RecordType"} == 17) 30 222 252
2136 {
2137 30 putElmSpace('');
2138 30 $self -> {'InTxt'} = FALSE;
2139 30 $self -> {'InBoundary'} = FALSE;
2140 }
2141 252 ▶ $self -> {'InTxt'} = TRUE if (($self -> {'RecordType'}) == TEXT);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 12 9 243 252
2142 252 ▶ $self -> {'InBoundary'} = TRUE if (($self -> {'RecordType'}) == BOUNDARY);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 8 9 243 252
2143 252 ▶ if ((($self -> {'RecordType'}) == LIBNAME) || (($self -> {'RecordType'}) == STRNAME))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"RecordType"} == 2 or $self->{"RecordType"} == 6) 12 240 252
Condition100%3/3
$self->{"RecordType"} == 2 or $self->{"RecordType"} == 6
l!l&&r!l&&!r
39240
MC/DC100%2/2
$self->{"RecordType"} == 2 or $self->{"RecordType"} == 6
$self->{"RecordType"} == 2 $self->{"RecordType"} == 6
Truth table100%3/3
A or B
A= $self->{"RecordType"} == 2B= $self->{"RecordType"} == 6
ABresult
1X1
011
000
2144  
2145 {
2146 12 $self -> {'DateFld'} = 0;
2147 }
2148 252 ▶ $self -> {'DateFld'} = 1 if ((($self -> {'RecordType'}) == BGNLIB) || (($self -> {'RecordType'}) == BGNSTR));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 1 or $self->{"RecordType"} == 5 12 240 252
Condition100%3/3
$self->{"RecordType"} == 1 or $self->{"RecordType"} == 5
l!l&&r!l&&!r
39240
MC/DC100%2/2
$self->{"RecordType"} == 1 or $self->{"RecordType"} == 5
$self->{"RecordType"} == 1 $self->{"RecordType"} == 5
Truth table100%3/3
A or B
A= $self->{"RecordType"} == 1B= $self->{"RecordType"} == 5
ABresult
1X1
011
000
2149 }
2150 }
2151  
2152 #if (read($self -> {'FileHandle'},$data,1)) ## data type
2153 255 $data = substr($buffer,3,1);
2154 {
2155 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2156 255 $self -> {'Record'} .= $data;
2157 255 $self -> {'DataType'} = unpack 'C',$data;
2158 }
2159 #printf("P:Length=%-5d RecordType=%-2d DataType=%-2d\n",$self -> {'Length'},$self -> {'RecordType'},$self -> {'DataType'}); ##DEBUG
2160 255 return 1;
2161 }
2162 ################################################################################
2163  
2164 =head2 readGds2RecordData - only reads record data section
2165  
2166 slightly faster if you just want a certain thing...
2167 usage:
2168 while ($gds2File -> readGds2RecordHeader)
2169 {
2170 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2171 {
2172 $gds2File -> readGds2RecordData;
2173 $layersFound[$gds2File -> returnLayer] = 1;
2174 }
2175 }
2176  
2177 =cut
2178  
2179 sub readGds2RecordData
2180 255 ▶{
Subroutine readGds2RecordData: called CC=22 SCAR=31.1
Pod documented
2181 255 my $self = shift;
2182  
2183 255 ▶ $self -> readGds2RecordHeader() if ($self -> {'INHEADER'} != TRUE); # program did not read HEADER - needs to...
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"INHEADER"} != 1 0 255 255
2184 255 ▶ return $self -> {'Record'} if ($self -> {'DataType'} == NO_REC_DATA); # no sense going on...
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DataType"} == 0 72 183 255
2185 183 $self -> {'INHEADER'} = FALSE; # not in HEADER - need to read HEADER next time around...
2186 183 $self -> {'INDATA'} = TRUE; # rather in DATA - actually will be at the end of data by the time we test this...
2187 183 $self -> {'RecordData'} = '';
2188 183 $self -> {'RecordData'} = ();
2189 183 $self -> {'CurrentDataList'} = '';
2190 183 my $bytesLeft = $self -> {'Length'} - 4; ## 4 should have been just read by readGds2RecordHeader
2191 183 my $data;
2192 183 ▶ if ($self -> {'DataType'} == BIT_ARRAY) ## bit array
Branch: 6 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 27 156 183
elsif ($self->{'DataType'} == 2) { } 69 87 156
elsif ($self->{'DataType'} == 3) { } 33 54 87
elsif ($self->{'DataType'} == 4) { } 0 54 54
elsif ($self->{'DataType'} == 5) { } 24 30 54
elsif ($self->{'DataType'} == 6) { } 30 0 30
2193 {
2194 27 $self -> {'DataIndex'}=0;
2195 27 read($self -> {'FileHandle'},$data,$bytesLeft);
2196 27 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 27 0 27
2197 27 my $bitsLeft = $bytesLeft * 8;
2198 27 $self -> {'Record'} .= $data;
2199 27 $self -> {'RecordData'}[0] = unpack "B$bitsLeft",$data;
2200 27 $self -> {'CurrentDataList'} = ($self -> {'RecordData'}[0]);
2201 }
2202 elsif ($self -> {'DataType'} == INTEGER_2) ## 2 byte signed integer
2203 {
2204 69 my $tmpListString = '';
2205 69 my $i = 0;
2206 69 ▶ while ($bytesLeft)
Branch: 1 branch
BranchTrueFalseTotal
if ($bytesLeft) 201 69 270
2207 {
2208 201 read($self -> {'FileHandle'},$data,2);
2209 201 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 201 0 201
2210 201 $self -> {'Record'} .= $data;
2211 201 $self -> {'RecordData'}[$i] = unpack 's',$data;
2212 201 $tmpListString .= ',';
2213 201 $tmpListString .= $self -> {'RecordData'}[$i];
2214 201 $i++;
2215 201 $bytesLeft -= 2;
2216 }
2217 69 $self -> {'DataIndex'} = $i - 1;
2218 69 $self -> {'CurrentDataList'} = $tmpListString;
2219 }
2220 elsif ($self -> {'DataType'} == INTEGER_4) ## 4 byte signed integer
2221 {
2222 33 my $tmpListString = '';
2223 33 my $i = 0;
2224 33 my $buffer = '';
2225 33 read($self -> {'FileHandle'},$buffer,$bytesLeft); ## try fewer reads
2226 33 ▶ for(my $start=0; $start < $bytesLeft; $start += 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($start < $bytesLeft) 165 33 198
2227 {
2228 165 $data = substr($buffer,$start,4);
2229 165 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 165 0 165
2230 165 $self -> {'Record'} .= $data;
2231 165 $self -> {'RecordData'}[$i] = unpack 'i',$data;
2232 165 $tmpListString .= ',';
2233 165 $tmpListString .= $self -> {'RecordData'}[$i];
2234 165 $i++;
2235 }
2236 33 $self -> {'DataIndex'} = $i - 1;
2237 33 $self -> {'CurrentDataList'} = $tmpListString;
2238 }
2239 elsif ($self -> {'DataType'} == REAL_4) ## 4 byte real
2240 {
2241 0 die "4-byte reals are not supported $!";
2242 }
2243 elsif ($self -> {'DataType'} == REAL_8) ## 8 byte real - UNITS, MAG, ANGLE
2244 {
2245 24 my $resolution = $self -> {'Resolution'};
2246 24 my $tmpListString = '';
2247 24 my $i = 0;
2248 24 my ($negative,$exponent,$mantdata,$byteString,$byte,$mantissa,$real);
2249 24 ▶ while ($bytesLeft)
Branch: 1 branch
BranchTrueFalseTotal
if ($bytesLeft) 27 24 51
2250 {
2251 27 read($self -> {'FileHandle'},$data,1); ## sign bit and 7 exponent bits
2252 27 $self -> {'Record'} .= $data;
2253 27 $negative = unpack 'B',$data; ## sign bit
2254 27 $exponent = unpack 'C',$data;
2255 27 ▶ if ($negative)
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 27 27
2256 {
2257 0 $exponent -= 192; ## 128 + 64
2258 }
2259 else
2260 {
2261 27 $exponent -= 64;
2262 }
2263 27 read($self -> {'FileHandle'},$data,7); ## mantissa bits
2264 27 $mantdata = unpack 'b*',$data;
2265 27 $self -> {'Record'} .= $data;
2266 27 $mantissa = 0.0;
2267 27 ▶ for(my $j=0; $j<7; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 7) 189 27 216
2268 {
2269 189 $byteString = substr($mantdata,0,8,'');
2270 189 $byte = pack 'b*',$byteString;
2271 189 $byte = unpack 'C',$byte;
2272 189 $mantissa += $byte / (256.0**($j+1));
2273 }
2274 27 $real = $mantissa * (16**$exponent);
2275 27 ▶ $real = (0 - $real) if ($negative);
Branch: 1 branch
BranchTrueFalseTotal
if $negative 0 27 27
2276 27 ▶ if ($RecordTypeStrings[$self -> {'RecordType'}] eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($RecordTypeStrings[$self->{'RecordType'}] eq 'UNITS') { } 6 21 27
2277 {
2278 6 ▶ if ($self -> {'UUnits'} == -1.0)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'UUnits'} == -1.0) { } 3 3 6
elsif ($self->{'DBUnits'} == -1.0) { } 3 0 3
2279 {
2280 3 $self -> {'UUnits'} = $real;
2281 }
2282 elsif ($self -> {'DBUnits'} == -1.0)
2283 {
2284 3 $self -> {'DBUnits'} = $real;
2285 }
2286 }
2287 else
2288 {
2289 ### this works because UUnits and DBUnits are 1st reals in GDS2 file
2290 21 ▶ $real = int(($real+($self -> {'UUnits'}/$resolution))/$self -> {'UUnits'})*$self -> {'UUnits'} if ($self -> {'UUnits'} != 0); ## "rounds" off
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"UUnits"} != 0 21 0 21
2291 }
2292 27 $self -> {'RecordData'}[$i] = $real;
2293 27 $tmpListString .= ',';
2294 27 $tmpListString .= $self -> {'RecordData'}[$i];
2295 27 $i++;
2296 27 $bytesLeft -= 8;
2297 }
2298 24 $self -> {'DataIndex'} = $i - 1;
2299 24 $self -> {'CurrentDataList'} = $tmpListString;
2300 }
2301 elsif ($self -> {'DataType'} == ACSII_STRING) ## ascii string (null padded)
2302 {
2303 30 $self -> {'DataIndex'} = 0;
2304 30 read($self -> {'FileHandle'},$data,$bytesLeft);
2305 30 $self -> {'Record'} .= $data;
2306 30 $self -> {'RecordData'}[0] = unpack "a$bytesLeft",$data;
2307 30 $self -> {'RecordData'}[0] =~ s|\0||g; ## take off ending nulls
2308 30 $self -> {'CurrentDataList'} = ($self -> {'RecordData'}[0]);
2309 }
2310 183 return 1;
2311 }
2312 ################################################################################
2313  
2314 =head1 Low Level Generic Evaluation Methods
2315  
2316 =cut
2317  
2318 ################################################################################
2319  
2320 =head2 returnRecordType - returns current (read) record type as integer
2321  
2322 usage:
2323 if ($gds2File -> returnRecordType == 6)
2324 {
2325 print "found STRNAME";
2326 }
2327  
2328 =cut
2329  
2330 sub returnRecordType
2331 0 ▶{
Subroutine returnRecordType: not called CC=1 SCAR=6.9
Pod documented
2332 0 my $self = shift;
2333 0 $self -> {'RecordType'};
2334 }
2335 ################################################################################
2336  
2337 =head2 returnRecordTypeString - returns current (read) record type as string
2338  
2339 usage:
2340 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2341 {
2342 code goes here...
2343 }
2344  
2345 =cut
2346  
2347 sub returnRecordTypeString
2348 0 ▶{
Subroutine returnRecordTypeString: not called CC=1 SCAR=6.9
Pod documented
2349 0 my $self = shift;
2350 0 $RecordTypeStrings[($self -> {'RecordType'})];
2351 }
2352 ################################################################################
2353  
2354 =head2 returnRecordAsString - returns current (read) record as a string
2355  
2356 usage:
2357 while ($gds2File -> readGds2Record)
2358 {
2359 print $gds2File -> returnRecordAsString(-compact=>1);
2360 }
2361  
2362 =cut
2363  
2364 sub returnRecordAsString()
2365 255 ▶{
Subroutine returnRecordAsString: called CC=62 SCAR=41.5
Pod documented
2366 255 my($self,%arg) = @_;
2367 255 my $compact = $arg{'-compact'};
2368 255 ▶ $compact = FALSE if (! defined $compact);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $compact 170 85 255
2369 255 my $string = '';
2370 255 $self -> {'UsingPrettyPrint'} = TRUE;
2371 255 my $inText = $self -> {'InTxt'};
2372 255 my $inBoundary = $self -> {'InBoundary'};
2373 255 my $dateFld = $self -> {'DateFld'};
2374 255 ▶ if (! $compact)
Branch: 1 branch
BranchTrueFalseTotal
unless ($compact) 170 85 255
2375 {
2376 170 ▶ $string .= getStrSpace() if ($self -> {'RecordType'} != BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} != 5 164 6 170
2377 $string .= getElmSpace() if (!(
2378 ($self -> {'RecordType'} == BOUNDARY) ||
2379 ($self -> {'RecordType'} == PATH) ||
2380 ($self -> {'RecordType'} == TEXT) ||
2381 ($self -> {'RecordType'} == SREF) ||
2382 170 ▶ ($self -> {'RecordType'} == AREF)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 150 20 170
Condition91%11/12
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
200150
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
146150
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12
l!l&&r!l&&!r
86156
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
62162
MC/DC80%4/5
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 8 $self->{"RecordType"} == 9 $self->{"RecordType"} == 12 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table83%5/6
A or B or C or D or E
A= $self->{"RecordType"} == 8B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 12D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2383 ));
2384 }
2385 255 my $recordType = $RecordTypeStrings[$self -> {'RecordType'}];
2386 255 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 85 170 255
2387 {
2388 85 $string .= $CompactRecordTypeStrings[$self -> {'RecordType'}];
2389 }
2390 else
2391 {
2392 170 $string .= $recordType;
2393 }
2394 255 my $i = 0;
2395 255 ▶ while ($i <= $self -> {'DataIndex'})
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"DataIndex"}) 716 255 971
2396 {
2397 716 ▶ if ($self -> {'DataType'} == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 27 689 716
elsif ($self->{'DataType'} == 2) { } 201 488 689
elsif ($self->{'DataType'} == 3) { } 165 323 488
elsif ($self->{'DataType'} == 5) { } 27 296 323
elsif ($self->{'DataType'} == 6) { } 30 266 296
2398 {
2399 27 my $bitString = $self -> {'RecordData'}[$i];
2400 27 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) 27 0 27
2401 {
2402 27 $bitString =~ m|(........)(........)|;
2403 27 $bitString = "$2$1";
2404 }
2405 27 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 9 18 27
2406 {
2407 9 ▶ $string .= ' fx' if($bitString =~ m/^1/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /^1/ 2 7 9
2408 9 ▶ if ($inText && ($self -> {'RecordType'} != STRANS))
Branch: 1 branch
BranchTrueFalseTotal
if ($inText and $self->{"RecordType"} != 26) 3 6 9
Condition100%3/3
$inText and $self->{"RecordType"} != 26
!ll&&!rl&&r
333
MC/DC100%2/2
$inText and $self->{"RecordType"} != 26
$inText $self->{"RecordType"} != 26
Truth table100%3/3
A and B
A= $inTextB= $self->{"RecordType"} != 26
ABresult
0X0
100
111
2409 {
2410 3 $string .= ' f';
2411 3 ▶ $string .= '0' if ($bitString =~ m/00....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00....$/ 3 0 3
2412 3 ▶ $string .= '1' if ($bitString =~ m/01....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01....$/ 0 3 3
2413 3 ▶ $string .= '2' if ($bitString =~ m/10....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10....$/ 0 3 3
2414 3 ▶ $string .= '3' if ($bitString =~ m/11....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /11....$/ 0 3 3
2415 3 ▶ $string .= ' t' if ($bitString =~ m/00..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00..$/ 0 3 3
2416 3 ▶ $string .= ' m' if ($bitString =~ m/01..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01..$/ 0 3 3
2417 3 ▶ $string .= ' b' if ($bitString =~ m/10..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10..$/ 3 0 3
2418 3 ▶ $string .= 'l' if ($bitString =~ m/00$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00$/ 2 1 3
2419 3 ▶ $string .= 'c' if ($bitString =~ m/01$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01$/ 0 3 3
2420 3 ▶ $string .= 'r' if ($bitString =~ m/10$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10$/ 1 2 3
2421 }
2422 }
2423 else
2424 {
2425 18 $string .= ' '.$bitString;
2426 }
2427 }
2428 elsif ($self -> {'DataType'} == INTEGER_2)
2429 {
2430 201 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 67 134 201
2431 {
2432 67 ▶ if ($dateFld)
Branch: 1 branch
BranchTrueFalseTotal
if ($dateFld) { } 48 19 67
2433 {
2434 48 my $num = $self -> {'RecordData'}[$i];
2435 48 ▶ if ($dateFld =~ m/^[17]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($dateFld =~ /^[17]$/) 8 40 48
2436 {
2437 8 ▶ if ($dateFld eq '1')
Branch: 2 branches
BranchTrueFalseTotal
if ($dateFld eq '1') { } 4 4 8
elsif ($dateFld eq '7') { } 4 0 4
2438 {
2439 4 ▶ if ($recordType eq 'BGNLIB')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq 'BGNLIB') { } 1 3 4
2440 {
2441 1 $string .= 'm=';
2442 }
2443 else
2444 {
2445 3 $string .= 'c=';
2446 }
2447 }
2448 elsif ($dateFld eq '7')
2449 {
2450 4 ▶ if ($recordType eq 'BGNLIB')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq 'BGNLIB') { } 1 3 4
2451 {
2452 1 $string .= ' a=';
2453 }
2454 else
2455 {
2456 3 $string .= ' m=';
2457 }
2458 }
2459 8 ▶ $num += 1900 if ($num < 1900);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 1900 8 0 8
2460 }
2461 48 $num = sprintf("%02d",$num);
2462 48 ▶ $string .= '-' if ($dateFld =~ m/^[2389]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^[2389]/ 16 32 48
2463 48 ▶ $string .= ':' if ($dateFld =~ m/^[56]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^[56]/ 8 40 48
2464 48 ▶ $string .= ':' if ($dateFld =~ m/^1[12]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^1[12]/ 8 40 48
2465 48 ▶ $string .= ' ' if (($dateFld eq '4') || ($dateFld eq '10'));
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld eq 4 or $dateFld eq 10 8 40 48
Condition100%3/3
$dateFld eq 4 or $dateFld eq 10
l!l&&r!l&&!r
4440
MC/DC100%2/2
$dateFld eq 4 or $dateFld eq 10
$dateFld eq 4 $dateFld eq 10
Truth table100%3/3
A or B
A= $dateFld eq 4B= $dateFld eq 10
ABresult
1X1
011
000
2466 48 $string .= $num;
2467 }
2468 else
2469 {
2470 19 ▶ $string .= ' ' unless ($string =~ m/ (a|m|pt|dt|tt)$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ / (a|m|pt|dt|tt)$/i 8 11 19
2471 19 $string .= $self -> {'RecordData'}[$i];
2472 }
2473 }
2474 else
2475 {
2476 134 $string .= ' ';
2477 134 $string .= $self -> {'RecordData'}[$i];
2478 }
2479 201 ▶ if ($recordType eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq "UNITS") 0 201 201
2480 {
2481 0 $string =~ s|(\d)\.e|$1e|; ## perl on Cygwin prints "1.e-9" others "1e-9"
2482 0 $string =~ s|(\d)e\-0+|$1e-|; ## different perls print 1e-9 1e-09 1e-009 etc... standardize to 1e-9
2483 }
2484 }
2485 elsif ($self -> {'DataType'} == INTEGER_4)
2486 {
2487 165 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 55 110 165
2488 {
2489 55 ▶ $string .= ' ' if ($i);
Branch: 1 branch
BranchTrueFalseTotal
if $i 44 11 55
2490 }
2491 else
2492 {
2493 110 $string .= ' ';
2494 }
2495 165 $string .= cleanFloatNum($self -> {'RecordData'}[$i]*($self -> {'UUnits'}));
2496 165 ▶ if ($compact && $i && ($i == $#{$self -> {'RecordData'}}))
Branch: 1 branch
BranchTrueFalseTotal
if ($compact and $i and $i == $#{$$self{"RecordData"};}) 10 155 165
Condition100%6/6
$compact and $i and $i == $#{$$self{"RecordData"};}
!ll&&!rl&&r
1213410
$compact and $i
!ll&&!rl&&r
1101144
MC/DC100%3/3
$compact and $i and $i == $#{$$self{"RecordData"};}
$compact $i $i == $#{$$self{"RecordData"};}
Truth table100%4/4
A and B and C
A= $compactB= $iC= $i == $#{$$self{"RecordData"};}
ABCresult
0XX0
10X0
1100
1111
2497 {
2498 10 ▶ $string =~ s/ +[\d\.\-]+ +[\d\.\-]+$// if ($inBoundary); #remove last point
Branch: 1 branch
BranchTrueFalseTotal
if $inBoundary 3 7 10
2499 10 $string .= ')';
2500 }
2501 }
2502 elsif ($self -> {'DataType'} == REAL_8)
2503 {
2504 27 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 9 18 27
2505 {
2506 9 ▶ $string .= ' ' unless ($string =~ m/ (a|m|pt|dt|tt)$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ / (a|m|pt|dt|tt)$/i 2 7 9
2507 }
2508 else
2509 {
2510 18 $string .= ' ';
2511 }
2512 27 my $num = $self -> {'RecordData'}[$i];
2513 27 ▶ if ($num =~ m/e/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($num =~ /e/i) { } 3 24 27
2514 {
2515 3 $num = cleanExpNum($num);
2516 }
2517 else
2518 {
2519 24 $num = cleanFloatNum($num);
2520 }
2521 27 $string .= $num;
2522 27 ▶ if ($recordType eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq "UNITS") 6 21 27
2523 {
2524 6 $string =~ s|(\d)\.e|$1e|; ## perl on Cygwin prints "1.e-9" others "1e-9"
2525 6 $string =~ s|(\d)e\-0+|$1e-|; ## different perls print 1e-9 1e-09 1e-009 etc... standardize to shorter 1e-9
2526 }
2527 }
2528 elsif ($self -> {'DataType'} == ACSII_STRING)
2529 {
2530 30 ▶ $string .= ' ' if (! $compact);
Branch: 1 branch
BranchTrueFalseTotal
unless $compact 20 10 30
2531 30 $string .= " '".$self -> {'RecordData'}[$i]."'";
2532 }
2533 716 $i++;
2534 716 ▶ $dateFld++ if ($dateFld);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld 144 572 716
2535 }
2536  
2537 255 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) 85 170 255
2538 {
2539 85 $G_gdtString .= $string;
2540 85 ▶ if (($G_gdtString =~ m/}$/ || $G_gdtString =~ m/^(gds2|lib|m).*\d$/) || ($G_gdtString =~ m/^cell.*'$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/) { } 20 65 85
Condition100%6/6
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/
l!l&&r!l&&!r
17365
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/
l!l&&r!l&&!r
14368
MC/DC100%3/3
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/
$G_gdtString =~ /}$/ $G_gdtString =~ /^(gds2|lib|m).*\d$/ $G_gdtString =~ /^cell.*'$/
Truth table100%4/4
A or B or C
A= $G_gdtString =~ /}$/B= $G_gdtString =~ /^(gds2|lib|m).*\d$/C= $G_gdtString =~ /^cell.*'$/
ABCresult
1XX1
01X1
0011
0000
2541 {
2542 20 $string = "$G_gdtString\n";
2543 20 $string =~ s/{ /{/; #a little more compact
2544 20 $string =~ s/(dt0|pt0|tt0|m1|w0|f0) //g; #these are all default in true GDT format
2545 20 $G_gdtString = "";
2546 }
2547 else
2548 {
2549 65 $string = "";
2550 }
2551 }
2552  
2553 255 $string;
2554 }
2555 ################################################################################
2556  
2557 =head2 returnXyAsArray - returns current (read) XY record as an array
2558  
2559 usage:
2560 $gds2File -> returnXyAsArray(
2561 -asInteger => 0|1 ## (optional) default is true. Return integer
2562 ## array or if false return array of reals.
2563 -withClosure => 0|1 ## (optional) default is true. Whether to
2564 ##return a rectangle with 5 or 4 points.
2565 );
2566  
2567 example:
2568 while ($gds2File -> readGds2Record)
2569 {
2570 my @xy = $gds2File -> returnXyAsArray if ($gds2File -> isXy);
2571 }
2572  
2573 =cut
2574  
2575 sub returnXyAsArray()
2576 0 ▶{
Subroutine returnXyAsArray: not called CC=8 SCAR=42.8
Pod documented
2577 0 my($self,%arg) = @_;
2578 0 my $asInteger = $arg{'-asInteger'};
2579 0 ▶ $asInteger = TRUE unless (defined $asInteger);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $asInteger 0 0 0
2580 0 my $withClosure = $arg{'-withClosure'};
2581 0 ▶ $withClosure = TRUE unless (defined $withClosure);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $withClosure 0 0 0
2582 0 my @xys=();
2583 0 ▶ if ($self -> isXy)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isXy) 0 0 0
2584 {
2585 0 my $i = 0;
2586 0 my $stopPoint = $self -> {'DataIndex'};
2587 0 ▶ if ($withClosure)
Branch: 1 branch
BranchTrueFalseTotal
if ($withClosure) { } 0 0 0
2588 {
2589 0 ▶ return @{$self -> {'RecordData'}} if ($asInteger);
Branch: 1 branch
BranchTrueFalseTotal
if $asInteger 0 0 0
2590 }
2591 else
2592 {
2593 0 $stopPoint -= 2;
2594 }
2595 0 my $num=0;
2596 0 ▶ while ($i <= $stopPoint)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $stopPoint) 0 0 0
2597 {
2598 0 ▶ if ($asInteger)
Branch: 1 branch
BranchTrueFalseTotal
if ($asInteger) { } 0 0 0
2599 {
2600 0 $num = $self -> {'RecordData'}[$i];
2601 }
2602 else
2603 {
2604 0 $num = cleanFloatNum($self -> {'RecordData'}[$i]*($self -> {'UUnits'}));
2605 }
2606 0 push @xys,$num;
2607 0 $i++;
2608 }
2609 }
2610 0 @xys;
2611 }
2612 ################################################################################
2613  
2614  
2615 =head2 returnRecordAsPerl - returns current (read) record as a perl command to facilitate the creation of parameterized gds2 data with perl.
2616  
2617 usage:
2618 #!/usr/local/bin/perl
2619 use GDS2;
2620 my $gds2File = new GDS2(-fileName=>"test.gds");
2621 while ($gds2File -> readGds2Record)
2622 {
2623 print $gds2File -> returnRecordAsPerl;
2624 }
2625  
2626 =cut
2627  
2628 sub returnRecordAsPerl()
2629 0 ▶{
Subroutine returnRecordAsPerl: not called CC=27 SCAR=66.3
Pod documented
2630 0 my($self,%arg) = @_;
2631  
2632 0 my $gds2File = $arg{'-gds2File'};
2633 0 ▶ $gds2File = '$gds2File' unless (defined $gds2File);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gds2File 0 0 0
2634  
2635 0 my $PGR = $arg{'-printGds2Record'};
2636 0 ▶ $PGR = 'printGds2Record' unless (defined $PGR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $PGR 0 0 0
2637  
2638 0 my $string = '';
2639 0 $self -> {'UsingPrettyPrint'} = TRUE;
2640 0 ▶ $string .= getStrSpace() if ($self -> {'RecordType'} != BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} != 5 0 0 0
2641 $string .= getElmSpace() if (!(
2642 ($self -> {'RecordType'} == TEXT) ||
2643 ($self -> {'RecordType'} == PATH) ||
2644 ($self -> {'RecordType'} == BOUNDARY) ||
2645 ($self -> {'RecordType'} == SREF) ||
2646 0 ▶ ($self -> {'RecordType'} == AREF)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 0 0 0
Condition0%0/12
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
000
MC/DC0%0/5
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table0%0/6
A or B or C or D or E
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2647 ));
2648 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 12 or $self->{'RecordType'} == 9 or $self->{'RecordType'} == 8 or $self->{'RecordType'} == 10 or $self->{'RecordType'} == 11 or $self->{'RecordType'} == 17 or $self->{'RecordType'} == 7 or $self->{'RecordType'} == 4) { } 0 0 0
Condition0%0/21
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7 or $self->{"RecordType"} == 4
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
000
MC/DC0%0/8
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7 or $self->{"RecordType"} == 4
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11 $self->{"RecordType"} == 17 $self->{"RecordType"} == 7 $self->{"RecordType"} == 4
Truth table0%0/9
A or B or C or D or E or F or G or H
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11F= $self->{"RecordType"} == 17G= $self->{"RecordType"} == 7H= $self->{"RecordType"} == 4
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
2649 ($self -> {'RecordType'} == TEXT) ||
2650 ($self -> {'RecordType'} == PATH) ||
2651 ($self -> {'RecordType'} == BOUNDARY) ||
2652 ($self -> {'RecordType'} == SREF) ||
2653 ($self -> {'RecordType'} == AREF) ||
2654 ($self -> {'RecordType'} == ENDEL) ||
2655 ($self -> {'RecordType'} == ENDSTR) ||
2656 ($self -> {'RecordType'} == ENDLIB)
2657 )
2658 {
2659 0 $string .= $gds2File.'->'.$PGR.'(-type=>'."'".$RecordTypeStrings[$self -> {'RecordType'}]."'".');';
2660 }
2661 else
2662 {
2663 0 $string .= $gds2File.'->'.$PGR.'(-type=>'."'".$RecordTypeStrings[$self -> {'RecordType'}]."',-data=>";
2664 0 my $i = 0;
2665 0 my $maxi = $self -> {'DataIndex'};
2666 0 ▶ if ($maxi >= 1) {$string .= '['}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxi >= 1) 0 0 0
2667 0 ▶ while ($i <= $maxi)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $maxi) 0 0 0
2668 {
2669 0 ▶ if ($self -> {'DataType'} == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 0 0 0
elsif ($self->{'DataType'} == 2) { } 0 0 0
elsif ($self->{'DataType'} == 3) { } 0 0 0
elsif ($self->{'DataType'} == 5) { } 0 0 0
elsif ($self->{'DataType'} == 6) { } 0 0 0
2670 {
2671 0 my $bitString = $self -> {'RecordData'}[$i];
2672 0 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) 0 0 0
2673 {
2674 0 $bitString =~ m|(........)(........)|;
2675 0 $bitString = "$2$1";
2676 }
2677 0 $string .= "'$bitString'";
2678 }
2679 elsif ($self -> {'DataType'} == INTEGER_2)
2680 {
2681 0 $string .= $self -> {'RecordData'}[$i];
2682 }
2683 elsif ($self -> {'DataType'} == INTEGER_4)
2684 {
2685 0 $string .= $self -> {'RecordData'}[$i];
2686 }
2687 elsif ($self -> {'DataType'} == REAL_8)
2688 {
2689 0 $string .= $self -> {'RecordData'}[$i];
2690 }
2691 elsif ($self -> {'DataType'} == ACSII_STRING)
2692 {
2693 0 $string .= "'".$self -> {'RecordData'}[$i]."'";
2694 }
2695 0 ▶ if ($i < $maxi) {$string .= ', '}
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $maxi) 0 0 0
2696 0 $i++;
2697 }
2698 0 ▶ if ($maxi >= 1) {$string .= ']'}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxi >= 1) 0 0 0
2699 0 $string .= ');';
2700 }
2701 0 $string;
2702 }
2703 ################################################################################
2704  
2705  
2706 =head1 Low Level Specific Write Methods
2707  
2708 =cut
2709  
2710 ################################################################################
2711  
2712 =head2 printAngle - prints ANGLE record
2713  
2714 usage:
2715 $gds2File -> printAngle(-num=>#.#);
2716  
2717 =cut
2718  
2719 sub printAngle
2720 0 ▶{
Subroutine printAngle: not called CC=3 SCAR=24.8
Pod documented
2721 0 my($self,%arg) = @_;
2722 0 my $angle = $arg{'-num'};
2723 0 ▶ if (defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $angle) { } 0 0 0
2724 {
2725 0 $angle=posAngle($angle);
2726 }
2727 else
2728 {
2729 0 $angle = -1; #not really... just means not specified
2730 }
2731 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
2732 }
2733 ################################################################################
2734  
2735 =head2 printAttrtable - prints ATTRTABLE record
2736  
2737 usage:
2738 $gds2File -> printAttrtable(-string=>$string);
2739  
2740 =cut
2741  
2742 sub printAttrtable
2743 0 ▶{
Subroutine printAttrtable: not called CC=2 SCAR=17.9
Pod documented
2744 0 my($self,%arg) = @_;
2745 0 my $string = $arg{'-string'};
2746 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
2747 {
2748 0 die "printAttrtable expects a string. Missing -string => 'text' $!";
2749 }
2750 0 $self -> printGds2Record(-type => 'ATTRTABLE',-data => $string);
2751 }
2752 ################################################################################
2753  
2754 =head2 printBgnextn - prints BGNEXTN record
2755  
2756 usage:
2757 $gds2File -> printBgnextn(-num=>#.#);
2758  
2759 =cut
2760  
2761 sub printBgnextn
2762 0 ▶{
Subroutine printBgnextn: not called CC=3 SCAR=24.8
Pod documented
2763 0 my($self,%arg) = @_;
2764 0 my $num = $arg{'-num'};
2765 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2766 {
2767 0 die "printBgnextn expects a extension number. Missing -num => #.# $!";
2768 }
2769 0 my $resolution = $self -> {'Resolution'};
2770 0 ▶ if ($num >= 0) {$num = int(($num*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($num >= 0) { } 0 0 0
2771 0 else {$num = int(($num*$resolution)-$G_epsilon);}
2772 0 $self -> printGds2Record(-type => 'BGNEXTN',-data => $num);
2773 }
2774 ################################################################################
2775  
2776 =head2 printBgnlib - prints BGNLIB record
2777  
2778 usage:
2779 $gds2File -> printBgnlib(
2780 -isoDate => 0|1 ## (optional) use ISO 4 digit date 2001 vs 101
2781 );
2782  
2783 =cut
2784  
2785 sub printBgnlib
2786 0 ▶{
Subroutine printBgnlib: not called CC=4 SCAR=30.0
Pod documented
2787 0 my($self,%arg) = @_;
2788 0 my $isoDate = $arg{'-isoDate'};
2789 0 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 0 0 0
elsif ($isoDate != 0) { } 0 0 0
2790 {
2791 0 $isoDate = 0;
2792 }
2793 elsif ($isoDate != 0)
2794 {
2795 0 $isoDate = 1;
2796 }
2797 0 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
2798 0 $mon++;
2799 0 ▶ $year += 1900 if ($isoDate); ## Cadence likes year left "as is". GDS format supports year number up to 65535 -- 101 vs 2001
Branch: 1 branch
BranchTrueFalseTotal
if $isoDate 0 0 0
2800 0 $self -> printGds2Record(-type=>'BGNLIB',-data=>[$year,$mon,$mday,$hour,$min,$sec,$year,$mon,$mday,$hour,$min,$sec]);
2801 }
2802 ################################################################################
2803  
2804 =head2 printBox - prints BOX record
2805  
2806 usage:
2807 $gds2File -> printBox;
2808  
2809 =cut
2810  
2811 sub printBox
2812 0 ▶{
Subroutine printBox: not called CC=1 SCAR=6.9
Pod documented
2813 0 my $self = shift;
2814 0 $self -> printGds2Record(-type => 'BOX');
2815 }
2816 ################################################################################
2817  
2818 =head2 printBoxtype - prints BOXTYPE record
2819  
2820 usage:
2821 $gds2File -> printBoxtype(-num=>#);
2822  
2823 =cut
2824  
2825 sub printBoxtype
2826 0 ▶{
Subroutine printBoxtype: not called CC=2 SCAR=17.9
Pod documented
2827 0 my($self,%arg) = @_;
2828 0 my $num = $arg{'-num'};
2829 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2830 {
2831 0 die "printBoxtype expects a number. Missing -num => # $!";
2832 }
2833 0 $self -> printGds2Record(-type => 'BOXTYPE',-data => $num);
2834 }
2835 ################################################################################
2836  
2837 =head2 printColrow - prints COLROW record
2838  
2839 usage:
2840 $gds2File -> printBoxtype(-columns=>#, -rows=>#);
2841  
2842 =cut
2843  
2844 sub printColrow
2845 0 ▶{
Subroutine printColrow: not called CC=5 SCAR=34.0
Pod documented
2846 0 my($self,%arg) = @_;
2847 0 my $columns = $arg{'-columns'};
2848 0 ▶ if ((! defined $columns)||($columns <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $columns or $columns <= 0) { } 0 0 0
Condition0%0/3
not defined $columns or $columns <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $columns or $columns <= 0
not defined $columns $columns <= 0
Truth table0%0/3
not(A) or B
A= not defined $columnsB= $columns <= 0
ABresult
1X1
011
000
2849 {
2850 0 $columns=1;
2851 }
2852 else
2853 {
2854 0 $columns=int($columns);
2855 }
2856 0 my $rows = $arg{'-rows'};
2857 0 ▶ if ((! defined $rows)||($rows <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $rows or $rows <= 0) { } 0 0 0
Condition0%0/3
not defined $rows or $rows <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $rows or $rows <= 0
not defined $rows $rows <= 0
Truth table0%0/3
not(A) or B
A= not defined $rowsB= $rows <= 0
ABresult
1X1
011
000
2858 {
2859 0 $rows=1;
2860 }
2861 else
2862 {
2863 0 $rows=int($rows);
2864 }
2865 0 $self -> printGds2Record(-type => 'COLROW',-data => [$columns,$rows]);
2866 }
2867 ################################################################################
2868  
2869 =head2 printDatatype - prints DATATYPE record
2870  
2871 usage:
2872 $gds2File -> printDatatype(-num=>#);
2873  
2874 =cut
2875  
2876 sub printDatatype
2877 0 ▶{
Subroutine printDatatype: not called CC=2 SCAR=17.9
Pod documented
2878 0 my($self,%arg) = @_;
2879 0 my $dataType = $arg{'-num'};
2880 0 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 0 0 0
2881 0 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
2882 }
2883 ################################################################################
2884  
2885 sub printEflags
2886 0 ▶{
Subroutine printEflags: not called CC=1 SCAR=6.9
Pod undocumented
2887 0 my $self = shift;
2888 0 die "EFLAGS type not supported $!";
2889 }
2890 ################################################################################
2891  
2892 =head2 printElkey - prints ELKEY record
2893  
2894 usage:
2895 $gds2File -> printElkey(-num=>#);
2896  
2897 =cut
2898  
2899 sub printElkey
2900 0 ▶{
Subroutine printElkey: not called CC=2 SCAR=17.9
Pod documented
2901 0 my($self,%arg) = @_;
2902 0 my $num = $arg{'-num'};
2903 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2904 {
2905 0 die "printElkey expects a number. Missing -num => #.# $!";
2906 }
2907 0 $self -> printGds2Record(-type => 'ELKEY',-data => $num);
2908 }
2909 ################################################################################
2910  
2911 =head2 printEndel - closes an element definition
2912  
2913 =cut
2914  
2915 sub printEndel
2916 0 ▶{
Subroutine printEndel: not called CC=1 SCAR=6.9
Pod documented
2917 0 my $self = shift;
2918 0 $self -> printGds2Record(-type => 'ENDEL');
2919 }
2920 ################################################################################
2921  
2922 =head2 printEndextn - prints path end extension record
2923  
2924 usage:
2925 $gds2File printEndextn -> (-num=>#.#);
2926  
2927 =cut
2928  
2929 sub printEndextn
2930 0 ▶{
Subroutine printEndextn: not called CC=3 SCAR=24.8
Pod documented
2931 0 my($self,%arg) = @_;
2932 0 my $num = $arg{'-num'};
2933 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2934 {
2935 0 die "printEndextn expects a extension number. Missing -num => #.# $!";
2936 }
2937 0 my $resolution = $self -> {'Resolution'};
2938 0 ▶ if ($num >= 0) {$num = int(($num*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($num >= 0) { } 0 0 0
2939 0 else {$num = int(($num*$resolution)-$G_epsilon);}
2940 0 $self -> printGds2Record(-type => 'ENDEXTN',-data => $num);
2941 }
2942 ################################################################################
2943  
2944 =head2 printEndlib - closes a library definition
2945  
2946 =cut
2947  
2948 sub printEndlib
2949 2 ▶{
Subroutine printEndlib: called CC=1 SCAR=0.0
Pod documented
2950 2 my $self = shift;
2951 2 $self -> printGds2Record(-type => 'ENDLIB');
2952 }
2953 ################################################################################
2954  
2955 =head2 printEndstr - closes a structure definition
2956  
2957 =cut
2958  
2959 sub printEndstr
2960 4 ▶{
Subroutine printEndstr: called CC=1 SCAR=0.0
Pod documented
2961 4 my $self = shift;
2962 4 $self -> printGds2Record(-type => 'ENDSTR');
2963 }
2964 ################################################################################
2965  
2966 =head2 printEndmasks - prints a ENDMASKS
2967  
2968 =cut
2969  
2970 sub printEndmasks
2971 0 ▶{
Subroutine printEndmasks: not called CC=1 SCAR=6.9
Pod documented
2972 0 my $self = shift;
2973 0 $self -> printGds2Record(-type => 'ENDMASKS');
2974 }
2975 ################################################################################
2976  
2977 =head2 printFonts - prints a FONTS record
2978  
2979 usage:
2980 $gds2File -> printFonts(-string=>'names_of_font_files');
2981  
2982 =cut
2983  
2984 sub printFonts
2985 0 ▶{
Subroutine printFonts: not called CC=2 SCAR=17.9
Pod documented
2986 0 my($self,%arg) = @_;
2987 0 my $string = $arg{'-string'};
2988 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
2989 {
2990 0 die "printFonts expects a string. Missing -string => 'text' $!";
2991 }
2992 0 $self -> printGds2Record(-type => 'FONTS',-data => $string);
2993 }
2994 ################################################################################
2995  
2996 sub printFormat
2997 0 ▶{
Subroutine printFormat: not called CC=2 SCAR=17.9
Pod undocumented
2998 0 my($self,%arg) = @_;
2999 0 my $num = $arg{'-num'};
3000 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3001 {
3002 0 die "printFormat expects a number. Missing -num => #.# $!";
3003 }
3004 0 $self -> printGds2Record(-type => 'FORMAT',-data => $num);
3005 }
3006 ################################################################################
3007  
3008 sub printGenerations
3009 0 ▶{
Subroutine printGenerations: not called CC=1 SCAR=6.9
Pod undocumented
3010 0 my $self = shift;
3011 0 $self -> printGds2Record(-type => 'GENERATIONS');
3012 }
3013 ################################################################################
3014  
3015 =head2 printHeader - Prints a rev 3 header
3016  
3017 usage:
3018 $gds2File -> printHeader(
3019 -num => # ## optional, defaults to 3. valid revs are 0,3,4,5,and 600
3020 );
3021  
3022 =cut
3023  
3024 sub printHeader
3025 0 ▶{
Subroutine printHeader: not called CC=2 SCAR=17.9
Pod documented
3026 0 my($self,%arg) = @_;
3027 0 my $rev = $arg{'-num'};
3028 0 ▶ unless (defined $rev)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rev) 0 0 0
3029 {
3030 0 $rev=3;
3031 }
3032 0 $self -> printGds2Record(-type=>'HEADER',-data=>$rev);
3033 }
3034 ################################################################################
3035  
3036 =head2 printLayer - prints a LAYER number
3037  
3038 usage:
3039 $gds2File -> printLayer(
3040 -num => # ## optional, defaults to 0.
3041 );
3042  
3043 =cut
3044  
3045 sub printLayer
3046 0 ▶{
Subroutine printLayer: not called CC=2 SCAR=17.9
Pod documented
3047 0 my($self,%arg) = @_;
3048 0 my $layer = $arg{'-num'};
3049 0 ▶ $layer = 0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 0 0
3050 0 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
3051 }
3052 ################################################################################
3053  
3054 sub printLibdirsize
3055 0 ▶{
Subroutine printLibdirsize: not called CC=1 SCAR=6.9
Pod undocumented
3056 0 my $self = shift;
3057 0 $self -> printGds2Record(-type => 'LIBDIRSIZE');
3058 }
3059 ################################################################################
3060  
3061 =head2 printLibname - Prints library name
3062  
3063 usage:
3064 printLibname(-name=>$name);
3065  
3066 =cut
3067  
3068 sub printLibname
3069 0 ▶{
Subroutine printLibname: not called CC=2 SCAR=17.9
Pod documented
3070 0 my($self,%arg) = @_;
3071 0 my $libName = $arg{'-name'};
3072 0 ▶ unless (defined $libName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $libName) 0 0 0
3073 {
3074 0 die "printLibname expects a library name. Missing -name => 'name' $!";
3075 }
3076 0 $self -> printGds2Record(-type => 'LIBNAME',-data => $libName);
3077 }
3078 ################################################################################
3079  
3080 sub printLibsecur
3081 0 ▶{
Subroutine printLibsecur: not called CC=1 SCAR=6.9
Pod undocumented
3082 0 my $self = shift;
3083 0 $self -> printGds2Record(-type => 'LIBSECUR');
3084 }
3085 ################################################################################
3086  
3087 sub printLinkkeys
3088 0 ▶{
Subroutine printLinkkeys: not called CC=2 SCAR=17.9
Pod undocumented
3089 0 my($self,%arg) = @_;
3090 0 my $num = $arg{'-num'};
3091 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3092 {
3093 0 die "printLinkkeys expects a number. Missing -num => #.# $!";
3094 }
3095 0 $self -> printGds2Record(-type => 'LINKKEYS',-data => $num);
3096 }
3097 ################################################################################
3098  
3099 sub printLinktype
3100 0 ▶{
Subroutine printLinktype: not called CC=2 SCAR=17.9
Pod undocumented
3101 0 my($self,%arg) = @_;
3102 0 my $num = $arg{'-num'};
3103 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3104 {
3105 0 die "printLinktype expects a number. Missing -num => #.# $!";
3106 }
3107 0 $self -> printGds2Record(-type => 'LINKTYPE',-data => $num);
3108 }
3109 ################################################################################
3110  
3111 =head2 printPathtype - prints a PATHTYPE number
3112  
3113 usage:
3114 $gds2File -> printPathtype(
3115 -num => # ## optional, defaults to 0.
3116 );
3117  
3118 =cut
3119  
3120 sub printPathtype
3121 0 ▶{
Subroutine printPathtype: not called CC=3 SCAR=24.8
Pod documented
3122 0 my($self,%arg) = @_;
3123 0 my $pathType = $arg{'-num'};
3124 0 ▶ $pathType=0 if (! defined $pathType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pathType 0 0 0
3125 0 ▶ $self -> printGds2Record(-type => 'PATHTYPE',-data => $pathType) if ($pathType);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType 0 0 0
3126 }
3127 ################################################################################
3128  
3129 =head2 printMag - prints a MAG number
3130  
3131 usage:
3132 $gds2File -> printMag(
3133 -num => #.# ## optional, defaults to 0.0
3134 );
3135  
3136 =cut
3137  
3138 sub printMag
3139 0 ▶{
Subroutine printMag: not called CC=4 SCAR=30.0
Pod documented
3140 0 my($self,%arg) = @_;
3141 0 my $mag = $arg{'-num'};
3142 0 ▶ $mag=0 if ((! defined $mag)||($mag <= 0));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $mag or $mag <= 0 0 0 0
Condition0%0/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table0%0/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
3143 0 $mag = cleanFloatNum($mag);
3144 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
3145 }
3146 ################################################################################
3147  
3148 sub printMask
3149 0 ▶{
Subroutine printMask: not called CC=2 SCAR=17.9
Pod undocumented
3150 0 my($self,%arg) = @_;
3151 0 my $string = $arg{'-string'};
3152 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3153 {
3154 0 die "printMask expects a string. Missing -string => 'text' $!";
3155 }
3156 0 $self -> printGds2Record(-type => 'MASK',-data => $string);
3157 }
3158 ################################################################################
3159  
3160 sub printNode
3161 0 ▶{
Subroutine printNode: not called CC=1 SCAR=6.9
Pod undocumented
3162 0 my $self = shift;
3163 0 $self -> printGds2Record(-type => 'NODE');
3164 }
3165 ################################################################################
3166  
3167 =head2 printNodetype - prints a NODETYPE number
3168  
3169 usage:
3170 $gds2File -> printNodetype(
3171 -num => #
3172 );
3173  
3174 =cut
3175  
3176 sub printNodetype
3177 0 ▶{
Subroutine printNodetype: not called CC=2 SCAR=17.9
Pod documented
3178 0 my($self,%arg) = @_;
3179 0 my $num = $arg{'-num'};
3180 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3181 {
3182 0 die "printNodetype expects a number. Missing -num => # $!";
3183 }
3184 0 $self -> printGds2Record(-type => 'NODETYPE',-data => $num);
3185 }
3186 ################################################################################
3187  
3188 sub printPlex
3189 0 ▶{
Subroutine printPlex: not called CC=2 SCAR=17.9
Pod undocumented
3190 0 my($self,%arg) = @_;
3191 0 my $num = $arg{'-num'};
3192 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3193 {
3194 0 die "printPlex expects a number. Missing -num => #.# $!";
3195 }
3196 0 $self -> printGds2Record(-type => 'PLEX',-data => $num);
3197 }
3198 ################################################################################
3199  
3200 =head2 printPresentation - prints a text presentation record
3201  
3202 usage:
3203 $gds2File -> printPresentation(
3204 -font => #, ##optional, defaults to 0, valid numbers are 0-3
3205 -top, ||-middle, || -bottom, ## vertical justification
3206 -left, ||-center, || -right, ## horizontal justification
3207 );
3208  
3209 example:
3210 gds2File -> printPresentation(-font=>0,-top,-left);
3211  
3212 =cut
3213  
3214 sub printPresentation
3215 0 ▶{
Subroutine printPresentation: not called CC=8 SCAR=42.8
Pod documented
3216 0 my($self,%arg) = @_;
3217 0 my $font = $arg{'-font'};
3218 0 ▶ if ((! defined $font) || ($font < 0) || ($font > 3))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $font or $font < 0 or $font > 3) 0 0 0
Condition0%0/6
not defined $font or $font < 0 or $font > 3
l!l&&r!l&&!r
000
not defined $font or $font < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $font or $font < 0 or $font > 3
not defined $font $font < 0 $font > 3
Truth table0%0/4
not(A) or B or C
A= not defined $fontB= $font < 0C= $font > 3
ABCresult
1XX1
01X1
0011
0000
3219 {
3220 0 $font=0;
3221 }
3222 0 $font = sprintf("%02d",$font);
3223  
3224 0 my $vertical;
3225 0 my $top = $arg{'-top'};
3226 0 my $middle = $arg{'-middle'};
3227 0 my $bottom = $arg{'-bottom'};
3228 0 ▶ if (defined $top) {$vertical = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $top) { } 0 0 0
elsif (defined $bottom) { } 0 0 0
3229 0 elsif (defined $bottom) {$vertical = '10';}
3230 0 else {$vertical = '01';} ## middle
3231 0 my $horizontal;
3232 0 my $left = $arg{'-left'};
3233 0 my $center = $arg{'-center'};
3234 0 my $right = $arg{'-right'};
3235 0 ▶ if (defined $left) {$horizontal = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $left) { } 0 0 0
elsif (defined $right) { } 0 0 0
3236 0 elsif (defined $right) {$horizontal = '10';}
3237 0 else {$horizontal = '01';} ## center
3238  
3239 0 my $bitstring = '0'x10;
3240 0 $bitstring .= "$font$vertical$horizontal";
3241 0 $self -> printGds2Record(-type => 'PRESENTATION',-data => $bitstring);
3242 }
3243 ################################################################################
3244  
3245 =head2 printPropattr - prints a property id number
3246  
3247 usage:
3248 $gds2File -> printPropattr( -num => # );
3249  
3250 =cut
3251  
3252 sub printPropattr
3253 0 ▶{
Subroutine printPropattr: not called CC=2 SCAR=17.9
Pod documented
3254 0 my($self,%arg) = @_;
3255 0 my $num = $arg{'-num'};
3256 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3257 {
3258 0 die "printPropattr expects a number. Missing -num => # $!";
3259 }
3260 0 $self -> printGds2Record(-type => 'PROPATTR',-data => $num);
3261 }
3262 ################################################################################
3263  
3264 =head2 printPropvalue - prints a property value string
3265  
3266 usage:
3267 $gds2File -> printPropvalue( -string => $string );
3268  
3269 =cut
3270  
3271 sub printPropvalue
3272 0 ▶{
Subroutine printPropvalue: not called CC=2 SCAR=17.9
Pod documented
3273 0 my($self,%arg) = @_;
3274 0 my $string = $arg{'-string'};
3275 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3276 {
3277 0 die "printPropvalue expects a string. Missing -string => 'text' $!";
3278 }
3279 0 $self -> printGds2Record(-type => 'PROPVALUE',-data => $string);
3280 }
3281 ################################################################################
3282  
3283 sub printReflibs
3284 0 ▶{
Subroutine printReflibs: not called CC=2 SCAR=17.9
Pod undocumented
3285 0 my($self,%arg) = @_;
3286 0 my $string = $arg{'-string'};
3287 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3288 {
3289 0 die "printReflibs expects a string. Missing -string => 'text' $!";
3290 }
3291 0 $self -> printGds2Record(-type => 'REFLIBS',-data => $string);
3292 }
3293 ################################################################################
3294  
3295 sub printReserved
3296 0 ▶{
Subroutine printReserved: not called CC=2 SCAR=17.9
Pod undocumented
3297 0 my($self,%arg) = @_;
3298 0 my $num = $arg{'-num'};
3299 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3300 {
3301 0 die "printReserved expects a number. Missing -num => #.# $!";
3302 }
3303 0 $self -> printGds2Record(-type => 'RESERVED',-data => $num);
3304 }
3305 ################################################################################
3306  
3307 =head2 printSname - prints a SNAME string
3308  
3309 usage:
3310 $gds2File -> printSname( -name => $cellName );
3311  
3312 =cut
3313  
3314 sub printSname
3315 0 ▶{
Subroutine printSname: not called CC=2 SCAR=17.9
Pod documented
3316 0 my($self,%arg) = @_;
3317 0 my $string = $arg{'-name'};
3318 0 ▶ if (! defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3319 {
3320 0 die "printSname expects a cell name. Missing -name => 'text' $!";
3321 }
3322 0 $self -> printGds2Record(-type => 'SNAME',-data => $string);
3323 }
3324 ################################################################################
3325  
3326 sub printSpacing
3327 0 ▶{
Subroutine printSpacing: not called CC=1 SCAR=6.9
Pod undocumented
3328 0 my $self = shift;
3329 0 die "SPACING type not supported $!";
3330 }
3331 ################################################################################
3332  
3333 sub printSrfname
3334 0 ▶{
Subroutine printSrfname: not called CC=1 SCAR=6.9
Pod undocumented
3335 0 my $self = shift;
3336 0 $self -> printGds2Record(-type => 'SRFNAME');
3337 }
3338 ################################################################################
3339  
3340 =head2 printStrans - prints a STRANS record
3341  
3342 usage:
3343 $gds2File -> printStrans( -reflect );
3344  
3345 =cut
3346  
3347 sub printStrans
3348 0 ▶{
Subroutine printStrans: not called CC=3 SCAR=24.8
Pod documented
3349 0 my($self,%arg) = @_;
3350 0 my $reflect = $arg{'-reflect'};
3351 0 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 0 0 0
Condition0%0/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table0%0/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
3352 {
3353 0 $reflect = 0;
3354 }
3355 else
3356 {
3357 0 $reflect = 1;
3358 }
3359 0 my $data = $reflect.'0'x15; ## 16 'bit' string
3360 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
3361 }
3362 ################################################################################
3363  
3364 sub printStrclass
3365 0 ▶{
Subroutine printStrclass: not called CC=1 SCAR=6.9
Pod undocumented
3366 0 my $self = shift;
3367 0 $self -> printGds2Record(-type => 'STRCLASS');
3368 }
3369 ################################################################################
3370  
3371 =head2 printString - prints a STRING record
3372  
3373 usage:
3374 $gds2File -> printSname( -string => $text );
3375  
3376 =cut
3377  
3378 sub printString
3379 0 ▶{
Subroutine printString: not called CC=2 SCAR=17.9
Pod documented
3380 0 my($self,%arg) = @_;
3381 0 my $string = $arg{'-string'};
3382 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3383 {
3384 0 die "printString expects a string. Missing -string => 'text' $!";
3385 }
3386 0 $self -> printGds2Record(-type => 'STRING',-data => $string);
3387 }
3388 ################################################################################
3389  
3390 =head2 printStrname - prints a structure name string
3391  
3392 usage:
3393 $gds2File -> printStrname( -name => $cellName );
3394  
3395 =cut
3396  
3397 sub printStrname
3398 0 ▶{
Subroutine printStrname: not called CC=2 SCAR=17.9
Pod documented
3399 0 my($self,%arg) = @_;
3400 0 my $strName = $arg{'-name'};
3401 0 ▶ unless (defined $strName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $strName) 0 0 0
3402 {
3403 0 die "printStrname expects a structure name. Missing -name => 'name' $!";
3404 }
3405 0 $self -> printGds2Record(-type => 'STRNAME',-data => $strName);
3406 }
3407 ################################################################################
3408  
3409 sub printStrtype
3410 0 ▶{
Subroutine printStrtype: not called CC=1 SCAR=6.9
Pod undocumented
3411 0 my $self = shift;
3412 0 die "STRTYPE type not supported $!";
3413 }
3414 ################################################################################
3415  
3416 sub printStyptable
3417 0 ▶{
Subroutine printStyptable: not called CC=2 SCAR=17.9
Pod undocumented
3418 0 my($self,%arg) = @_;
3419 0 my $string = $arg{'-string'};
3420 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3421 {
3422 0 die "printStyptable expects a string. Missing -string => 'text' $!";
3423 }
3424 0 $self -> printGds2Record(-type => 'STYPTABLE',-data => $string);
3425 }
3426 ################################################################################
3427  
3428 sub printTapecode
3429 0 ▶{
Subroutine printTapecode: not called CC=2 SCAR=17.9
Pod undocumented
3430 0 my($self,%arg) = @_;
3431 0 my $num = $arg{'-num'};
3432 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3433 {
3434 0 die "printTapecode expects a number. Missing -num => #.# $!";
3435 }
3436 0 $self -> printGds2Record(-type => 'TAPECODE',-data => $num);
3437 }
3438 ################################################################################
3439  
3440 sub printTapenum
3441 0 ▶{
Subroutine printTapenum: not called CC=2 SCAR=17.9
Pod undocumented
3442 0 my($self,%arg) = @_;
3443 0 my $num = $arg{'-num'};
3444 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3445 {
3446 0 die "printTapenum expects a number. Missing -num => #.# $!";
3447 }
3448 0 $self -> printGds2Record(-type => 'TAPENUM',-data => $num);
3449 }
3450 ################################################################################
3451  
3452 sub printTextnode
3453 0 ▶{
Subroutine printTextnode: not called CC=1 SCAR=6.9
Pod undocumented
3454 0 my $self = shift;
3455 0 $self -> printGds2Record(-type => 'TEXTNODE');
3456 }
3457 ################################################################################
3458  
3459 =head2 printTexttype - prints a text type number
3460  
3461 usage:
3462 $gds2File -> printTexttype( -num => # );
3463  
3464 =cut
3465  
3466 sub printTexttype
3467 0 ▶{
Subroutine printTexttype: not called CC=3 SCAR=24.8
Pod documented
3468 0 my($self,%arg) = @_;
3469 0 my $num = $arg{'-num'};
3470 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3471 {
3472 0 die "printTexttype expects a number. Missing -num => # $!";
3473 }
3474 0 ▶ $num = 0 if ($num < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 0 0 0 0
3475 0 $self -> printGds2Record(-type => 'TEXTTYPE',-data => $num);
3476 }
3477 ################################################################################
3478  
3479 sub printUinteger
3480 0 ▶{
Subroutine printUinteger: not called CC=1 SCAR=6.9
Pod undocumented
3481 0 my $self = shift;
3482 0 die "UINTEGER type not supported $!";
3483 }
3484 ################################################################################
3485  
3486 =head2 printUnits - Prints units record.
3487  
3488 options:
3489 -uUnit => real number ## (optional) default is 0.001
3490 -dbUnit => real number ## (optional) default is 1e-9
3491  
3492 =cut
3493  
3494 sub printUnits
3495 0 ▶{
Subroutine printUnits: not called CC=3 SCAR=24.8
Pod documented
3496 0 my($self,%arg) = @_;
3497  
3498 0 my $uUnit = $arg{'-uUnit'};
3499 0 ▶ if (! defined $uUnit)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $uUnit) { } 0 0 0
3500 {
3501 0 $uUnit = 0.001;
3502 }
3503 else
3504 {
3505 0 $self -> {'Resolution'} = (1 / $uUnit); ## default is 1000 - already set in new()
3506 }
3507 0 $self -> {'UUnits'} = $uUnit;
3508 #################################################
3509 0 my $dbUnit = $arg{'-dbUnit'};
3510 0 ▶ unless (defined $dbUnit)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dbUnit) 0 0 0
3511 {
3512 0 $dbUnit = 1e-9;
3513 }
3514 0 $self -> {'DBUnits'} = $dbUnit;
3515 #################################################
3516  
3517 0 $self -> printGds2Record(-type => 'UNITS',-data => [$uUnit,$dbUnit]);
3518 }
3519 ################################################################################
3520  
3521 sub printUstring
3522 0 ▶{
Subroutine printUstring: not called CC=1 SCAR=6.9
Pod undocumented
3523 0 my $self = shift;
3524 0 die "USTRING type not supported $!";
3525 }
3526 ################################################################################
3527  
3528 =head2 printWidth - prints a width number
3529  
3530 usage:
3531 $gds2File -> printWidth( -num => # );
3532  
3533 =cut
3534  
3535 sub printWidth
3536 0 ▶{
Subroutine printWidth: not called CC=4 SCAR=30.0
Pod documented
3537 0 my($self,%arg) = @_;
3538 0 my $width = $arg{'-num'};
3539 0 ▶ if ((! defined $width)||($width <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $width or $width <= 0) 0 0 0
Condition0%0/3
not defined $width or $width <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $width or $width <= 0
not defined $width $width <= 0
Truth table0%0/3
not(A) or B
A= not defined $widthB= $width <= 0
ABresult
1X1
011
000
3540 {
3541 0 $width=0;
3542 }
3543 0 ▶ $self -> printGds2Record(-type => 'WIDTH',-data => $width) if ($width);
Branch: 1 branch
BranchTrueFalseTotal
if $width 0 0 0
3544 }
3545 ################################################################################
3546  
3547 =head2 printXy - prints an XY array
3548  
3549 usage:
3550 $gds2File -> printXy( -xyInt => \@arrayGds2Ints );
3551 -or-
3552 $gds2File -> printXy( -xy => \@arrayReals );
3553  
3554 -xyInt most useful if reading and modifying... -xy if creating from scratch
3555  
3556 =cut
3557  
3558 sub printXy
3559 0 ▶{
Subroutine printXy: not called CC=6 SCAR=37.4
Pod documented
3560 0 my($self,%arg) = @_;
3561 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
3562 0 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
3563 0 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
3564 0 my $resolution = $self -> {'Resolution'};
3565 0 ▶ if (! ((defined $xy) || (defined $xyInt)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 0 0
Condition0%0/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table0%0/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
3566 {
3567 0 die "printXy expects an xy array reference. Missing -xy => \\\@array $!";
3568 }
3569 0 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 0 0
3570 {
3571 0 $xy = $xyInt;
3572 0 $resolution = 1;
3573 }
3574 0 my @xyTmp=(); ##don't pollute array passed in
3575 0 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 0 0 0
3576 {
3577 0 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 0 0 0
3578 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
3579 }
3580 0 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
3581 }
3582 ################################################################################
3583  
3584  
3585 =head1 Low Level Specific Evaluation Methods
3586  
3587 =cut
3588  
3589 =head2 returnFilePosition - return current byte position (NOT zero based)
3590  
3591 usage:
3592 my $position = $gds2File -> returnFilePosition;
3593  
3594 =cut
3595  
3596 sub returnFilePosition()
3597 0 ▶{
Subroutine returnFilePosition: not called CC=1 SCAR=6.9
Pod documented
3598 0 my $self = shift;
3599 0 $self -> {'BytesDone'};
3600 }
3601 ################################################################################
3602  
3603 sub tellSize() ## old name
3604 0 ▶{
Subroutine tellSize: not called CC=1 SCAR=6.9
Pod undocumented
3605 0 my $self = shift;
3606 0 $self -> {'BytesDone'};
3607 }
3608 ################################################################################
3609  
3610  
3611 =head2 returnBgnextn - returns bgnextn if record is BGNEXTN else returns 0
3612  
3613 usage:
3614  
3615 =cut
3616  
3617 sub returnBgnextn
3618 0 ▶{
Subroutine returnBgnextn: not called CC=2 SCAR=17.9
Pod documented
3619 0 my $self = shift;
3620 ## 2 byte signed integer
3621 0 ▶ if ($self -> isBgnextn) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isBgnextn) { } 0 0 0
3622 0 else { 0; }
3623 }
3624 ################################################################################
3625  
3626 =head2 returnDatatype - returns datatype # if record is DATATYPE else returns -1
3627  
3628 usage:
3629 $dataTypesFound[$gds2File -> returnDatatype] = 1;
3630  
3631 =cut
3632  
3633 sub returnDatatype
3634 0 ▶{
Subroutine returnDatatype: not called CC=2 SCAR=17.9
Pod documented
3635 0 my $self = shift;
3636 ## 2 byte signed integer
3637 0 ▶ if ($self -> isDatatype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isDatatype) { } 0 0 0
3638 0 else { UNKNOWN; }
3639 }
3640 ################################################################################
3641  
3642 =head2 returnEndextn- returns endextn if record is ENDEXTN else returns 0
3643  
3644 usage:
3645  
3646 =cut
3647  
3648 sub returnEndextn
3649 0 ▶{
Subroutine returnEndextn: not called CC=2 SCAR=17.9
Pod undocumented
3650 0 my $self = shift;
3651 ## 2 byte signed integer
3652 0 ▶ if ($self -> isEndextn) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isEndextn) { } 0 0 0
3653 0 else { 0; }
3654 }
3655 ################################################################################
3656  
3657  
3658 =head2 returnLayer - returns layer # if record is LAYER else returns -1
3659  
3660 usage:
3661 $layersFound[$gds2File -> returnLayer] = 1;
3662  
3663 =cut
3664  
3665 sub returnLayer
3666 0 ▶{
Subroutine returnLayer: not called CC=2 SCAR=17.9
Pod documented
3667 0 my $self = shift;
3668 ## 2 byte signed integer
3669 0 ▶ if ($self -> isLayer) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isLayer) { } 0 0 0
3670 0 else { UNKNOWN; }
3671 }
3672 ################################################################################
3673  
3674 =head2 returnPathtype - returns pathtype # if record is PATHTYPE else returns -1
3675  
3676 usage:
3677  
3678 =cut
3679  
3680 sub returnPathtype
3681 0 ▶{
Subroutine returnPathtype: not called CC=2 SCAR=17.9
Pod documented
3682 0 my $self = shift;
3683 ## 2 byte signed integer
3684 0 ▶ if ($self -> isPathtype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPathtype) { } 0 0 0
3685 0 else { UNKNOWN; }
3686 }
3687 ################################################################################
3688  
3689 =head2 returnPropattr - returns propattr # if record is PROPATTR else returns -1
3690  
3691 usage:
3692  
3693 =cut
3694  
3695 sub returnPropattr
3696 0 ▶{
Subroutine returnPropattr: not called CC=2 SCAR=17.9
Pod documented
3697 0 my $self = shift;
3698 ## 2 byte signed integer
3699 0 ▶ if ($self -> isPropattr) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPropattr) { } 0 0 0
3700 0 else { UNKNOWN; }
3701 }
3702 ################################################################################
3703  
3704 =head2 returnPropvalue - returns propvalue string if record is PROPVALUE else returns ''
3705  
3706 usage:
3707  
3708 =cut
3709  
3710 sub returnPropvalue
3711 0 ▶{
Subroutine returnPropvalue: not called CC=2 SCAR=17.9
Pod documented
3712 0 my $self = shift;
3713 0 ▶ if ($self -> isPropvalue) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPropvalue) { } 0 0 0
3714 0 else { ''; }
3715 }
3716 ################################################################################
3717  
3718 =head2 returnSname - return string if record type is SNAME else ''
3719  
3720 =cut
3721  
3722 sub returnSname
3723 0 ▶{
Subroutine returnSname: not called CC=2 SCAR=17.9
Pod documented
3724 0 my $self = shift;
3725 0 ▶ if ($self -> isSname) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isSname) { } 0 0 0
3726 0 else { ''; }
3727 }
3728 ################################################################################
3729  
3730 =head2 returnString - return string if record type is STRING else ''
3731  
3732 =cut
3733  
3734 sub returnString
3735 0 ▶{
Subroutine returnString: not called CC=2 SCAR=17.9
Pod documented
3736 0 my $self = shift;
3737 0 ▶ if ($self -> isString) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isString) { } 0 0 0
3738 0 else { ''; }
3739 }
3740 ################################################################################
3741  
3742 =head2 returnStrname - return string if record type is STRNAME else ''
3743  
3744 =cut
3745  
3746 sub returnStrname
3747 0 ▶{
Subroutine returnStrname: not called CC=2 SCAR=17.9
Pod documented
3748 0 my $self = shift;
3749 0 ▶ if ($self -> isStrname) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isStrname) { } 0 0 0
3750 0 else { ''; }
3751 }
3752 ################################################################################
3753  
3754 =head2 returnTexttype - returns texttype # if record is TEXTTYPE else returns -1
3755  
3756 usage:
3757 $TextTypesFound[$gds2File -> returnTexttype] = 1;
3758  
3759 =cut
3760  
3761 sub returnTexttype
3762 0 ▶{
Subroutine returnTexttype: not called CC=2 SCAR=17.9
Pod documented
3763 0 my $self = shift;
3764 ## 2 byte signed integer
3765 0 ▶ if ($self -> isTexttype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isTexttype) { } 0 0 0
3766 0 else { UNKNOWN; }
3767 }
3768 ################################################################################
3769  
3770 =head2 returnWidth - returns width # if record is WIDTH else returns -1
3771  
3772 usage:
3773  
3774 =cut
3775  
3776 sub returnWidth
3777 0 ▶{
Subroutine returnWidth: not called CC=2 SCAR=17.9
Pod documented
3778 0 my $self = shift;
3779 ## 4 byte signed integer
3780 0 ▶ if ($self -> isWidth) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isWidth) { } 0 0 0
3781 0 else { UNKNOWN; }
3782 }
3783 ################################################################################
3784  
3785 ################################################################################
3786  
3787 =head1 Low Level Specific Boolean Methods
3788  
3789 =cut
3790  
3791 ################################################################################
3792  
3793 =head2 isAref - return 0 or 1 depending on whether current record is an aref
3794  
3795 =cut
3796  
3797 sub isAref
3798 0 ▶{
Subroutine isAref: not called CC=2 SCAR=17.9
Pod documented
3799 0 my $self = shift;
3800 0 ▶ if ($self -> {'RecordType'} == AREF) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 11) { } 0 0 0
3801 0 else { 0; }
3802 }
3803 ################################################################################
3804  
3805 =head2 isBgnlib - return 0 or 1 depending on whether current record is a bgnlib
3806  
3807 =cut
3808  
3809 sub isBgnlib
3810 0 ▶{
Subroutine isBgnlib: not called CC=2 SCAR=17.9
Pod documented
3811 0 my $self = shift;
3812 0 ▶ if ($self -> {'RecordType'} == BGNLIB) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 1) { } 0 0 0
3813 0 else { 0; }
3814 }
3815 ################################################################################
3816  
3817 =head2 isBgnstr - return 0 or 1 depending on whether current record is a bgnstr
3818  
3819 =cut
3820  
3821 sub isBgnstr
3822 0 ▶{
Subroutine isBgnstr: not called CC=2 SCAR=17.9
Pod documented
3823 0 my $self = shift;
3824 0 ▶ if ($self -> {'RecordType'} == BGNSTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 5) { } 0 0 0
3825 0 else { 0; }
3826 }
3827 ################################################################################
3828  
3829 =head2 isBoundary - return 0 or 1 depending on whether current record is a boundary
3830  
3831 =cut
3832  
3833 sub isBoundary
3834 0 ▶{
Subroutine isBoundary: not called CC=2 SCAR=17.9
Pod documented
3835 0 my $self = shift;
3836 0 ▶ if ($self -> {'RecordType'} == BOUNDARY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 8) { } 0 0 0
3837 0 else { 0; }
3838 }
3839 ################################################################################
3840  
3841 =head2 isDatatype - return 0 or 1 depending on whether current record is datatype
3842  
3843 =cut
3844  
3845 sub isDatatype
3846 0 ▶{
Subroutine isDatatype: not called CC=2 SCAR=17.9
Pod documented
3847 0 my $self = shift;
3848 0 ▶ if ($self -> {'RecordType'} == DATATYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 14) { } 0 0 0
3849 0 else { 0; }
3850 }
3851 ################################################################################
3852  
3853 =head2 isEndlib - return 0 or 1 depending on whether current record is endlib
3854  
3855 =cut
3856  
3857 sub isEndlib
3858 0 ▶{
Subroutine isEndlib: not called CC=2 SCAR=17.9
Pod documented
3859 0 my $self = shift;
3860 0 ▶ if ($self -> {'RecordType'} == ENDLIB) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 4) { } 0 0 0
3861 0 else { 0; }
3862 }
3863 ################################################################################
3864  
3865 =head2 isEndel - return 0 or 1 depending on whether current record is endel
3866  
3867 =cut
3868  
3869 sub isEndel
3870 0 ▶{
Subroutine isEndel: not called CC=2 SCAR=17.9
Pod documented
3871 0 my $self = shift;
3872 0 ▶ if ($self -> {'RecordType'} == ENDEL) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 17) { } 0 0 0
3873 0 else { 0; }
3874 }
3875 ################################################################################
3876  
3877 =head2 isEndstr - return 0 or 1 depending on whether current record is endstr
3878  
3879 =cut
3880  
3881 sub isEndstr
3882 0 ▶{
Subroutine isEndstr: not called CC=2 SCAR=17.9
Pod documented
3883 0 my $self = shift;
3884 0 ▶ if ($self -> {'RecordType'} == ENDSTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 7) { } 0 0 0
3885 0 else { 0; }
3886 }
3887 ################################################################################
3888  
3889  
3890 =head2 isHeader - return 0 or 1 depending on whether current record is a header
3891  
3892 =cut
3893  
3894 sub isHeader
3895 0 ▶{
Subroutine isHeader: not called CC=2 SCAR=17.9
Pod documented
3896 0 my $self = shift;
3897 0 ▶ if ($self -> {'RecordType'} == HEADER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 0) { } 0 0 0
3898 0 else { 0; }
3899 }
3900 ################################################################################
3901  
3902 =head2 isLibname - return 0 or 1 depending on whether current record is a libname
3903  
3904 =cut
3905  
3906 sub isLibname
3907 0 ▶{
Subroutine isLibname: not called CC=2 SCAR=17.9
Pod documented
3908 0 my $self = shift;
3909 0 ▶ if ($self -> {'RecordType'} == LIBNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 2) { } 0 0 0
3910 0 else { 0; }
3911 }
3912 ################################################################################
3913  
3914 =head2 isPath - return 0 or 1 depending on whether current record is a path
3915  
3916 =cut
3917  
3918 sub isPath
3919 0 ▶{
Subroutine isPath: not called CC=2 SCAR=17.9
Pod documented
3920 0 my $self = shift;
3921 0 ▶ if ($self -> {'RecordType'} == PATH) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 9) { } 0 0 0
3922 0 else { 0; }
3923 }
3924 ################################################################################
3925  
3926 =head2 isSref - return 0 or 1 depending on whether current record is an sref
3927  
3928 =cut
3929  
3930 sub isSref
3931 0 ▶{
Subroutine isSref: not called CC=2 SCAR=17.9
Pod documented
3932 0 my $self = shift;
3933 0 ▶ if ($self -> {'RecordType'} == SREF) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 10) { } 0 0 0
3934 0 else { 0; }
3935 }
3936 ################################################################################
3937  
3938 =head2 isSrfname - return 0 or 1 depending on whether current record is an srfname
3939  
3940 =cut
3941  
3942 sub isSrfname
3943 0 ▶{
Subroutine isSrfname: not called CC=2 SCAR=17.9
Pod documented
3944 0 my $self = shift;
3945 0 ▶ if ($self -> {'RecordType'} == SRFNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 58) { } 0 0 0
3946 0 else { 0; }
3947 }
3948 ################################################################################
3949  
3950 =head2 isText - return 0 or 1 depending on whether current record is a text
3951  
3952 =cut
3953  
3954 sub isText
3955 0 ▶{
Subroutine isText: not called CC=2 SCAR=17.9
Pod documented
3956 0 my $self = shift;
3957 0 ▶ if ($self -> {'RecordType'} == TEXT) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 12) { } 0 0 0
3958 0 else { 0; }
3959 }
3960 ################################################################################
3961  
3962 =head2 isUnits - return 0 or 1 depending on whether current record is units
3963  
3964 =cut
3965  
3966 sub isUnits
3967 0 ▶{
Subroutine isUnits: not called CC=2 SCAR=17.9
Pod documented
3968 0 my $self = shift;
3969 0 ▶ if ($self -> {'RecordType'} == UNITS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 3) { } 0 0 0
3970 0 else { 0; }
3971 }
3972 ################################################################################
3973  
3974 =head2 isLayer - return 0 or 1 depending on whether current record is layer
3975  
3976 =cut
3977  
3978 sub isLayer
3979 0 ▶{
Subroutine isLayer: not called CC=2 SCAR=17.9
Pod documented
3980 0 my $self = shift;
3981 0 ▶ if ($self -> {'RecordType'} == LAYER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 13) { } 0 0 0
3982 0 else { 0; }
3983 }
3984 ################################################################################
3985  
3986 =head2 isStrname - return 0 or 1 depending on whether current record is strname
3987  
3988 =cut
3989  
3990 sub isStrname
3991 0 ▶{
Subroutine isStrname: not called CC=2 SCAR=17.9
Pod documented
3992 0 my $self = shift;
3993 0 ▶ if ($self -> {'RecordType'} == STRNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 6) { } 0 0 0
3994 0 else { 0; }
3995 }
3996 ################################################################################
3997  
3998 =head2 isWidth - return 0 or 1 depending on whether current record is width
3999  
4000 =cut
4001  
4002 sub isWidth
4003 0 ▶{
Subroutine isWidth: not called CC=2 SCAR=17.9
Pod documented
4004 0 my $self = shift;
4005 0 ▶ if ($self -> {'RecordType'} == WIDTH) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 15) { } 0 0 0
4006 0 else { 0; }
4007 }
4008 ################################################################################
4009  
4010 =head2 isXy - return 0 or 1 depending on whether current record is xy
4011  
4012 =cut
4013  
4014 sub isXy
4015 0 ▶{
Subroutine isXy: not called CC=2 SCAR=17.9
Pod documented
4016 0 my $self = shift;
4017 0 ▶ if ($self -> {'RecordType'} == XY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 16) { } 0 0 0
4018 0 else { 0; }
4019 }
4020 ################################################################################
4021  
4022 =head2 isSname - return 0 or 1 depending on whether current record is sname
4023  
4024 =cut
4025  
4026 sub isSname
4027 0 ▶{
Subroutine isSname: not called CC=2 SCAR=17.9
Pod documented
4028 0 my $self = shift;
4029 0 ▶ if ($self -> {'RecordType'} == SNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 18) { } 0 0 0
4030 0 else { 0; }
4031 }
4032 ################################################################################
4033  
4034 =head2 isColrow - return 0 or 1 depending on whether current record is colrow
4035  
4036 =cut
4037  
4038 sub isColrow
4039 0 ▶{
Subroutine isColrow: not called CC=2 SCAR=17.9
Pod documented
4040 0 my $self = shift;
4041 0 ▶ if ($self -> {'RecordType'} == COLROW) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 19) { } 0 0 0
4042 0 else { 0; }
4043 }
4044 ################################################################################
4045  
4046 =head2 isTextnode - return 0 or 1 depending on whether current record is a textnode
4047  
4048 =cut
4049  
4050 sub isTextnode
4051 0 ▶{
Subroutine isTextnode: not called CC=2 SCAR=17.9
Pod documented
4052 0 my $self = shift;
4053 0 ▶ if ($self -> {'RecordType'} == TEXTNODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 20) { } 0 0 0
4054 0 else { 0; }
4055 }
4056 ################################################################################
4057  
4058 =head2 isNode - return 0 or 1 depending on whether current record is a node
4059  
4060 =cut
4061  
4062 sub isNode
4063 0 ▶{
Subroutine isNode: not called CC=2 SCAR=17.9
Pod documented
4064 0 my $self = shift;
4065 0 ▶ if ($self -> {'RecordType'} == NODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 21) { } 0 0 0
4066 0 else { 0; }
4067 }
4068 ################################################################################
4069  
4070 =head2 isTexttype - return 0 or 1 depending on whether current record is a texttype
4071  
4072 =cut
4073  
4074 sub isTexttype
4075 0 ▶{
Subroutine isTexttype: not called CC=2 SCAR=17.9
Pod documented
4076 0 my $self = shift;
4077 0 ▶ if ($self -> {'RecordType'} == TEXTTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 22) { } 0 0 0
4078 0 else { 0; }
4079 }
4080 ################################################################################
4081  
4082 =head2 isPresentation - return 0 or 1 depending on whether current record is a presentation
4083  
4084 =cut
4085  
4086 sub isPresentation
4087 0 ▶{
Subroutine isPresentation: not called CC=2 SCAR=17.9
Pod documented
4088 0 my $self = shift;
4089 0 ▶ if ($self -> {'RecordType'} == PRESENTATION) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 23) { } 0 0 0
4090 0 else { 0; }
4091 }
4092 ################################################################################
4093  
4094 =head2 isSpacing - return 0 or 1 depending on whether current record is a spacing
4095  
4096 =cut
4097  
4098 sub isSpacing
4099 0 ▶{
Subroutine isSpacing: not called CC=2 SCAR=17.9
Pod documented
4100 0 my $self = shift;
4101 0 ▶ if ($self -> {'RecordType'} == SPACING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 24) { } 0 0 0
4102 0 else { 0; }
4103 }
4104 ################################################################################
4105  
4106 =head2 isString - return 0 or 1 depending on whether current record is a string
4107  
4108 =cut
4109  
4110 sub isString
4111 0 ▶{
Subroutine isString: not called CC=2 SCAR=17.9
Pod documented
4112 0 my $self = shift;
4113 0 ▶ if ($self -> {'RecordType'} == STRING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 25) { } 0 0 0
4114 0 else { 0; }
4115 }
4116 ################################################################################
4117  
4118 =head2 isStrans - return 0 or 1 depending on whether current record is a strans
4119  
4120 =cut
4121  
4122 sub isStrans
4123 0 ▶{
Subroutine isStrans: not called CC=2 SCAR=17.9
Pod documented
4124 0 my $self = shift;
4125 0 ▶ if ($self -> {'RecordType'} == STRANS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 26) { } 0 0 0
4126 0 else { 0; }
4127 }
4128 ################################################################################
4129  
4130 =head2 isMag - return 0 or 1 depending on whether current record is a mag
4131  
4132 =cut
4133  
4134 sub isMag
4135 0 ▶{
Subroutine isMag: not called CC=2 SCAR=17.9
Pod documented
4136 0 my $self = shift;
4137 0 ▶ if ($self -> {'RecordType'} == MAG) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 27) { } 0 0 0
4138 0 else { 0; }
4139 }
4140 ################################################################################
4141  
4142 =head2 isAngle - return 0 or 1 depending on whether current record is a angle
4143  
4144 =cut
4145  
4146 sub isAngle
4147 0 ▶{
Subroutine isAngle: not called CC=2 SCAR=17.9
Pod documented
4148 0 my $self = shift;
4149 0 ▶ if ($self -> {'RecordType'} == ANGLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 28) { } 0 0 0
4150 0 else { 0; }
4151 }
4152 ################################################################################
4153  
4154 =head2 isUinteger - return 0 or 1 depending on whether current record is a uinteger
4155  
4156 =cut
4157  
4158 sub isUinteger
4159 0 ▶{
Subroutine isUinteger: not called CC=2 SCAR=17.9
Pod documented
4160 0 my $self = shift;
4161 0 ▶ if ($self -> {'RecordType'} == UINTEGER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 29) { } 0 0 0
4162 0 else { 0; }
4163 }
4164 ################################################################################
4165  
4166 =head2 isUstring - return 0 or 1 depending on whether current record is a ustring
4167  
4168 =cut
4169  
4170 sub isUstring
4171 0 ▶{
Subroutine isUstring: not called CC=2 SCAR=17.9
Pod documented
4172 0 my $self = shift;
4173 0 ▶ if ($self -> {'RecordType'} == USTRING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 30) { } 0 0 0
4174 0 else { 0; }
4175 }
4176 ################################################################################
4177  
4178 =head2 isReflibs - return 0 or 1 depending on whether current record is a reflibs
4179  
4180 =cut
4181  
4182 sub isReflibs
4183 0 ▶{
Subroutine isReflibs: not called CC=2 SCAR=17.9
Pod documented
4184 0 my $self = shift;
4185 0 ▶ if ($self -> {'RecordType'} == REFLIBS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 31) { } 0 0 0
4186 0 else { 0; }
4187 }
4188 ################################################################################
4189  
4190 =head2 isFonts - return 0 or 1 depending on whether current record is a fonts
4191  
4192 =cut
4193  
4194 sub isFonts
4195 0 ▶{
Subroutine isFonts: not called CC=2 SCAR=17.9
Pod documented
4196 0 my $self = shift;
4197 0 ▶ if ($self -> {'RecordType'} == FONTS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 32) { } 0 0 0
4198 0 else { 0; }
4199 }
4200 ################################################################################
4201  
4202 =head2 isPathtype - return 0 or 1 depending on whether current record is a pathtype
4203  
4204 =cut
4205  
4206 sub isPathtype
4207 0 ▶{
Subroutine isPathtype: not called CC=2 SCAR=17.9
Pod documented
4208 0 my $self = shift;
4209 0 ▶ if ($self -> {'RecordType'} == PATHTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 33) { } 0 0 0
4210 0 else { 0; }
4211 }
4212 ################################################################################
4213  
4214 =head2 isGenerations - return 0 or 1 depending on whether current record is a generations
4215  
4216 =cut
4217  
4218 sub isGenerations
4219 0 ▶{
Subroutine isGenerations: not called CC=2 SCAR=17.9
Pod documented
4220 0 my $self = shift;
4221 0 ▶ if ($self -> {'RecordType'} == GENERATIONS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 34) { } 0 0 0
4222 0 else { 0; }
4223 }
4224 ################################################################################
4225  
4226 =head2 isAttrtable - return 0 or 1 depending on whether current record is a attrtable
4227  
4228 =cut
4229  
4230 sub isAttrtable
4231 0 ▶{
Subroutine isAttrtable: not called CC=2 SCAR=17.9
Pod documented
4232 0 my $self = shift;
4233 0 ▶ if ($self -> {'RecordType'} == ATTRTABLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 35) { } 0 0 0
4234 0 else { 0; }
4235 }
4236 ################################################################################
4237  
4238 =head2 isStyptable - return 0 or 1 depending on whether current record is a styptable
4239  
4240 =cut
4241  
4242 sub isStyptable
4243 0 ▶{
Subroutine isStyptable: not called CC=2 SCAR=17.9
Pod documented
4244 0 my $self = shift;
4245 0 ▶ if ($self -> {'RecordType'} == STYPTABLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 36) { } 0 0 0
4246 0 else { 0; }
4247 }
4248 ################################################################################
4249  
4250 =head2 isStrtype - return 0 or 1 depending on whether current record is a strtype
4251  
4252 =cut
4253  
4254 sub isStrtype
4255 0 ▶{
Subroutine isStrtype: not called CC=2 SCAR=17.9
Pod documented
4256 0 my $self = shift;
4257 0 ▶ if ($self -> {'RecordType'} == STRTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 37) { } 0 0 0
4258 0 else { 0; }
4259 }
4260 ################################################################################
4261  
4262 =head2 isEflags - return 0 or 1 depending on whether current record is a eflags
4263  
4264 =cut
4265  
4266 sub isEflags
4267 0 ▶{
Subroutine isEflags: not called CC=2 SCAR=17.9
Pod documented
4268 0 my $self = shift;
4269 0 ▶ if ($self -> {'RecordType'} == EFLAGS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 38) { } 0 0 0
4270 0 else { 0; }
4271 }
4272 ################################################################################
4273  
4274 =head2 isElkey - return 0 or 1 depending on whether current record is a elkey
4275  
4276 =cut
4277  
4278 sub isElkey
4279 0 ▶{
Subroutine isElkey: not called CC=2 SCAR=17.9
Pod documented
4280 0 my $self = shift;
4281 0 ▶ if ($self -> {'RecordType'} == ELKEY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 39) { } 0 0 0
4282 0 else { 0; }
4283 }
4284 ################################################################################
4285  
4286 =head2 isLinktype - return 0 or 1 depending on whether current record is a linktype
4287  
4288 =cut
4289  
4290 sub isLinktype
4291 0 ▶{
Subroutine isLinktype: not called CC=2 SCAR=17.9
Pod documented
4292 0 my $self = shift;
4293 0 ▶ if ($self -> {'RecordType'} == LINKTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 40) { } 0 0 0
4294 0 else { 0; }
4295 }
4296 ################################################################################
4297  
4298 =head2 isLinkkeys - return 0 or 1 depending on whether current record is a linkkeys
4299  
4300 =cut
4301  
4302 sub isLinkkeys
4303 0 ▶{
Subroutine isLinkkeys: not called CC=2 SCAR=17.9
Pod documented
4304 0 my $self = shift;
4305 0 ▶ if ($self -> {'RecordType'} == LINKKEYS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 41) { } 0 0 0
4306 0 else { 0; }
4307 }
4308 ################################################################################
4309  
4310 =head2 isNodetype - return 0 or 1 depending on whether current record is a nodetype
4311  
4312 =cut
4313  
4314 sub isNodetype
4315 0 ▶{
Subroutine isNodetype: not called CC=2 SCAR=17.9
Pod documented
4316 0 my $self = shift;
4317 0 ▶ if ($self -> {'RecordType'} == NODETYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 42) { } 0 0 0
4318 0 else { 0; }
4319 }
4320 ################################################################################
4321  
4322 =head2 isPropattr - return 0 or 1 depending on whether current record is a propattr
4323  
4324 =cut
4325  
4326 sub isPropattr
4327 0 ▶{
Subroutine isPropattr: not called CC=2 SCAR=17.9
Pod documented
4328 0 my $self = shift;
4329 0 ▶ if ($self -> {'RecordType'} == PROPATTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 43) { } 0 0 0
4330 0 else { 0; }
4331 }
4332 ################################################################################
4333  
4334 =head2 isPropvalue - return 0 or 1 depending on whether current record is a propvalue
4335  
4336 =cut
4337  
4338 sub isPropvalue
4339 0 ▶{
Subroutine isPropvalue: not called CC=2 SCAR=17.9
Pod documented
4340 0 my $self = shift;
4341 0 ▶ if ($self -> {'RecordType'} == PROPVALUE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 44) { } 0 0 0
4342 0 else { 0; }
4343 }
4344 ################################################################################
4345  
4346 =head2 isBox - return 0 or 1 depending on whether current record is a box
4347  
4348 =cut
4349  
4350 sub isBox
4351 0 ▶{
Subroutine isBox: not called CC=2 SCAR=17.9
Pod documented
4352 0 my $self = shift;
4353 0 ▶ if ($self -> {'RecordType'} == BOX) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 45) { } 0 0 0
4354 0 else { 0; }
4355 }
4356 ################################################################################
4357  
4358 =head2 isBoxtype - return 0 or 1 depending on whether current record is a boxtype
4359  
4360 =cut
4361  
4362 sub isBoxtype
4363 0 ▶{
Subroutine isBoxtype: not called CC=2 SCAR=17.9
Pod documented
4364 0 my $self = shift;
4365 0 ▶ if ($self -> {'RecordType'} == BOXTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 46) { } 0 0 0
4366 0 else { 0; }
4367 }
4368 ################################################################################
4369  
4370 =head2 isPlex - return 0 or 1 depending on whether current record is a plex
4371  
4372 =cut
4373  
4374 sub isPlex
4375 0 ▶{
Subroutine isPlex: not called CC=2 SCAR=17.9
Pod documented
4376 0 my $self = shift;
4377 0 ▶ if ($self -> {'RecordType'} == PLEX) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 47) { } 0 0 0
4378 0 else { 0; }
4379 }
4380 ################################################################################
4381  
4382 =head2 isBgnextn - return 0 or 1 depending on whether current record is a bgnextn
4383  
4384 =cut
4385  
4386 sub isBgnextn
4387 0 ▶{
Subroutine isBgnextn: not called CC=2 SCAR=17.9
Pod documented
4388 0 my $self = shift;
4389 0 ▶ if ($self -> {'RecordType'} == BGNEXTN) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 48) { } 0 0 0
4390 0 else { 0; }
4391 }
4392 ################################################################################
4393  
4394 =head2 isEndextn - return 0 or 1 depending on whether current record is a endextn
4395  
4396 =cut
4397  
4398 sub isEndextn
4399 0 ▶{
Subroutine isEndextn: not called CC=2 SCAR=17.9
Pod documented
4400 0 my $self = shift;
4401 0 ▶ if ($self -> {'RecordType'} == ENDEXTN) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 49) { } 0 0 0
4402 0 else { 0; }
4403 }
4404 ################################################################################
4405  
4406 =head2 isTapenum - return 0 or 1 depending on whether current record is a tapenum
4407  
4408 =cut
4409  
4410 sub isTapenum
4411 0 ▶{
Subroutine isTapenum: not called CC=2 SCAR=17.9
Pod documented
4412 0 my $self = shift;
4413 0 ▶ if ($self -> {'RecordType'} == TAPENUM) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 50) { } 0 0 0
4414 0 else { 0; }
4415 }
4416 ################################################################################
4417  
4418 =head2 isTapecode - return 0 or 1 depending on whether current record is a tapecode
4419  
4420 =cut
4421  
4422 sub isTapecode
4423 0 ▶{
Subroutine isTapecode: not called CC=2 SCAR=17.9
Pod documented
4424 0 my $self = shift;
4425 0 ▶ if ($self -> {'RecordType'} == TAPECODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 51) { } 0 0 0
4426 0 else { 0; }
4427 }
4428 ################################################################################
4429  
4430 =head2 isStrclass - return 0 or 1 depending on whether current record is a strclass
4431  
4432 =cut
4433  
4434 sub isStrclass
4435 0 ▶{
Subroutine isStrclass: not called CC=2 SCAR=17.9
Pod documented
4436 0 my $self = shift;
4437 0 ▶ if ($self -> {'RecordType'} == STRCLASS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 52) { } 0 0 0
4438 0 else { 0; }
4439 }
4440 ################################################################################
4441  
4442 =head2 isReserved - return 0 or 1 depending on whether current record is a reserved
4443  
4444 =cut
4445  
4446 sub isReserved
4447 0 ▶{
Subroutine isReserved: not called CC=2 SCAR=17.9
Pod documented
4448 0 my $self = shift;
4449 0 ▶ if ($self -> {'RecordType'} == RESERVED) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 53) { } 0 0 0
4450 0 else { 0; }
4451 }
4452 ################################################################################
4453  
4454 =head2 isFormat - return 0 or 1 depending on whether current record is a format
4455  
4456 =cut
4457  
4458 sub isFormat
4459 0 ▶{
Subroutine isFormat: not called CC=2 SCAR=17.9
Pod documented
4460 0 my $self = shift;
4461 0 ▶ if ($self -> {'RecordType'} == FORMAT) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 54) { } 0 0 0
4462 0 else { 0; }
4463 }
4464 ################################################################################
4465  
4466 =head2 isMask - return 0 or 1 depending on whether current record is a mask
4467  
4468 =cut
4469  
4470 sub isMask
4471 0 ▶{
Subroutine isMask: not called CC=2 SCAR=17.9
Pod documented
4472 0 my $self = shift;
4473 0 ▶ if ($self -> {'RecordType'} == MASK) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 55) { } 0 0 0
4474 0 else { 0; }
4475 }
4476 ################################################################################
4477  
4478 =head2 isEndmasks - return 0 or 1 depending on whether current record is a endmasks
4479  
4480 =cut
4481  
4482 sub isEndmasks
4483 0 ▶{
Subroutine isEndmasks: not called CC=2 SCAR=17.9
Pod documented
4484 0 my $self = shift;
4485 0 ▶ if ($self -> {'RecordType'} == ENDMASKS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 56) { } 0 0 0
4486 0 else { 0; }
4487 }
4488 ################################################################################
4489  
4490 =head2 isLibdirsize - return 0 or 1 depending on whether current record is a libdirsize
4491  
4492 =cut
4493  
4494 sub isLibdirsize
4495 0 ▶{
Subroutine isLibdirsize: not called CC=2 SCAR=17.9
Pod documented
4496 0 my $self = shift;
4497 0 ▶ if ($self -> {'RecordType'} == LIBDIRSIZE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 57) { } 0 0 0
4498 0 else { 0; }
4499 }
4500 ################################################################################
4501  
4502 =head2 isLibsecur - return 0 or 1 depending on whether current record is a libsecur
4503  
4504 =cut
4505  
4506 sub isLibsecur
4507 0 ▶{
Subroutine isLibsecur: not called CC=2 SCAR=17.9
Pod documented
4508 0 my $self = shift;
4509 0 ▶ if ($self -> {'RecordType'} == LIBSECUR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 59) { } 0 0 0
4510 0 else { 0; }
4511 }
4512 ################################################################################
4513  
4514 ################################################################################
4515 ## support functions
4516  
4517 sub getRecordData
4518 0 ▶{
Subroutine getRecordData: not called CC=6 SCAR=37.4
Pod undocumented
4519 0 my $self = shift;
4520 0 my $dt = $self -> {'DataType'};
4521 0 ▶ if ($dt == NO_REC_DATA)
Branch: 3 branches
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
elsif ($dt == 2 or $dt == 3 or $dt == 5) { } 0 0 0
elsif ($dt == 6) { } 0 0 0
4522 {
4523 0 return '';
4524 }
4525 ▶ elsif ($dt==INTEGER_2 || $dt==INTEGER_4 || $dt==REAL_8)
Condition0%0/6
$dt == 2 or $dt == 3 or $dt == 5
l!l&&r!l&&!r
000
$dt == 2 or $dt == 3
l!l&&r!l&&!r
000
MC/DC0%0/3
$dt == 2 or $dt == 3 or $dt == 5
$dt == 2 $dt == 3 $dt == 5
Truth table0%0/4
A or B or C
A= $dt == 2B= $dt == 3C= $dt == 5
ABCresult
1XX1
01X1
0011
0000
4526 {
4527 0 my $stuff = $self -> {'CurrentDataList'};
4528 0 $stuff =~ s|^,||;
4529 0 return(split(/,/,$stuff));
4530 }
4531 elsif ($dt == ACSII_STRING)
4532 {
4533 0 my $stuff = $self -> {'CurrentDataList'};
4534 0 $stuff =~ s|\0||g;
4535 0 return($stuff);
4536 }
4537 else ## bit_array
4538 {
4539 0 return ($self -> {'CurrentDataList'});
4540 }
4541 }
4542 ################################################################################
4543  
4544 sub readRecordTypeAndData
4545 0 ▶{
Subroutine readRecordTypeAndData: not called CC=1 SCAR=6.9
Pod undocumented
4546 0 my $self = shift;
4547 0 return ($RecordTypeStrings[$self -> {'RecordType'}],$self -> {'RecordData'});
4548 }
4549 ################################################################################
4550  
4551 sub skipGds2RecordData
4552 24 ▶{
Subroutine skipGds2RecordData: called CC=2 SCAR=7.0
Pod undocumented
4553 24 my $self = shift;
4554 24 ▶ $self -> readGds2RecordHeader() if ($self -> {'INHEADER'} != TRUE); ## safety - need to read HEADER if INHEADER == UNKNOWN or FALSE
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"INHEADER"} != 1 0 24 24
4555 24 $self -> {'INHEADER'} = FALSE;
4556 24 $self -> {'INDATA'} = TRUE; # in DATA - actually will be at the end of data by the time we test this...
4557 ## 4 should have been just read by readGds2RecordHeader
4558 24 seek($self -> {'FileHandle'},$self -> {'Length'} - 4,SEEK_CUR); ## seek seems to run a little faster than read
4559 24 $self -> {'DataIndex'} = UNKNOWN;
4560 24 return 1;
4561 }
4562 ################################################################################
4563  
4564 ### return number of XY coords if XY record
4565 sub returnNumCoords
4566 0 ▶{
Subroutine returnNumCoords: not called CC=2 SCAR=17.9
Pod undocumented
4567 0 my $self = shift;
4568 0 ▶ if ($self -> {'RecordType'} == XY) ## 4 byte signed integer
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 16) { } 0 0 0
4569 {
4570 0 int(($self -> {'Length'} - 4) / 8);
4571 }
4572 else
4573 {
4574 0 0;
4575 }
4576 }
4577 ################################################################################
4578  
4579 sub roundNum
4580 0 ▶{
Subroutine roundNum: not called CC=1 SCAR=6.9
Pod undocumented
4581 0 my $self = shift;
4582 0 my $num = shift;
4583 0 my $places = shift;
4584 0 sprintf("%.${places}f",$num);
4585 }
4586 ################################################################################
4587  
4588 sub scaleNum($$)
4589 0 ▶{
Subroutine scaleNum: not called CC=3 SCAR=24.8
Pod undocumented
4590 0 my $num=shift;
4591 0 my $scale=shift;
4592 0 ▶ die "1st number passed into scaleNum() must be an integer $!" if ($num !~ m|^-?\d+|);
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^-?\d+/ 0 0 0
4593 0 $num = $num * $scale;
4594 0 ▶ $num = int($num+0.5) if ($num =~ m|\.|);
Branch: 1 branch
BranchTrueFalseTotal
if $num =~ /\./ 0 0 0
4595 0 $num;
4596 }
4597 ################################################################################
4598  
4599 sub snapNum($$)
4600 0 ▶{
Subroutine snapNum: not called CC=5 SCAR=34.0
Pod undocumented
4601 0 my $num = shift;
4602 0 ▶ die "1st number passed into snapNum() must be an integer $!" if ($num !~ m|^-?\d+$|);
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^-?\d+$/ 0 0 0
4603 0 my $snap = shift;
4604 0 my $snapLength = length("$snap");
4605 0 my $lean=1; ##init
4606 0 ▶ $lean = -1 if($num < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 0 0 0 0
4607 ## snap to grid..
4608 0 my $littlePart=substr($num,-$snapLength,$snapLength);
4609 0 ▶ if($num<0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 0 0
4610 {
4611 0 $littlePart = -$littlePart;
4612 }
4613 0 $littlePart = int(($littlePart/$snap)+(0.5*$lean))*$snap;
4614 0 my $bigPart=substr($num,0,-$snapLength);
4615 0 ▶ if ($bigPart =~ m|^[-]?$|)
Branch: 1 branch
BranchTrueFalseTotal
if ($bigPart =~ /^[-]?$/) { } 0 0 0
4616 {
4617 0 $bigPart=0;
4618 }
4619 else
4620 {
4621 0 $bigPart *= 10**$snapLength;
4622 }
4623 0 $num = $bigPart + $littlePart;
4624 0 $num;
4625 }
4626 ################################################################################
4627  
4628 sub DESTROY
4629 8 ▶{
Subroutine DESTROY: called CC=1 SCAR=0.0
4630 8 my $self = shift;
4631 #warn "DESTROYing $self";
4632 }
4633 ################################################################################
4634  
4635 ################################################################################
4636 ## some vendor tools have trouble w/ negative angles and angles >= 360
4637 ## so we normalize to positive equivalent
4638 ################################################################################
4639 sub posAngle($)
4640 0 ▶{
Subroutine posAngle: not called CC=3 SCAR=24.8
Pod undocumented
4641 0 my $angle = shift;
4642 0 ▶ $angle += 360.0 while ($angle < 0.0);
Branch: 1 branch
BranchTrueFalseTotal
$angle < 0 and do { $angle += 360 } 0 0 0
4643 0 ▶ $angle -= 360.0 while ($angle >= 360.0);
Branch: 1 branch
BranchTrueFalseTotal
$angle >= 360 and do { $angle -= 360 } 0 0 0
4644 0 $angle = cleanFloatNum($angle);
4645 0 $angle;
4646 }
4647 ################################################################################
4648  
4649 =head2 recordSize - return current record size
4650  
4651 usage:
4652 my $len = $gds2File -> recordSize;
4653  
4654  
4655 =cut
4656  
4657 sub recordSize()
4658 0 ▶{
Subroutine recordSize: not called CC=1 SCAR=6.9
Pod documented
4659 0 my $self = shift;
4660 0 $self -> {'Length'};
4661 }
4662 ################################################################################
4663  
4664 =head2 dataSize - return current record size - 4 (length of data)
4665  
4666 usage:
4667 my $dataLen = $gds2File -> dataSize;
4668  
4669  
4670 =cut
4671  
4672 sub dataSize()
4673 0 ▶{
Subroutine dataSize: not called CC=1 SCAR=6.9
Pod documented
4674 0 my $self = shift;
4675 0 $self -> {'Length'} - 4;
4676 }
4677 ################################################################################
4678  
4679 =head2 returnUnitsAsArray - return user units and database units as a 2 element array
4680  
4681 usage:
4682 my ($uu,$dbu) = $gds2File -> returnUnitsAsArray;
4683  
4684  
4685 =cut
4686  
4687 sub returnUnitsAsArray
4688 0 ▶{
Subroutine returnUnitsAsArray: not called CC=2 SCAR=17.9
Pod documented
4689 0 my $self = shift;
4690 0 ▶ if ($self -> isUnits) { ($self -> {'UUnits'}, $self -> {'DBUnits'}); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isUnits) { } 0 0 0
4691 0 else { () }
4692 }
4693 ################################################################################
4694  
4695 #######
4696 sub subbyte() ## GDS2::version();
4697 0 ▶{
Subroutine subbyte: not called CC=1 SCAR=6.9
Pod undocumented
4698 0 my($what,$where,$howmuch) = @_;
4699 0 unpack("x$where C$howmuch", $what);
4700 }
4701 ################################################################################
4702  
4703 =head2 version - return GDS2 module version string
4704  
4705 =cut
4706  
4707 #######
4708 sub version() ## GDS2::version();
4709 0 ▶{
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
4710 0 return $GDS2::VERSION;
4711 }
4712 ################################################################################
4713  
4714 =head2 version - return GDS2 module revision string
4715  
4716 =cut
4717  
4718 #######
4719 sub revision() ## GDS2::revision();
4720 0 ▶{
Subroutine revision: not called CC=1 SCAR=6.9
Pod documented
4721 0 return $GDS2::revision;
4722 }
4723 ################################################################################
4724  
4725 sub getElmSpace
4726 150 ▶{
Subroutine getElmSpace: called CC=1 SCAR=0.0
Pod undocumented
4727 150 return $ElmSpace;
4728 }
4729 ################################################################################
4730  
4731 sub putElmSpace
4732 60 ▶{
Subroutine putElmSpace: called CC=1 SCAR=0.0
Pod undocumented
4733 60 $ElmSpace = shift;
4734 }
4735 ################################################################################
4736  
4737 sub getStrSpace
4738 164 ▶{
Subroutine getStrSpace: called CC=1 SCAR=0.0
Pod undocumented
4739 164 return $StrSpace;
4740 }
4741 ################################################################################
4742  
4743 sub putStrSpace
4744 18 ▶{
Subroutine putStrSpace: called CC=1 SCAR=0.0
Pod undocumented
4745 18 $StrSpace = shift;
4746 }
4747 ################################################################################
4748  
4749 6 1;
4750 }
4751  
4752 __END__
↑ Summary