wordIOList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "wordIOList.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
35 
39 }
40 
41 
43 (
44  const List<wordList>& wll,
45  List<string::size_type>& columnWidth,
46  Ostream& os
47 )
48 {
49  if (!wll.size()) return;
50 
51  // Find the maximum word length for each column
52  columnWidth.setSize(wll[0].size(), string::size_type(0));
53  forAll(columnWidth, j)
54  {
55  forAll(wll, i)
56  {
57  columnWidth[j] = max(columnWidth[j], wll[i][j].size());
58  }
59  }
60 
61  // Print the rows adding spacing for the columns
62  forAll(wll, i)
63  {
64  forAll(wll[i], j)
65  {
66  os << wll[i][j];
67  for
68  (
70  k<columnWidth[j] - wll[i][j].size() + 2;
71  k++
72  )
73  {
74  os << ' ';
75  }
76  }
77  os << nl;
78 
79  if (i == 0) os << nl;
80  }
81 }
82 
83 
85 {
86  List<string::size_type> columnWidth;
87  printTable(wll, columnWidth, os);
88 }
89 
90 
91 // ************************************************************************* //
label k
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
IOContainer with global data (so optionally read from master)
Definition: GlobalIOList.H:123
A List of objects of type <Type> with automated input and output.
Definition: IOList.H:124
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
void setSize(const label)
Reset size of List.
Definition: List.C:281
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Namespace for OpenFOAM.
defineCompoundTypeName(List< complex >, complexList)
defineTemplateTypeNameAndDebugWithName(IOMap< dictionary >, "dictionaryIOMap", 0)
void printTable(const List< wordList > &, List< string::size_type > &, Ostream &)
Definition: wordIOList.C:43
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
static const char nl
Definition: Ostream.H:260