| 1 | # ----------------------------------------------------------------------------- | ||||||||||
| 2 | |||||||||||
| 3 | =encoding utf8 | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Quiq::TableRow - Tabellenzeile | ||||||||||
| 8 | |||||||||||
| 9 | =head1 BASE CLASS | ||||||||||
| 10 | |||||||||||
| 11 | L<Quiq::Object> | ||||||||||
| 12 | |||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||
| 14 | |||||||||||
| 15 | Ein Objekt der Klasse repräsentiert eine Tabellenzeile, bestehend aus | ||||||||||
| 16 | einem Verweis auf die Tabelle (ein Objekt der Klasse Quiq::Table) | ||||||||||
| 17 | und ein Verweis auf ein Array von Werten. Das Array muss keiner Klasse | ||||||||||
| 18 | angehören, kann also ungeblesst sein. Eine Tabellenzeile wird | ||||||||||
| 19 | typischerweise nicht direkt instantiiert, sondern von der Methode push() | ||||||||||
| 20 | der Klasse Quiq::Table. Details siehe dort. | ||||||||||
| 21 | |||||||||||
| 22 | =cut | ||||||||||
| 23 | |||||||||||
| 24 | # ----------------------------------------------------------------------------- | ||||||||||
| 25 | |||||||||||
| 26 | package Quiq::TableRow; | ||||||||||
| 27 | 3 | ▶ | use base qw/Quiq::Object/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 3 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | |||||||||||
| 33 | 3 | our $VERSION = '1.240'; | |||||||||
| 34 | |||||||||||
| 35 | 3 | ▶ | use Scalar::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | |||||||||||
| 37 | # ----------------------------------------------------------------------------- | ||||||||||
| 38 | |||||||||||
| 39 | =head1 METHODS | ||||||||||
| 40 | |||||||||||
| 41 | =head2 Klassenmethoden | ||||||||||
| 42 | |||||||||||
| 43 | =head3 new() - Konstruktor | ||||||||||
| 44 | |||||||||||
| 45 | =head4 Synopsis | ||||||||||
| 46 | |||||||||||
| 47 | $row = $class->new($tab,\@arr); | ||||||||||
| 48 | |||||||||||
| 49 | =head4 Arguments | ||||||||||
| 50 | |||||||||||
| 51 | =over 4 | ||||||||||
| 52 | |||||||||||
| 53 | =item $tab | ||||||||||
| 54 | |||||||||||
| 55 | Referenz auf Tabellenobjekt. | ||||||||||
| 56 | |||||||||||
| 57 | =item @arr | ||||||||||
| 58 | |||||||||||
| 59 | Liste von Werten (Daten der Tabellenzeile). | ||||||||||
| 60 | |||||||||||
| 61 | =back | ||||||||||
| 62 | |||||||||||
| 63 | =head4 Returns | ||||||||||
| 64 | |||||||||||
| 65 | Referenz auf Zeilen-Objekt | ||||||||||
| 66 | |||||||||||
| 67 | =head4 Description | ||||||||||
| 68 | |||||||||||
| 69 | Instantiiere ein Zeilen-Objekt für Tabelle $tab mit den Zeilendaten @arr. | ||||||||||
| 70 | |||||||||||
| 71 | =cut | ||||||||||
| 72 | |||||||||||
| 73 | # ----------------------------------------------------------------------------- | ||||||||||
| 74 | |||||||||||
| 75 | 13 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 76 | 13 | my ($class,$tab,$valueA) = @_; | |||||||||
| 77 | |||||||||||
| 78 | 13 | ▶ | if (@$valueA != $tab->{'width'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | $class->throw( | ||||||||||
| 80 | 'TABLE-00099: Unexpected array length', | ||||||||||
| 81 | 1 | TableWidth => scalar @{$tab->{'columnA'}}, | |||||||||
| 82 | ArrayLength => scalar @$valueA, | ||||||||||
| 83 | ); | ||||||||||
| 84 | } | ||||||||||
| 85 | 12 | Scalar::Util::weaken($tab); | |||||||||
| 86 | |||||||||||
| 87 | 12 | return bless [$tab,$valueA]; | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | # ----------------------------------------------------------------------------- | ||||||||||
| 91 | |||||||||||
| 92 | =head2 Objektmethoden | ||||||||||
| 93 | |||||||||||
| 94 | =head3 get() - Wert einer Kolumne | ||||||||||
| 95 | |||||||||||
| 96 | =head4 Synopsis | ||||||||||
| 97 | |||||||||||
| 98 | $value = $row->get($column); | ||||||||||
| 99 | |||||||||||
| 100 | =head4 Arguments | ||||||||||
| 101 | |||||||||||
| 102 | =over 4 | ||||||||||
| 103 | |||||||||||
| 104 | =item $column | ||||||||||
| 105 | |||||||||||
| 106 | Kolumnenname (String) | ||||||||||
| 107 | |||||||||||
| 108 | =back | ||||||||||
| 109 | |||||||||||
| 110 | =head4 Returns | ||||||||||
| 111 | |||||||||||
| 112 | Kolumnenwert (String) | ||||||||||
| 113 | |||||||||||
| 114 | =head4 Description | ||||||||||
| 115 | |||||||||||
| 116 | Liefere den Wert der Kolumne $column. Existiert die Kolumne nicht, | ||||||||||
| 117 | wird eine Exception geworfen. | ||||||||||
| 118 | |||||||||||
| 119 | =cut | ||||||||||
| 120 | |||||||||||
| 121 | # ----------------------------------------------------------------------------- | ||||||||||
| 122 | |||||||||||
| 123 | 2 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 124 | 2 | my ($self,$column) = @_; | |||||||||
| 125 | 2 | return $self->[1]->[$self->[0]->{'columnH'}->{$column}]; | |||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | # ----------------------------------------------------------------------------- | ||||||||||
| 129 | |||||||||||
| 130 | =head3 values() - Liste der Zeilenwerte | ||||||||||
| 131 | |||||||||||
| 132 | =head4 Synopsis | ||||||||||
| 133 | |||||||||||
| 134 | @values | $valueA = $row->values; | ||||||||||
| 135 | |||||||||||
| 136 | =head4 Returns | ||||||||||
| 137 | |||||||||||
| 138 | Liste der Zeilenwerte (Strings). Im Skalarkontext eine Referenz | ||||||||||
| 139 | auf die Liste. | ||||||||||
| 140 | |||||||||||
| 141 | =head4 Description | ||||||||||
| 142 | |||||||||||
| 143 | Liefere die Liste der Werte der Zeile. | ||||||||||
| 144 | |||||||||||
| 145 | =cut | ||||||||||
| 146 | |||||||||||
| 147 | # ----------------------------------------------------------------------------- | ||||||||||
| 148 | |||||||||||
| 149 | 19 | ▶ | sub values { | ||||||||
|
Subroutine
values: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 150 | 19 | my $self = shift; | |||||||||
| 151 | 19 | my $valueA = $self->[1]; | |||||||||
| 152 | 19 | ▶ | return wantarray? @$valueA: $valueA; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 153 | } | ||||||||||
| 154 | |||||||||||
| 155 | # ----------------------------------------------------------------------------- | ||||||||||
| 156 | |||||||||||
| 157 | =head1 VERSION | ||||||||||
| 158 | |||||||||||
| 159 | 1.240 | ||||||||||
| 160 | |||||||||||
| 161 | =head1 AUTHOR | ||||||||||
| 162 | |||||||||||
| 163 | Frank Seitz, L<http://fseitz.de/> | ||||||||||
| 164 | |||||||||||
| 165 | =head1 COPYRIGHT | ||||||||||
| 166 | |||||||||||
| 167 | Copyright (C) 2026 Frank Seitz | ||||||||||
| 168 | |||||||||||
| 169 | =head1 LICENSE | ||||||||||
| 170 | |||||||||||
| 171 | This code is free software; you can redistribute it and/or modify | ||||||||||
| 172 | it under the same terms as Perl itself. | ||||||||||
| 173 | |||||||||||
| 174 | =cut | ||||||||||
| 175 | |||||||||||
| 176 | # ----------------------------------------------------------------------------- | ||||||||||
| 177 | |||||||||||
| 178 | 3 | 1; | |||||||||
| 179 | |||||||||||
| 180 | # eof | ||||||||||