2 # Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # he Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 package PciIds::Html::Format;
22 use PciIds::Html::Util;
25 our @EXPORT = qw(&htmlFormatTable);
27 sub htmlFormatTable( $$$$$$ ) {
28 my( $data, $cols, $headers, $funcs, $filter, $trHead ) = @_;
29 $trHead = sub { return ''; } unless( defined $trHead );
30 foreach my $line ( @{$data} ) {
31 next unless( &{$filter}( $line ) );
33 print '<tr'.&{$trHead}( $line ).'>';
34 for( $i = 0; $i < $cols; $i ++ ) {
36 if( ( scalar( @{$headers} ) > $i ) && defined( $headers->[ $i ] ) ) {
37 $header = $headers->[ $i ];
41 if( ( scalar( @{$funcs} ) > $i ) && defined( $funcs->[ $i ] ) ) {
42 $func = $funcs->[ $i ];
46 my $data = &{$func}( $line->[ $i ] );
47 $data = "" unless( defined( $data ) );