| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | Quiq::Properties - Eigenschaften einer Menge von skalaren Werten | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | L<Quiq::Object> | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse ist Träger von Information über eine | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | Menge von skalaren Werten (Integer, Float, String). Die Information | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ist nützlich, wenn die Menge der Werte tabellarisch dargestellt werden | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | soll. | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =item type | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | Typ der Wertemenge: s (String), f (Float), d (Integer). | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =item width | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | Breite des breitesten Werts der Wertemenge. | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =item floatPrefix | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | Maximale Anzahl an Zeichen einer Fließkommazahl vor und einschließlich | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | dem Punkt. Dieses Attribut wird nur intern gebraucht, um die maximale | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | Breite einer Fließkommazahl zu bestimmen. | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | =item scale | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | Maximale Anzahl an Nachkommastellen im Falle einer Wertemenge | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | vom Typ f (Float). | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =item align | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Ausrichtung der Werte der Wertemenge: l (left), r (right). | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =item multiLine | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Boolscher Wert, der angibt, ob die Wertemenge wenigstens einen | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | mehrzeiligen Wert enthält. | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =head1 EXAMPLE | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | Erzeuge eine formatierte Liste von Float-Werten: | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | my @values = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 234.567, | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5.45, | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 92345.6, | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 42.56739, | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | my $prp = Quiq::Properties->new(\@values); | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | my $text; | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | for (@values) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $text .= $prp->format('text',$_)."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | print $text; | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 234.56700 | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5.45000 | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 92345.60000 | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 42.56739 | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | package Quiq::Properties; | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | ▶ | use base qw/Quiq::Object/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 18 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 18 | ▶ | use Quiq::String; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 Klassenmethoden | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $prp = $class->new(@opt); | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $prp = $class->new(\@values,@opt); | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | =item @arr | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | Array von skalaren Werten (Integers, Floats, String) | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =head4 Options | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =item -noTrailingZeros => $bool (Default: 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Entferne bei Floats nach dem Dezimalpunkt 0-en am Ende. | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | Objekt | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | Instantiiere ein Objekt der Klasse und liefere eine Referenz auf | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | dieses Objekt zurück. Ist als Parameter eine Referenz auf ein Array | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | angegeben, werden dessen Werte analysiert. | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 19 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 19 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | # @_: @opt -or- $valueA,@opt | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Argumente und Optionen | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 19 | my $noTrailingZeros = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 19 | my $argA = $class->parameters(0,1,\@_, | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | -noTrailingZeros => \$noTrailingZeros, | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 19 | ▶ | my $valueA = shift(@$argA) // []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @$argA // []
MC/DC100%1/1
shift @$argA // []
shift @$argA
Truth table100%2/2
A
A= shift @$argA
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # Instantiiere Objekt | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # 0 type | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # | 1 width | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # | | 2 floatPrefix | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # | | | 3 scale | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # | | | | 4 align | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # | | | | | 5 multiLine | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # | | | | | | 6 Option $noTrailingZeros | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # | | | | | | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 19 | my $self = bless ['d',0,0,0,'r',0,$noTrailingZeros],$class; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Analysiere Werte | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 19 | for (@$valueA) { | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 12 | $self->analyze($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 19 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | =head2 Akzessoren | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | =head3 align() - Setze/Liefere Ausrichtung der Werte | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $align = $prp->align; | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $align = $prp->align($align); | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Ausrichtung (Zeichen) | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | Setze/Liefere die Ausrichtung der Werte, falls sie tabellarisch | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | angezeigt werden sollen. | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | Eine Wertemenge vom Typ d oder f hat die Ausrichtung r. | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | Eine Wertemenge vom Typ s hat per Default die Ausrichtung l, | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | die aber auf r geändert werden werden kann. | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 12 | ▶ | sub align { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
align: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | # @_ $align | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 12 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->[4] = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 12 | ▶ | return $self->type eq 's'? ($self->[1] == 0? 'l': $self->[4]): 'r'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | =head3 multiLine() - Mehrzeilige Werte? | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $bool = $prp->multiLine; | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | Boolean | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Liefere wahr (1), wenn die Wertemenge mehrzeilige Werte enthält, | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | andernfalls falsch (0). Kann nur für eine Wertemenge vom Typ s | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | wahr sein. | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub multiLine { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
multiLine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return shift->[5]; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | =head3 scale() - Maximale Anzahl Nachkommastellen | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | $scale = $prp->scale; | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | Integer | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | Liefere die Maximale Anzahl an Nachkommastellen. Diese Information | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | hat nur im Falle des Typs f (Float) eine Bedeutung. | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 72 | ▶ | sub scale { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scale: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 72 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 72 | ▶ | return $self->type eq 'f'? $self->[3]: 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =head3 type() - Liefere/Setze Typ der Kolumne | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | $type = $prp->type; | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | $type = $prp->type($type); | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | Typbezeichner (Zeichen) | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | Liefere den Typ der Kolumne. | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | Eine Wertmenge hat den Typ d, wenn sie ausschließlich aus | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | Integern (und Leerstrings) besteht. | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | Eine Wertmenge hat den Typ f, wenn sie ausschließlich aus numerischen | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | Werten (und Leerstrings) besteht und wenigstens ein numerischer | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | Wert einen Dezimalpunkt enthält, also Nachkommastellen besitzt. | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | Eine Wertmenge hat den Typ s, wenn sie leer ist, nur aus Leerstrings | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | besteht oder wenigsténs einen nichtnumerischen Wert enthält. | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 223 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 223 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | # @_: $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 223 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->[0] = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 223 | ▶ | return $self->[1] == 0? 's': $self->[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | =head3 width() - Länge des längsten Werts | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | $width = $prp->width; | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $width = $prp->width($width); | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =head4 Returns | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | Integer | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | Liefere oder setzte die Länge des längsten Werts. | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Die Breite einer Wertemenge des Typs d ist die Länge des | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | längsten Werts. | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | Die Breite einer Wertemenge des Typs s ist die Länge der | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | längsten Zeile eines Werts. | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | Die Breite einer Wertemenge des Typs f ist die | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | Summe aus der maximalen Anzahl an Nachkommastellen plus der | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | maximalen Anzahl an Zeichen vor und einschließlich des Kommas. | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 74 | ▶ | sub width { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
width: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 74 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | # @_: $width; | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 74 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2 | my $width = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | ▶ | if ($self->type eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->[2] = $width-$self->scale; | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | $self->[1] = $width; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 74 | ▶ | if ($self->type eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 36 | return $self->[2]+$self->scale; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 38 | return $self->[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | =head2 Objektmethoden | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | =head3 analyze() - Füge Wert zur Analysemenge hinzu | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | $prp->analyze($value); | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | =item $value | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | Skalarer Wert (Integer, Float, String) | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | Analysiere Wert $value hinsichtlich seiner Eigenschaften und passe | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | die Eigenschaften der Menge entsprechend an. Ein leerer Wert (undef oder | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | Leerstring) ändert die Eigenschaften nicht. | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 63 | ▶ | sub analyze { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
analyze: called CC=15 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 63 | my ($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 63 | ▶ | if (!defined($val) || $val eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $val or $val eq ""
MC/DC50%1/2
not defined $val or $val eq ""
not defined $val
$val eq ""
Truth table66%2/3
not(A) or B
A= not defined $valB= $val eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Ein leerer Wert beeinflusst die Eigenschaften nicht | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # Bisherige Information holen | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 62 | my ($type,$width,$floatPrefix,$scale,$align,$multiLine,$opt) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # Typ behandeln | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 62 | ▶ | if ($type ne 's') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 53 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | 68 | ▶ | if ($type eq 'd' && $val !~ /^[+-]?\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$type eq "d" and not $val =~ /^[+-]?\d+$/
MC/DC100%2/2
$type eq "d" and not $val =~ /^[+-]?\d+$/
$type eq "d"
not $val =~ /^[+-]?\d+$/
Truth table100%3/3
A and not(B)
A= $type eq "d"B= not $val =~ /^[+-]?\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 15 | $type = 'f'; | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | 15 | $floatPrefix = $width+1; # +1 wg. Dezimalpunkt | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 15 | redo; | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | elsif ($type eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # MEMO: Die Ziffer vor dem Dezimalpunkt kann fehlen (Oracle) | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 38 | ▶ | if ($val !~ /^[+-]?(\d*\.(\d+)$|\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 6 | $type = 's'; | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | 6 | $align = 'l'; | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | 6 | $floatPrefix = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | 6 | $scale = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # Maximale Anzahl Nachkommastellen | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 32 | ▶ | my $n = defined($2)? length $2: 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 32 | ▶ | if ($n > $scale) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 16 | $scale = $n; | |||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # Anzahl Zeichen vor den Nachkommastellen, | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # einschließlich Punkt und Vorzeichen. | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # Korrektur für Oracle-Zahlen zw. 1 und -1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # und Integer, die zwischen Float auftauchen. | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # .N oder -.N (Oracle-Fix) | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 32 | my $m = length($val)-$n; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | 32 | ▶ | if ($1 eq '' || $n == 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$1 eq "" or $n == 0
MC/DC50%1/2
$1 eq "" or $n == 0
$1 eq ""
$n == 0
Truth table66%2/3
A or B
A= $1 eq ""B= $n == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | $m++; | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 32 | ▶ | if ($m > $floatPrefix) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 18 | $floatPrefix = $m; | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 53 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # Width/MultiLine ermitteln | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 62 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | 62 | ▶ | if ($val =~ tr/\n//) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $l = Quiq::String->maxLineLength($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $multiLine = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 62 | $l = length $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 62 | ▶ | if ($l > $width) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 39 | $width = $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # Neue Information setzen | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 62 | @$self = ($type,$width,$floatPrefix,$scale,$align,$multiLine,$opt); | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 62 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | =head3 format() - Formatiere Wert | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | $str = $prp->format($format,$val); | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | =item $format | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | Formatierung, die auf den Wert angewendet wird. | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | Mögliche Werte: 'text', 'html'. | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | =item $val | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | Skalarer Wert (Integer, Float, String) aus der Wertemenge. | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | =head4 Description | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | Formatiere Wert $val gemäß Format $format und liefere das Resultat zurück. | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 54 | ▶ | sub format { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format: called CC=20 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 54 | my ($self,$format,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 54 | my $type = $self->type; | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | 54 | my $width = $self->width; | |||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 54 | ▶ | if ($format eq 'text') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 47 | ▶ | if (!defined($val) || $val eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $val or $val eq ""
MC/DC0%0/2
not defined $val or $val eq ""
not defined $val
$val eq ""
Truth table33%1/3
not(A) or B
A= not defined $valB= $val eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $val = ' ' x abs($width); | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 47 | ▶ | if (($type eq 'd' || $type eq 'f') && $val =~ /[^-+\d.]/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$type eq "d" || $type eq "f" and $val =~ /[^-+\d.]/
$type eq "d" or $type eq "f"
MC/DC0%0/3
$type eq "d" || $type eq "f" and $val =~ /[^-+\d.]/
$type eq "d"
$type eq "f"
$val =~ /[^-+\d.]/
Truth table60%3/5
A or B and C
A= $type eq "d"B= $type eq "f"C= $val =~ /[^-+\d.]/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # Einen nicht-numerischen Wert in einer numerischen Kolumne | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # (z.B. Überschrift) formatieren wir als String | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $type = 's'; | |||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 47 | ▶ | if ($type eq 's') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 13 | ▶ | $val = sprintf '%*s',$self->[4] eq 'l'? -$width: $width,$val; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | elsif ($type eq 'd') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # %d funktioniert bei großen Zahlen mit z.B. 24 Stellen nicht. | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # Es wird dann fälschlicherweise -1 als Wert angezeigt. | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # $val = sprintf '%*d',$width,$val; | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 13 | $val = sprintf '%*s',$width,$val; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | elsif ($type eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 21 | $val = sprintf '%*.*f',$width,$self->scale,$val; | |||||||||||||||||||||||||||||||||||||||||||||
| 555 | 21 | ▶ | if ($self->[6]) { # noTrailingZeros | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 4 | ▶ | if ($val =~ s/(0+)$/' ' x length($1)/e) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 3 | $val =~ s/\.$/ /; | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||||||
| 563 | 'PROP-00099: Unknown type', | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | Type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | elsif ($format eq 'html') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 7 | ▶ | if (!defined($val) || $val eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
not defined $val or $val eq ""
MC/DC0%0/2
not defined $val or $val eq ""
not defined $val
$val eq ""
Truth table33%1/3
not(A) or B
A= not defined $valB= $val eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $val = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | elsif ($type eq 'f') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 6 | $val = sprintf '%*.*f',$width,$self->scale,$val; | |||||||||||||||||||||||||||||||||||||||||||||
| 575 | 6 | $val =~ s/^ +//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 6 | ▶ | if ($self->[6]) { # noTrailingZeros | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 4 | ▶ | if ($val =~ s/(0+)$/' ' x length($1)/e) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3 | $val =~ s/\.$/ /; | |||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | elsif ($type eq 's') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | $val =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | $val =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | $val =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | 'PROP-00099: Unknown format', | ||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Format => $format, | ||||||||||||||||||||||||||||||||||||||||||||||
| 592 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 54 | return $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | =head3 set() - Setze Eigenschaften explizit | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||
| 602 | =head4 Synopsis | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | $prp->set($type,$align); | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | =head4 Arguments | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | =item $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||
| 612 | Typ der Wertemenge: s (Text) | ||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||
| 614 | =item $align | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | Ausrichtung der Werte der Wertemenge: l (left), r (right). | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my ($self,$type,$align) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | if (defined $type) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | $self->type($type); | |||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | if (defined $align) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $self->align($align); | |||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1.240 | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||
| 643 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||
| 651 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||
| 656 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # eof | ||||||||||||||||||||||||||||||||||||||||||||||