ENH: wordIOList: return columnsizes when printing table

This commit is contained in:
mattijs
2013-05-14 20:44:40 +01:00
parent 6d3cfe9848
commit 8009617b23
2 changed files with 17 additions and 4 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,12 +38,17 @@ namespace Foam
} }
void Foam::printTable(const List<wordList>& wll, Ostream& os) void Foam::printTable
(
const List<wordList>& wll,
List<string::size_type>& columnWidth,
Ostream& os
)
{ {
if (!wll.size()) return; if (!wll.size()) return;
// Find the maximum word length for each column // Find the maximum word length for each column
List<string::size_type> columnWidth(wll[0].size(), string::size_type(0)); columnWidth.setSize(wll[0].size(), string::size_type(0));
forAll(columnWidth, j) forAll(columnWidth, j)
{ {
forAll(wll, i) forAll(wll, i)
@ -75,4 +80,11 @@ void Foam::printTable(const List<wordList>& wll, Ostream& os)
} }
void Foam::printTable(const List<wordList>& wll, Ostream& os)
{
List<string::size_type> columnWidth;
printTable(wll, columnWidth, os);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,6 +43,7 @@ namespace Foam
typedef IOList<wordList> wordListIOList; typedef IOList<wordList> wordListIOList;
// Print word list list as a table // Print word list list as a table
void printTable(const List<wordList>&, List<string::size_type>&, Ostream&);
void printTable(const List<wordList>&, Ostream&); void printTable(const List<wordList>&, Ostream&);
} }