Commit 3135dcf2 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: support IOstreamOption in abstract stream types

- expose the write IOstreamOption in Time
parent 33f9ae50
......@@ -158,10 +158,11 @@ public:
// Constructors
//- Construct with specified stream option
explicit IOstream(const IOstreamOption option)
//- Default construct (ASCII, uncompressed),
//- construct with specified stream option
explicit IOstream(IOstreamOption streamOpt = IOstreamOption())
:
IOstreamOption(option),
IOstreamOption(streamOpt),
openClosed_(CLOSED),
ioState_(ios_base::iostate(0)),
labelByteSize_(sizeof(label)),
......@@ -171,15 +172,15 @@ public:
setBad();
}
//- Construct with format, version
//- Construct with format, version (compression)
IOstream
(
streamFormat format,
versionNumber version,
compressionType compression=UNCOMPRESSED
streamFormat fmt,
versionNumber ver,
compressionType comp = compressionType::UNCOMPRESSED
)
:
IOstream(IOstreamOption(format, version, compression))
IOstream(IOstreamOption(fmt, comp, ver))
{}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -85,16 +85,23 @@ public:
// Constructors
//- Default construct, set stream status
Istream
//- Default construct (ASCII, uncompressed),
//- construct with specified stream option.
explicit Istream(IOstreamOption streamOpt = IOstreamOption())
:
IOstream(streamOpt),
putBack_(false)
{}
//- Construct with format, version (compression)
explicit Istream
(
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
streamFormat fmt,
versionNumber ver = currentVersion,
compressionType comp = compressionType::UNCOMPRESSED
)
:
IOstream(format, version, compression),
putBack_(false)
Istream(IOstreamOption(fmt, comp, ver))
{}
......
......@@ -85,15 +85,23 @@ public:
// Constructors
//- Default construct, set stream status
Ostream
//- Default construct (ASCII, uncompressed),
//- construct with specified stream option
explicit Ostream(IOstreamOption streamOpt = IOstreamOption())
:
IOstream(streamOpt)
{}
//- Construct with format, version (compression)
explicit Ostream
(
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
streamFormat fmt,
versionNumber ver = currentVersion,
compressionType comp = compressionType::UNCOMPRESSED
)
:
IOstream(format, version, compression)
Ostream(IOstreamOption(fmt, comp, ver))
{}
......
......@@ -28,7 +28,7 @@ Class
Foam::ISstream
Description
Generic input stream using standard (STL) streams.
Generic input stream using a standard (STL) stream.
SourceFiles
ISstreamI.H
......@@ -88,16 +88,28 @@ public:
// Constructors
//- Construct as wrapper around std::istream
//- Construct wrapper around std::istream, set stream status
// Default stream options (ASCII, uncompressed)
inline ISstream
(
std::istream& is,
const string& name,
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
const string& streamName,
IOstreamOption streamOpt = IOstreamOption()
);
//- Construct wrapper around std::istream, set stream status
ISstream
(
std::istream& is,
const string& streamName,
streamFormat fmt,
versionNumber ver = currentVersion,
compressionType comp = compressionType::UNCOMPRESSED
)
:
ISstream(is, streamName, IOstreamOption(fmt, comp, ver))
{}
//- Destructor
virtual ~ISstream() = default;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,14 +31,12 @@ License
inline Foam::ISstream::ISstream
(
std::istream& is,
const string& name,
streamFormat format,
versionNumber version,
compressionType compression
const string& streamName,
IOstreamOption streamOpt
)
:
Istream(format, version, compression),
name_(name),
Istream(streamOpt),
name_(streamName),
is_(is)
{
if (is_.good())
......
......@@ -28,7 +28,7 @@ Class
Foam::OSstream
Description
Generic output stream.
Generic output stream using a standard (STL) stream.
SourceFiles
OSstreamI.H
......@@ -76,16 +76,28 @@ public:
// Constructors
//- Construct as wrapper around std::ostream and set stream status
//- Construct wrapper around std::ostream, set stream status
// Default stream options (ASCII, uncompressed)
inline OSstream
(
std::ostream& os,
const string& name,
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
const string& streamName,
IOstreamOption streamOpt = IOstreamOption()
);
//- Construct wrapper around std::ostream, set stream status
OSstream
(
std::ostream& os,
const string& streamName,
streamFormat fmt,
versionNumber ver = currentVersion,
compressionType comp = compressionType::UNCOMPRESSED
)
:
OSstream(os, streamName, IOstreamOption(fmt, comp, ver))
{}
// Member Functions
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -32,14 +33,12 @@ License
inline Foam::OSstream::OSstream
(
std::ostream& os,
const string& name,
streamFormat format,
versionNumber version,
compressionType compression
const string& streamName,
IOstreamOption streamOpt
)
:
Ostream(format, version, compression),
name_(name),
Ostream(streamOpt),
name_(streamName),
os_(os)
{
if (os_.good())
......
......@@ -47,13 +47,11 @@ inline void Foam::prefixOSstream::checkWritePrefix()
Foam::prefixOSstream::prefixOSstream
(
std::ostream& os,
const string& name,
streamFormat format,
versionNumber version,
compressionType compression
const string& streamName,
IOstreamOption streamOpt
)
:
OSstream(os, name, format, version, compression),
OSstream(os, streamName, streamOpt),
printPrefix_(true),
prefix_()
{}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -75,12 +76,23 @@ public:
prefixOSstream
(
std::ostream& os,
const string& name,
streamFormat format=ASCII,
versionNumber version=currentVersion,
compressionType compression=UNCOMPRESSED
const string& streamName,
IOstreamOption streamOpt = IOstreamOption()
);
//- Construct and set stream status
prefixOSstream
(
std::ostream& os,
const string& streamName,
streamFormat fmt,
versionNumber ver = currentVersion,
compressionType comp = compressionType::UNCOMPRESSED
)
:
prefixOSstream(os, streamName, IOstreamOption(fmt, comp, ver))
{}
// Member Functions
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -206,7 +206,7 @@ protected:
private:
//- Default write stream option (format, version, compression)
//- The write stream option (format, compression, version)
IOstreamOption writeStreamOption_;
//- Default graph format
......@@ -323,24 +323,30 @@ public:
return path()/timeName();
}
//- Default write format
IOstream::streamFormat writeFormat() const
//- The write stream option (format, compression, version)
IOstreamOption writeStreamOption() const
{
return writeStreamOption_.format();
return writeStreamOption_;
}
//- Default write version number
IOstream::versionNumber writeVersion() const
//- The write stream format
IOstream::streamFormat writeFormat() const
{
return writeStreamOption_.version();
return writeStreamOption_.format();
}
//- Default write compression
//- The write stream compression
IOstream::compressionType writeCompression() const
{
return writeStreamOption_.compression();
}
//- The write stream version
IOstream::versionNumber writeVersion() const
{
return writeStreamOption_.version();
}
//- Default graph format
const word& graphFormat() const
{
......
Markdown is supported
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