| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::StreamServe::Block - Inhalt eines StreamServe Blocks | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse repräsentiert den Inhalt eines StreamServe-Blocks, | ||||||||||||||||||||||||||||
| 16 | also eine Menge von Schlüssel/Wert-Paaren eines Typs (der durch den | ||||||||||||||||||||||||||||
| 17 | gemeinsamen Namenspräfix gegeben ist). | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | package Quiq::StreamServe::Block; | ||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use Quiq::Hash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head1 METHODS | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head2 Klassenmethoden | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head3 new() - Instantiiere Objekt | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | $ssb = $class->new($prefix); | ||||||||||||||||||||||||||||
| 45 | $ssb = $class->new($prefix,$h); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head4 Arguments | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =over 4 | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =item $prefix | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Block-Präfix | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =item $h (Default: {}) | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Hash mit den Schlüssel/Wert-Paaren des Blocks | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =back | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head4 Returns | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Objekt | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head4 Description | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Instantiiere ein Objekt der Klasse und liefere dieses zurück. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 11 | my ($class,$prefix) = splice @_,0,2; | |||||||||||||||||||||||||||
| 75 | 11 | ▶ | my $h = shift // {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 11 | return $class->SUPER::new( | |||||||||||||||||||||||||||
| 78 | prefix => $prefix, | ||||||||||||||||||||||||||||
| 79 | hash => Quiq::Hash->new($h), | ||||||||||||||||||||||||||||
| 80 | read => {}, # Gelesene Elemente | ||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 Objektmethoden | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head3 add() - Setze Schlüssel/Wert-Paar ohne Exception | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | $ssb->add($key,$val); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head4 Description | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Ist der Schlüssel vorhanden, wird sein Wert gesetzt. Ist er nicht | ||||||||||||||||||||||||||||
| 97 | vorhanden wird er mit dem angegebenen Wert hinzugefügt. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 221 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 221 | my ($self,$key,$val) = @_; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 221 | $self->hash->add($key,$val); | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 221 | return; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head3 concat() - Konkateniere Attributwerte | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | $val = $ssb->concat($sep,@keys); | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head4 Description | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Konkateniere die Werte der Attribute @keys mit Trennzeichen $sep zu | ||||||||||||||||||||||||||||
| 122 | einem Wert und liefere diesen zurück. Leere Werte werden übergangen. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub concat { | ||||||||||||||||||||||||||
|
Subroutine
concat: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 0 | my $sep = shift; | |||||||||||||||||||||||||||
| 131 | # @_: @keys | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my $val; | |||||||||||||||||||||||||||
| 134 | 0 | for my $key (@_) { | |||||||||||||||||||||||||||
| 135 | 0 | my $str = $self->get($key); | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($str && $str ne '00.00.00') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$str and $str ne "00.00.00"
MC/DC0%0/2
$str and $str ne "00.00.00"
$str
$str ne "00.00.00"
Truth table0%0/3
A and B
A= $strB= $str ne "00.00.00"
| |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ($val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | $val .= $sep; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 0 | $val .= $str; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | return $val; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =head3 content() - Inhalt des Blocks | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | $text = $ssb->content; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head4 Description | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | Liefere den Inhalt des Blocks als Text. Die Schlüssel sind alphanumerisch | ||||||||||||||||||||||||||||
| 158 | sortiert. | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =cut | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub content { | ||||||||||||||||||||||||||
|
Subroutine
content: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | my $h = $self->hash; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | my $text = ''; | |||||||||||||||||||||||||||
| 170 | 0 | for my $key (sort $h->keys) { | |||||||||||||||||||||||||||
| 171 | 0 | $text .= sprintf "%9s %s\n",$key,$h->{$key}; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | return $text; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head3 set() - Setze Schlüssel/Wert-Paar | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | $ssb->set($key,$val); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub set { | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 0 | my ($self,$key,$val) = @_; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | $self->hash->set($key,$val); | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | return; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head3 get() - Liefere Wert eines Schlüssels | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | $val = $ssb->get($key); | ||||||||||||||||||||||||||||
| 204 | $val = $ssb->get($key,$sloppy); | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =head4 Arguments | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =over 4 | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =item $key | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | Schlüssel | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =back | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head4 Options | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =over 4 | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =item $sloppy (Default: 0) | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | Wirf bei Nichtexistenz von $key keine Exception, sondern liefere C<undef>. | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =back | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 2 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=3 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||
| 231 | 2 | my ($self,$key,$sloppy) = @_; | |||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 2 | $self->read->{$key} = 1; # Element wurde gelesen | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 2 | ▶ | if ($sloppy) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | local $@; | |||||||||||||||||||||||||||
| 237 | 0 | eval {$self->hash->get($key)}; | |||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 0 | return undef; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 2 | return $self->hash->get($key); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | =head3 getFirst() - Liefere ersten Attributwert | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | $val = $ssb->getFirst(@keys); | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head4 Description | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | Liefere den ersten nichtleeren Wert der Attribute @keys. Attribute, die | ||||||||||||||||||||||||||||
| 257 | nicht existieren, werden übergangen. | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | =cut | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub getFirst { | ||||||||||||||||||||||||||
|
Subroutine
getFirst: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 265 | # @_: @keys | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | for my $key (@_) { | |||||||||||||||||||||||||||
| 268 | 0 | my $val = $self->get($key,1); | |||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (defined($val) && $val ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $val and $val ne ""
MC/DC0%0/2
defined $val and $val ne ""
defined $val
$val ne ""
Truth table0%0/3
A and B
A= defined $valB= $val ne ""
| |||||||||||||||||||||||||||||
| 270 | 0 | return $val; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | return undef; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =head3 prefix() - Liefere Präfix | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | $prefix = $ssb->prefix; | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =cut | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | # Attributmethode | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =head1 VERSION | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 1.240 | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 308 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 2 | 1; | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | # eof | ||||||||||||||||||||||||||||