Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
f78aa8e3
Commit
f78aa8e3
authored
Nov 25, 2018
by
Mark Olesen
Browse files
ENH: added Ostream fill() methods and corresponding IOmanip setfill()
- useful when generating formatted output such as tables.
parent
d8a55e46
Changes
6
Hide whitespace changes
Inline
Side-by-side
applications/test/io/Test-io.C
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -22,9 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
t
est
T
est
-io
Description
Test basic stream functionality
\*---------------------------------------------------------------------------*/
...
...
@@ -51,7 +52,25 @@ int main(void)
Info
<<
hex
<<
255
<<
endl
;
Info
<<
nl
<<
"Formatted fields"
<<
nl
;
const
char
oldfill
=
static_cast
<
OSstream
&>
(
Info
).
fill
();
Info
<<
setfill
(
'-'
);
Info
<<
"|"
<<
setf
(
ios_base
::
left
)
<<
setw
(
32
)
<<
" foo "
<<
"|"
<<
nl
;
Info
<<
"|"
<<
setf
(
ios_base
::
left
)
<<
setw
(
10
)
<<
" bar "
<<
"|"
<<
nl
;
Info
<<
"|"
<<
setf
(
ios_base
::
left
)
<<
setw
(
10
)
<<
""
<<
"|"
<<
nl
;
Info
<<
"resetting fill from (0x"
<<
hex
<<
int
(
oldfill
)
<<
")"
<<
nl
;
Info
<<
setfill
(
oldfill
);
Info
<<
"|"
<<
setf
(
ios_base
::
left
)
<<
setw
(
10
)
<<
" bar "
<<
"|"
<<
nl
;
Info
<<
nl
<<
nl
;
Info
.
operator
Foam
::
OSstream
&
()
<<
"stop"
<<
endl
;
static_cast
<
OSstream
&>
(
Info
)
<<
"
\n
End
\n
"
<<
nl
;
}
// ************************************************************************* //
src/OpenFOAM/db/IOstreams/IOstreams/IOmanip.H
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -40,7 +40,7 @@ Description
namespace
Foam
{
// Forward declaration
of friend functions and operator
s
// Forward declarations
template
<
class
T
>
class
Smanip
;
template
<
class
T
>
class
Imanip
;
...
...
@@ -160,15 +160,18 @@ inline Ostream& operator<<(Ostream& os, const Omanip<T>& m)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline
Smanip
<
ios_base
::
fmtflags
>
setf
(
const
ios_base
::
fmtflags
flags
)
inline
Smanip
<
ios_base
::
fmtflags
>
setf
(
const
ios_base
::
fmtflags
flags
)
{
return
Smanip
<
ios_base
::
fmtflags
>
(
&
IOstream
::
setf
,
flags
);
}
inline
Omanip
<
char
>
setfill
(
char
fillch
)
{
return
Omanip
<
char
>
(
&
Ostream
::
fill
,
fillch
);
}
inline
Omanip
<
IOstream
::
streamFormat
>
setformat
(
const
IOstream
::
streamFormat
fmt
...
...
src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -239,6 +239,12 @@ public:
//- Add newline and flush stream
virtual
void
endl
()
=
0
;
//- Get padding character
virtual
char
fill
()
const
=
0
;
//- Set padding character for formatted field up to field width
virtual
char
fill
(
const
char
fillch
)
=
0
;
//- Get width of output field
virtual
int
width
()
const
=
0
;
...
...
src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -122,7 +122,7 @@ public:
~
UOPstream
();
// Member
f
unctions
// Member
F
unctions
// Inquiry
...
...
@@ -133,7 +133,7 @@ public:
}
// Write
f
unctions
// Write
F
unctions
//- Write given buffer to given processor
static
bool
write
...
...
@@ -223,13 +223,27 @@ public:
virtual
void
endl
()
{}
//- Get the current padding character
// \return previous padding character
virtual
char
fill
()
const
{
return
0
;
}
//- Set padding character for formatted field up to field width
virtual
char
fill
(
const
char
)
{
return
0
;
}
//- Get width of output field
virtual
int
width
()
const
{
return
0
;
}
//- Set width of output field (and return old width)
//- Set width of output field
// \return previous width
virtual
int
width
(
const
int
)
{
return
0
;
...
...
@@ -241,7 +255,8 @@ public:
return
0
;
}
//- Set precision of output field (and return old precision)
//- Set precision of output field
// \return old precision
virtual
int
precision
(
const
int
)
{
return
0
;
...
...
src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -289,6 +289,18 @@ std::ios_base::fmtflags Foam::OSstream::flags(const ios_base::fmtflags f)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
char
Foam
::
OSstream
::
fill
()
const
{
return
os_
.
fill
();
}
char
Foam
::
OSstream
::
fill
(
const
char
fillch
)
{
return
os_
.
fill
(
fillch
);
}
int
Foam
::
OSstream
::
width
()
const
{
return
os_
.
width
();
...
...
src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H
View file @
f78aa8e3
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -180,18 +180,25 @@ public:
//- Add newline and flush stream
virtual
void
endl
();
//- Get the current padding character
virtual
char
fill
()
const
;
//- Set padding character for formatted field up to field width
// \return previous padding character
virtual
char
fill
(
const
char
fillch
);
//- Get width of output field
virtual
int
width
()
const
;
//- Set width of output field
// \return previous width
//
\return previous width
virtual
int
width
(
const
int
w
);
//- Get precision of output field
virtual
int
precision
()
const
;
//- Set precision of output field
// \return old precision
//
\return old precision
virtual
int
precision
(
const
int
p
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment