| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::StreamServe::Stream - Inhalt einer StreamServe Stream-Datei | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse repräsentiert den Inhalt einer StreamServe | ||||||||||||||||||||||||||||
| 16 | Stream-Datei: | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =over 2 | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =item * | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | Feldwerte können abgfragt werden | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =item * | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | Über den Blöcken kann iteriert werden | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =back | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | package Quiq::StreamServe::Stream; | ||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | our $VERSION = '1.238'; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use Quiq::StreamServe::Block; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | use Quiq::FileHandle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | use Quiq::Hash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 1 | ▶ | use Quiq::AnsiColor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 METHODS | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 Klassenmethoden | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head3 new() - Instantiiere Objekt | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | $ssf = $class->new($file,%options); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head4 Arguments | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =over 4 | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =item $file | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Pfad der Streamdatei. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =back | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head4 Options | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =over 4 | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =item -debug => $bool (Default: 0) | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Gib den Inhalt des Streams auf STDOUT aus (Blöcke in Lesereihenfolge, | ||||||||||||||||||||||||||||
| 77 | Felder alphanumerisch sortiert). | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item -ignore => \@vals (Default: []) | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Feldwerte, die auf einen Leerstring reduziert werden. Beispiel: | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | -ignore => ['.','*','-'] | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =back | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head4 Returns | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Objekt | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head4 Description | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Instantiiere ein Objekt der Klasse und liefere dieses zurück. | ||||||||||||||||||||||||||||
| 94 | Enthält die Streamdatei mehr als einen Stream, wird eine Exception | ||||||||||||||||||||||||||||
| 95 | geworfen. | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub new { | ||||||||||||||||||||||||||||
| 102 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.2
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | # @_: $file,%options | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | my $debug = 0; | |||||||||||||||||||||||||||
| 108 | 1 | my $ignoreA = []; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 1 | my $argA = $class->parameters(1,1,\@_, | |||||||||||||||||||||||||||
| 111 | -debug => \$debug, | ||||||||||||||||||||||||||||
| 112 | -ignore => \$ignoreA, | ||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||
| 114 | 1 | my $file = shift @$argA; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | # Datenstrukturen mit erstem (zunächst leeren) Block | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | my $n = 0; | |||||||||||||||||||||||||||
| 119 | 1 | my $type; | |||||||||||||||||||||||||||
| 120 | 1 | my $prefix = '*'; | |||||||||||||||||||||||||||
| 121 | 1 | my $blk = Quiq::StreamServe::Block->new($prefix); | |||||||||||||||||||||||||||
| 122 | 1 | my @blocks = ($blk); | |||||||||||||||||||||||||||
| 123 | 1 | my %section; | |||||||||||||||||||||||||||
| 124 | 1 | my $secBlkA = $section{$prefix} = [$blk]; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # StreamServe-Datei lesen | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 1 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 129 | 1 | $fh->setEncoding('UTF-8'); | |||||||||||||||||||||||||||
| 130 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 238 | chomp; | |||||||||||||||||||||||||||
| 132 | 238 | ▶ | if ($_ eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | # Wir übergehen Leerzeilen | ||||||||||||||||||||||||||||
| 134 | 8 | next; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 230 | my ($key,$val) = split /\t/,$_,2; | |||||||||||||||||||||||||||
| 137 | 230 | ▶ | if (!defined $val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | # Wir übergehen Zeilen ohne Wert. Es sollte nur eine geben: | ||||||||||||||||||||||||||||
| 139 | # BEGIN<NAME> | ||||||||||||||||||||||||||||
| 140 | 1 | ($type) = $key =~ /BEGIN(.*)/; | |||||||||||||||||||||||||||
| 141 | 1 | ▶ | if (++$n > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $class->throw( | |||||||||||||||||||||||||||
| 143 | 'STREAM-00099: Streamfile contains more than one stream', | ||||||||||||||||||||||||||||
| 144 | StreamFile => $file, | ||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 1 | next; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 229 | $val =~ s/^\s+|\s+$//; # Wert von umgebendem Whitespace befreien | |||||||||||||||||||||||||||
| 150 | 229 | for my $ign (@$ignoreA) { # unerwünschte Werte wegfiltern | |||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($val eq $ign) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | $val = ''; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 229 | ▶ | if (/^(..)INDCTR/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | # Nächsten (zunächst leeren) Block hinzufügen | ||||||||||||||||||||||||||||
| 157 | 9 | $prefix = $1; | |||||||||||||||||||||||||||
| 158 | 9 | $blk = Quiq::StreamServe::Block->new($prefix); | |||||||||||||||||||||||||||
| 159 | 9 | push @blocks,$blk; | |||||||||||||||||||||||||||
| 160 | 9 | ▶ | $secBlkA = $section{$prefix} //= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$section{$prefix} //= []
MC/DC0%0/1
$section{$prefix} //= []
$section{$prefix}
Truth table50%1/2
A
A= $section{$prefix}
| |||||||||||||||||||||||||||||
| 161 | 9 | push @$secBlkA,$blk; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 220 | $blk->add($key=>$val); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | 1 | $fh->close; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1 | return $class->SUPER::new( | |||||||||||||||||||||||||||
| 170 | file => $file, | ||||||||||||||||||||||||||||
| 171 | type => $type, | ||||||||||||||||||||||||||||
| 172 | blockA => \@blocks, | ||||||||||||||||||||||||||||
| 173 | sectionH => Quiq::Hash->new(\%section), | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head3 lookup() - Suche Feld | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | $val = $class->lookup($file,$name); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =head4 Arguments | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | =over 4 | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =item $file | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | Stream-Datei | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =item $name | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | Name des gesuchten Feldes | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =back | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head4 Returns | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | (String) Wert oder C<undef> | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | =head4 Description | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | Durchsuche den Stream $file nach dem ersten Vorkommen des Feldes $name | ||||||||||||||||||||||||||||
| 206 | und liefere dessen Wert zurück. Kommt das Feld im Stream nicht vor, | ||||||||||||||||||||||||||||
| 207 | liefere C<undef>. | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =cut | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | sub lookup { | ||||||||||||||||||||||||||||
| 214 | 0 | ▶ | my ($class,$file,$name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
lookup: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | my $val = undef; | |||||||||||||||||||||||||||
| 217 | 0 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 218 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | chomp; | |||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ($_ eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | # Wir übergehen Leerzeilen | ||||||||||||||||||||||||||||
| 222 | 0 | next; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | 0 | my ($key,$str) = split /\t/,$_,2; | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($key eq $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | $val = $str; | |||||||||||||||||||||||||||
| 227 | 0 | last; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | return $val; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head3 lookupHeader() - Suche Feld im Header | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | $val = $class->lookupHeader($file,$name); | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =head4 Arguments | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | =over 4 | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =item $file | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | Stream-Datei | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | =item $name | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | Name des gesuchten Feldes | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | =back | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =head4 Returns | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | (String) Wert oder C<undef> | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | =head4 Description | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | Durchsuche den Header des Streams $file nach dem ersten Vorkommen des | ||||||||||||||||||||||||||||
| 264 | Feldes $name und liefere dessen Wert zurück. Kommt das Feld im Stream | ||||||||||||||||||||||||||||
| 265 | nicht vor, liefere C<undef>. Die Felder des Headers beginnen mit einem | ||||||||||||||||||||||||||||
| 266 | Stern (C<*>). Gegenüber Metjode lookup() ist die Methode lookupHeader() | ||||||||||||||||||||||||||||
| 267 | effizienter, da sie nach Lesen der Headerfelder stoppt. | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =cut | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | sub lookupHeader { | ||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my ($class,$file,$name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
lookupHeader: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | my $val = undef; | |||||||||||||||||||||||||||
| 277 | 0 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 278 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | chomp; | |||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ($_ eq '' || $_ =~ /^BEGIN/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq "" or $_ =~ /^BEGIN/
MC/DC0%0/2
$_ eq "" or $_ =~ /^BEGIN/
$_ eq ""
$_ =~ /^BEGIN/
Truth table0%0/3
A or B
A= $_ eq ""B= $_ =~ /^BEGIN/
| |||||||||||||||||||||||||||||
| 281 | # Wir übergehen Leerzeilen und die BEGIN-Zeile | ||||||||||||||||||||||||||||
| 282 | 0 | next; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | 0 | my ($key,$str) = split /\t/,$_,2; | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | if (substr($key,0,1) ne '*') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | # Stoppe nach Lesen des Headers | ||||||||||||||||||||||||||||
| 287 | 0 | last; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ($key eq $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 0 | $val = $str; | |||||||||||||||||||||||||||
| 291 | 0 | last; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | return $val; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head3 numberOfStreams() - Anzahl der (Einzel-)Streams | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | $n = $class->numberOfStreams($file); | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =head4 Arguments | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =over 4 | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | =item $file | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | Stream-Datei | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | =back | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | =head4 Returns | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | (Integer) Anzahl der Einzelstreams | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =head4 Description | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | Ermittele die Anzahl der Einzelstreams und liefere diese zurück. | ||||||||||||||||||||||||||||
| 324 | Ax-Streams zählen wir nicht mit. | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =cut | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | sub numberOfStreams { | ||||||||||||||||||||||||||||
| 331 | 0 | ▶ | my ($class,$file) = @_; | ||||||||||||||||||||||||||
|
Subroutine
numberOfStreams: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | my $n = 0; | |||||||||||||||||||||||||||
| 334 | 0 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 335 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if (/^BEGIN/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (!/A\d$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 338 | 0 | $n++; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 0 | return $n; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =head3 split() - Zerlege (Multi-)Stream in Einzelstreams | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | @arr | $arrA = $class->split($file); | ||||||||||||||||||||||||||||
| 354 | @arr | $arrA = $class->split(\$data); | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =head4 Arguments | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =over 4 | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | =item $file | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | Stream-Datei | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | =item $data | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | Stream-Daten | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =back | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | =head4 Returns | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | (Array of Strings) Liste der Einzelstreams | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =head4 Description | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | Zerlege einen (Multi-)Stream (aus Datei oder In-Memory-Daten) | ||||||||||||||||||||||||||||
| 377 | in Einzelstreams und liefere die Liste der Einzelstreams zurück. | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | Ax-Streams ignorieren wir. D.h. die gelieferte Liste ist leer, wenn der | ||||||||||||||||||||||||||||
| 380 | Stream lediglich einen A0- oder A1-Stream enthält. | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =cut | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | sub split { | ||||||||||||||||||||||||||||
| 387 | 0 | ▶ | my ($class,$file) = @_; | ||||||||||||||||||||||||||
|
Subroutine
split: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | my @arr; | |||||||||||||||||||||||||||
| 390 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 391 | 0 | my $skip = 0; | |||||||||||||||||||||||||||
| 392 | 0 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 393 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if (/^BEGIN/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if (/A\d$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | $skip = 1; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | else { | ||||||||||||||||||||||||||||
| 399 | 0 | $skip = 0; | |||||||||||||||||||||||||||
| 400 | 0 | $i++; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($skip) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | 0 | next; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | 0 | $arr[$i] .= $_; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 0 | $i = 0; | |||||||||||||||||||||||||||
| 411 | 0 | my $header = shift @arr; | |||||||||||||||||||||||||||
| 412 | 0 | for my $body (@arr) { | |||||||||||||||||||||||||||
| 413 | 0 | $arr[$i++] = $header.$body; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return wantarray? @arr: \@arr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =head2 Objektmethoden | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | =head3 allBlocks() - Liste aller Blöcke | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | @arr | $arrH = $ssf->allBlocks; | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =head4 Returns | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | (Array of Hashes) Liste von Blöcken | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =head4 Description | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | Liefere die Liste aller Blöcke des Streams. | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | =cut | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | sub allBlocks { | ||||||||||||||||||||||||||||
| 442 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
allBlocks: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 1 | my $arr = $self->blockA; | |||||||||||||||||||||||||||
| 445 | 1 | ▶ | return wantarray? @$arr: $arr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =head3 blocks() - Liste der Blöcke einer Blockart | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | @arr | $arrH = $ssf->blocks($prefix); | ||||||||||||||||||||||||||||
| 455 | @arr | $arrH = $ssf->blocks($prefix,$sloppy); | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =head4 Arguments | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =over 4 | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =item $prefix | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Die Blockart | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | =back | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | =head4 Options | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | =over 4 | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =item $sloppy | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | Wenn gesetzt, wirf keine Exception, wenn die Blockart nicht existiert, | ||||||||||||||||||||||||||||
| 474 | sondern liefere eine leere Liste. | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | =back | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | =head4 Returns | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | (Array of Hashes) Liste von Blöcken | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | =head4 Description | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | Liefere die Liste der Blöcke einer Blockarten. Eine Blockart ist durch | ||||||||||||||||||||||||||||
| 485 | ihren Präfix charakterisiert. | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =cut | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | sub blocks { | ||||||||||||||||||||||||||||
| 492 | 2 | ▶ | my ($self,$prefix,$sloppy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
blocks: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 2 | my $arrA = eval {$self->sectionH->get($prefix)}; | |||||||||||||||||||||||||||
| 495 | 2 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 1 | ▶ | if ($sloppy) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | 0 | $arrA = []; | |||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | else { | ||||||||||||||||||||||||||||
| 500 | 1 | $self->throw( | |||||||||||||||||||||||||||
| 501 | 'STREAMSERVE-00099: Block does not exist', | ||||||||||||||||||||||||||||
| 502 | Prefix => $prefix, | ||||||||||||||||||||||||||||
| 503 | ); | ||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | 1 | ▶ | return wantarray? @$arrA: $arrA; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | =head3 file() - Pfad der Streamdatei (Accessor-Methode) | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | $path = $ssf->file; | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | =head4 Returns | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | (String) Pfad der Streamdatei | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | =head4 Description | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | Liefere den Pfad der Streamdatei. | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | =cut | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | # Accessor-Methode | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =head3 get() - Liefere Wert | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | $val = $ssf->get($name,$i); | ||||||||||||||||||||||||||||
| 538 | $val = $ssf->get($name); | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | =head4 Arguments | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | =over 4 | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =item $name | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | Name des abzufragenden Feldes | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | =item $i (Default: 0) | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | Index im Falle mehrfachen Vorkommens des Feldes | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | =back | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =head4 Returns | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | (String) Wert | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | sub get { | ||||||||||||||||||||||||||||
| 563 | 1 | ▶ | my ($self,$name) = splice @_,0,2; | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||
| 564 | 1 | ▶ | my $i = shift // 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 1 | ▶ | my $prefix = substr($name,0,1) eq '*'? '*': substr($name,0,2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 567 | 1 | return $self->sectionH->get($prefix)->[$i]->get($name); | |||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | =head3 set() - Setze Wert | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | $ssf->set($name,$val,$i); | ||||||||||||||||||||||||||||
| 577 | $ssf->set($name,$val); | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =head4 Arguments | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | =over 4 | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | =item $name | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | Name des zu setzenden Feldes | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =item $val | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | Wert, der gesetzt werden soll | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | =item $i (Default: 0) | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | Index im Falle mehrfachen Vorkommens des Feldes | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | =back | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | =cut | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | sub set { | ||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my ($self,$name,$val) = splice @_,0,3; | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 603 | 0 | ▶ | my $i = shift // 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | 0 | ▶ | my $prefix = substr($name,0,1) eq '*'? '*': substr($name,0,2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 606 | 0 | return $self->sectionH->get($prefix)->[$i]->set($name,$val); | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | =head3 prefixes() - Liste der Blockarten (Präfixe) | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | @arr | $arrH = $ssf->prefixes; | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | =head4 Returns | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | (Array of Strings) Liste der Block-Präfixe | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | =head4 Description | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | Liefere die Liste der Blockarten. Eine Blockart ist durch die Liste | ||||||||||||||||||||||||||||
| 624 | der gemeinsamen Feldpräfixe charakterisiert. | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | =cut | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | sub prefixes { | ||||||||||||||||||||||||||||
| 631 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
prefixes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | 1 | my @arr = sort keys %{$self->sectionH}; | |||||||||||||||||||||||||||
| 634 | 1 | ▶ | return wantarray? @arr: \@arr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | =head3 report() - Liefere Bericht über den Stream | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | $text = $ssf->report; | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | =head4 Returns | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | (String) Text des Berichts | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | =head4 Description | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | Erzeuge einen Bericht über den Stream und liefere dessen Text zurück. | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | =cut | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | sub report { | ||||||||||||||||||||||||||||
| 658 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
report: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 0 | my $a = Quiq::AnsiColor->new(1); | |||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | 0 | my $text = sprintf "---%s---\n",$a->str('bold red','Stream Report'); | |||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 0 | for my $blk ($self->allBlocks) { | |||||||||||||||||||||||||||
| 665 | 0 | $text .= $blk->prefix."\n"; | |||||||||||||||||||||||||||
| 666 | 0 | my $h = $blk->hash; | |||||||||||||||||||||||||||
| 667 | 0 | my $r = $blk->read; | |||||||||||||||||||||||||||
| 668 | 0 | for my $key (sort $blk->hash->keys) { | |||||||||||||||||||||||||||
| 669 | # $text .= " $key\n"; | ||||||||||||||||||||||||||||
| 670 | 0 | my $val = $h->{$key}; | |||||||||||||||||||||||||||
| 671 | $text .= sprintf " %s = %s\n",$key, | ||||||||||||||||||||||||||||
| 672 | 0 | ▶ | $r->{$key}? $a->str('green',$val): $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | 0 | return $text; | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | =head3 try() - Liefere Wert | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | $val = $ssf->try($name,$i); | ||||||||||||||||||||||||||||
| 686 | $val = $ssf->try($name); | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | =head4 Arguments | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | =over 4 | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | =item $name | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | Name des abzufragenden Feldes | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | =item $i (Default: 0) | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | Index im Falle mehrfachen Vorkommens des Feldes | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | =back | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | =head4 Returns | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | (String) Wert | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | =head4 Description | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | Wie get(), nur dass der Zugriff auf ein nicht-existentes Feld nicht | ||||||||||||||||||||||||||||
| 709 | zu einer Exception führt, sondern C<undef> liefert. | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | =cut | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||
| 715 | sub try { | ||||||||||||||||||||||||||||
| 716 | 0 | ▶ | my ($self,$name) = splice @_,0,2; | ||||||||||||||||||||||||||
|
Subroutine
try: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 717 | 0 | ▶ | my $i = shift // 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() // 0
MC/DC0%0/1
shift() // 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | 0 | ▶ | my $prefix = substr($name,0,1) eq '*'? '*': substr($name,0,2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 720 | 0 | my $val = eval {$self->{'sectionH'}->{$prefix}->[$i]->get($name)}; | |||||||||||||||||||||||||||
| 721 | 0 | return $val; | |||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||
| 726 | =head3 type() - Typ des Streams | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | $type = $ssf->type; | ||||||||||||||||||||||||||||
| 731 | $type = $class->type($file); | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | =head4 Arguments | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | =over 4 | ||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | =item $file | ||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | Stream-Datei | ||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | =back | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | =head4 Returns | ||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||
| 745 | (String) Typ des Stream, z.B. C<SOS1890H> | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | =head4 Description | ||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | Liefere den Typ der Streamdatei $ssf bzw. $file. Als Klassenmethode | ||||||||||||||||||||||||||||
| 750 | gerufen, wird der Typ effizient ermittelt, ohne den ganzen Stream | ||||||||||||||||||||||||||||
| 751 | einzulesen. | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | =cut | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | sub type { | ||||||||||||||||||||||||||||
| 758 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | # Typ aus dem Objekt liefern | ||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||
| 762 | 0 | ▶ | if (ref $this) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 763 | 0 | return $this->{'type'}; | |||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||
| 766 | # StreamServe-Datei lesen | ||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||
| 768 | 0 | my $file = shift; | |||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | 0 | my $type; | |||||||||||||||||||||||||||
| 771 | 0 | my $fh = Quiq::FileHandle->new('<',$file); | |||||||||||||||||||||||||||
| 772 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 773 | 0 | ▶ | if (/^BEGIN(.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 774 | 0 | $type = $1; | |||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||
| 777 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | 0 | return $type; | |||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||
| 782 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||
| 784 | =head1 VERSION | ||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||
| 786 | 1.238 | ||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||
| 792 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||
| 794 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||
| 796 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 799 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | =cut | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | 1 | 1; | |||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | # eof | ||||||||||||||||||||||||||||