wordIOList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2013 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 {
33  defineCompoundTypeName(List<word>, wordList);
35 
38 }
39 
40 
42 (
43  const List<wordList>& wll,
44  List<string::size_type>& columnWidth,
45  Ostream& os
46 )
47 {
48  if (!wll.size()) return;
49 
50  // Find the maximum word length for each column
51  columnWidth.setSize(wll[0].size(), string::size_type(0));
52  forAll(columnWidth, j)
53  {
54  forAll(wll, i)
55  {
56  columnWidth[j] = max(columnWidth[j], wll[i][j].size());
57  }
58  }
59 
60  // Print the rows adding spacing for the columns
61  forAll(wll, i)
62  {
63  forAll(wll[i], j)
64  {
65  os << wll[i][j];
66  for
67  (
69  k<columnWidth[j] - wll[i][j].size() + 2;
70  k++
71  )
72  {
73  os << ' ';
74  }
75  }
76  os << nl;
77 
78  if (i == 0) os << nl;
79  }
80 }
81 
82 
84 {
85  List<string::size_type> columnWidth;
86  printTable(wll, columnWidth, os);
87 }
88 
89 
90 // ************************************************************************* //
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Namespace for OpenFOAM.
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static const char nl
Definition: Ostream.H:260
void setSize(const label)
Reset size of List.
Definition: List.C:318
void printTable(const List< wordList > &, List< string::size_type > &, Ostream &)
Definition: wordIOList.C:42
defineTemplateTypeNameAndDebugWithName(scalarAverageIOField,"scalarAverageField", 0)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
label k
Boltzmann constant.
Macros for easy insertion into run-time selection tables.
defineCompoundTypeName(List< complex >, complexList)
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
List< word > wordList
A List of words.
Definition: fileName.H:54
IOList< wordList > wordListIOList
Definition: wordIOList.H:43
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
IOList< word > wordIOList
IO of a list of words.
Definition: wordIOList.H:42