mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
wordList: Added initial version of printTable which prints a List<wordList> in tabular form
This commit is contained in:
@ -37,4 +37,42 @@ namespace Foam
|
||||
defineTemplateTypeNameAndDebugWithName(wordListIOList, "wordListList", 0);
|
||||
}
|
||||
|
||||
|
||||
void Foam::printTable(const List<wordList>& wll, Ostream& os)
|
||||
{
|
||||
if (!wll.size()) return;
|
||||
|
||||
// Find the maximum word length for each column
|
||||
List<string::size_type> columnWidth(wll[0].size(), string::size_type(0));
|
||||
forAll(columnWidth, j)
|
||||
{
|
||||
forAll(wll, i)
|
||||
{
|
||||
columnWidth[j] = max(columnWidth[j], wll[i][j].size());
|
||||
}
|
||||
}
|
||||
|
||||
// Print the rows adding spacing for the columns
|
||||
forAll(wll, i)
|
||||
{
|
||||
forAll(wll[i], j)
|
||||
{
|
||||
os << wll[i][j];
|
||||
for
|
||||
(
|
||||
string::size_type k=0;
|
||||
k<columnWidth[j] - wll[i][j].size() + 2;
|
||||
k++
|
||||
)
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << nl;
|
||||
|
||||
if (i == 0) os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -41,6 +41,9 @@ namespace Foam
|
||||
{
|
||||
typedef IOList<word> wordIOList;
|
||||
typedef IOList<wordList> wordListIOList;
|
||||
|
||||
// Print word list list as a table
|
||||
void printTable(const List<wordList>&, Ostream&);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user