Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
5d0f1788
Commit
5d0f1788
authored
5 years ago
by
Mark OLESEN
Committed by
Andrew Heather
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ENH: minor improvements to printTable(List<wordList>, ..)
- return Ostream& - make header separation optional
parent
0ccc005f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OpenFOAM/primitives/strings/word/wordIOList.C
+38
-22
38 additions, 22 deletions
src/OpenFOAM/primitives/strings/word/wordIOList.C
src/OpenFOAM/primitives/strings/word/wordIOList.H
+17
-4
17 additions, 4 deletions
src/OpenFOAM/primitives/strings/word/wordIOList.H
with
55 additions
and
26 deletions
src/OpenFOAM/primitives/strings/word/wordIOList.C
+
38
−
22
View file @
5d0f1788
...
@@ -2,7 +2,7 @@
...
@@ -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 |
\\ / A nd |
Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
\\/ M anipulation |
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
| Copyright (C) 2012-2013 OpenFOAM Foundation
| Copyright (C) 2012-2013 OpenFOAM Foundation
...
@@ -40,40 +40,47 @@ namespace Foam
...
@@ -40,40 +40,47 @@ namespace Foam
}
}
void
Foam
::
printTable
Foam
::
Ostream
&
Foam
::
printTable
(
(
const
List
<
wordList
>&
wll
,
const
UList
<
wordList
>&
tbl
,
List
<
string
::
size_type
>&
columnWidth
,
List
<
std
::
string
::
size_type
>&
columnWidths
,
Ostream
&
os
Ostream
&
os
,
bool
headerSeparator
)
)
{
{
if
(
wll
.
empty
())
return
;
if
(
tbl
.
empty
())
{
return
os
;
}
// Find the maximum word length for each column
// Find maximum width for each column
columnWidth
.
setSize
(
wll
[
0
].
size
(),
string
::
size_type
(
0
));
columnWidths
.
resize
(
tbl
.
first
().
size
(),
std
::
string
::
size_type
(
0
));
forAll
(
columnWidth
,
coli
)
forAll
(
columnWidths
,
coli
)
{
{
forAll
(
wll
,
rowi
)
auto
&
colWidth
=
columnWidths
[
coli
];
for
(
const
wordList
&
tblRow
:
tbl
)
{
{
col
umn
Width
[
coli
]
=
colWidth
=
std
::
max
std
::
max
(
(
col
umn
Width
[
coli
]
,
colWidth
,
string
::
size_type
(
wll
[
rowi
]
[
coli
].
size
())
string
::
size_type
(
tblRow
[
coli
].
length
())
);
);
}
}
}
}
// Print the rows adding spacing for the columns
// Print the rows adding spacing for the columns
for
All
(
wll
,
rowi
)
for
(
const
wordList
&
tblRow
:
tbl
)
{
{
forAll
(
wll
[
rowi
]
,
coli
)
forAll
(
tblRow
,
coli
)
{
{
os
<<
wll
[
rowi
]
[
coli
];
os
<<
tblRow
[
coli
];
for
for
(
(
string
::
size_type
space
=
0
;
string
::
size_type
space
=
0
;
space
<
columnWidth
[
coli
]
-
wll
[
rowi
]
[
coli
].
size
()
+
2
;
space
<
columnWidth
s
[
coli
]
-
tblRow
[
coli
].
length
()
+
2
;
++
space
++
space
)
)
{
{
...
@@ -82,15 +89,24 @@ void Foam::printTable
...
@@ -82,15 +89,24 @@ void Foam::printTable
}
}
os
<<
nl
;
os
<<
nl
;
if
(
!
rowi
)
os
<<
nl
;
if
(
headerSeparator
)
os
<<
nl
;
headerSeparator
=
false
;
}
}
return
os
;
}
}
void
Foam
::
printTable
(
const
List
<
wordList
>&
wll
,
Ostream
&
os
)
Foam
::
Ostream
&
Foam
::
printTable
(
const
UList
<
wordList
>&
tbl
,
Ostream
&
os
,
bool
headerSeparator
)
{
{
List
<
string
::
size_type
>
columnWidth
;
List
<
std
::
string
::
size_type
>
columnWidths
;
printTable
(
wll
,
columnWidth
,
os
);
printTable
(
tbl
,
columnWidths
,
os
,
headerSeparator
);
return
os
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/OpenFOAM/primitives/strings/word/wordIOList.H
+
17
−
4
View file @
5d0f1788
...
@@ -2,7 +2,7 @@
...
@@ -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 |
\\ / A nd |
Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
\\/ M anipulation |
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
| Copyright (C) 2012-2013 OpenFOAM Foundation
| Copyright (C) 2012-2013 OpenFOAM Foundation
...
@@ -44,9 +44,22 @@ namespace Foam
...
@@ -44,9 +44,22 @@ namespace Foam
typedef
IOList
<
word
>
wordIOList
;
typedef
IOList
<
word
>
wordIOList
;
typedef
IOList
<
wordList
>
wordListIOList
;
typedef
IOList
<
wordList
>
wordListIOList
;
// Print word list list as a table
//- Print a List of wordList as a table
void
printTable
(
const
List
<
wordList
>&
,
List
<
string
::
size_type
>&
,
Ostream
&
);
Ostream
&
printTable
void
printTable
(
const
List
<
wordList
>&
,
Ostream
&
);
(
const
UList
<
wordList
>&
tbl
,
List
<
std
::
string
::
size_type
>&
columnWidths
,
Ostream
&
os
,
bool
headerSeparator
=
true
);
//- Print a List of wordList as a table
Ostream
&
printTable
(
const
UList
<
wordList
>&
tbl
,
Ostream
&
os
,
bool
headerSeparator
=
true
);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment