Skip to content
Snippets Groups Projects
Commit 931b8633 authored by Henry's avatar Henry
Browse files

wordList: Added initial version of printTable which prints a List<wordList> in tabular form

parent 2801f229
No related merge requests found
......@@ -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&);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment