Commit a4c81f59 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: make streams name() methods virtual throughout (issue #479)

parent 6a0a8b99
......@@ -91,12 +91,11 @@ Foam::IFstream::IFstream
ISstream
(
*ifPtr_,
"IFstream.sourceFile_",
pathname,
format,
version,
IFstreamAllocator::compression_
),
pathname_(pathname)
)
{
setClosed();
......@@ -166,7 +165,7 @@ Foam::IFstream& Foam::IFstream::operator()() const
if (!good())
{
// also checks .gz file
if (isFile(pathname_, true))
if (isFile(this->name(), true))
{
check("IFstream::operator()");
FatalIOError.exit();
......@@ -174,7 +173,7 @@ Foam::IFstream& Foam::IFstream::operator()() const
else
{
FatalIOErrorInFunction(*this)
<< "file " << pathname_ << " does not exist"
<< "file " << this->name() << " does not exist"
<< exit(FatalIOError);
}
}
......
......@@ -84,10 +84,6 @@ class IFstream
public IFstreamAllocator,
public ISstream
{
// Private data
fileName pathname_;
public:
// Declare name of the class and its debug switch
......@@ -113,17 +109,8 @@ public:
// Access
//- Return the name of the stream
const fileName& name() const
{
return pathname_;
}
//- Return non-const access to the name of the stream
fileName& name()
{
return pathname_;
}
//- Read/write access to the name of the stream
using ISstream::name;
// STL stream
......
......@@ -93,8 +93,7 @@ Foam::OFstream::OFstream
)
:
OFstreamAllocator(pathname, compression),
OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
pathname_(pathname)
OSstream(*ofPtr_, pathname, format, version, compression)
{
setClosed();
setState(ofPtr_->rdstate());
......
......@@ -84,11 +84,6 @@ class OFstream
private OFstreamAllocator,
public OSstream
{
// Private data
fileName pathname_;
public:
// Declare name of the class and its debug switch
......@@ -115,17 +110,8 @@ public:
// Access
//- Return the name of the stream
const fileName& name() const
{
return pathname_;
}
//- Return non-const access to the name of the stream
fileName& name()
{
return pathname_;
}
//- Read/write access to the name of the stream
using OSstream::name;
// STL stream
......
......@@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::fileName Foam::IOstream::name_("IOstream");
Foam::fileName Foam::IOstream::staticName_("IOstream");
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
......@@ -89,6 +89,18 @@ Foam::IOstream::compressionEnum(const word& compression)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::fileName& Foam::IOstream::name() const
{
return staticName_;
}
Foam::fileName& Foam::IOstream::name()
{
return staticName_;
}
bool Foam::IOstream::check(const char* operation) const
{
if (bad())
......
......@@ -214,8 +214,8 @@ private:
// Private data
//- Name of the stream
static fileName name_;
//- Name for any generic stream - normally treat as readonly
static fileName staticName_;
streamFormat format_;
versionNumber version_;
......@@ -295,17 +295,11 @@ public:
//- Return the name of the stream
// Useful for Fstream to return the filename
virtual const fileName& name() const
{
return name_;
}
virtual const fileName& name() const;
//- Return non-const access to the name of the stream
// Useful to alter the stream name
virtual fileName& name()
{
return name_;
}
virtual fileName& name();
// Check
......
......@@ -72,7 +72,7 @@ public:
// Constructors
//- Set stream status
//- Construct and set stream status
Istream
(
streamFormat format=ASCII,
......
......@@ -74,7 +74,7 @@ public:
// Constructors
//- Set stream status
//- Construct and set stream status
Ostream
(
streamFormat format=ASCII,
......
......@@ -75,7 +75,7 @@ class ISstream
Istream& readVariable(string&);
//- Disallow default bitwise assignment
void operator=(const ISstream&);
void operator=(const ISstream&) = delete;
public:
......
......@@ -62,14 +62,14 @@ class OSstream
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const OSstream&);
void operator=(const OSstream&) = delete;
public:
// Constructors
//- Set stream status
//- Construct and set stream status
OSstream
(
ostream& os,
......
......@@ -44,7 +44,7 @@ namespace Foam
//- Read a hex label from an input stream
template<class T>
T ReadHex(ISstream&);
T ReadHex(ISstream& is);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -68,7 +68,7 @@ public:
// Constructors
//- Set stream status
//- Construct and set stream status
prefixOSstream
(
ostream& os,
......
......@@ -67,7 +67,7 @@ public:
ISstream
(
*(new std::istringstream(buffer)),
"IStringStream.sourceFile",
"input",
format,
version
)
......@@ -85,7 +85,7 @@ public:
ISstream
(
*(new std::istringstream(buffer)),
"IStringStream.sourceFile",
"input",
format,
version
)
......
......@@ -66,7 +66,7 @@ public:
OSstream
(
*(new std::ostringstream()),
"OStringStream.sinkFile",
"output",
format,
version
)
......@@ -126,7 +126,7 @@ public:
// Print
//- Print description to Ostream
void print(Ostream&) const;
void print(Ostream& os) const;
};
......
......@@ -34,7 +34,7 @@ Description
void Foam::IStringStream::print(Ostream& os) const
{
os << "IStringStream " << name() << " : "
<< "buffer = \n" << str() << Foam::endl;
<< "buffer =\n" << str() << Foam::endl;
ISstream::print(os);
}
......@@ -43,7 +43,7 @@ void Foam::IStringStream::print(Ostream& os) const
void Foam::OStringStream::print(Ostream& os) const
{
os << "OStringStream " << name() << " : "
<< "buffer = \n" << str() << Foam::endl;
<< "buffer =\n" << str() << Foam::endl;
OSstream::print(os);
}
......
......@@ -126,13 +126,13 @@ public:
// Inquiry
//- Return the name of the stream
const fileName& name() const
virtual const fileName& name() const
{
return name_;
}
//- Return non-const access to the name of the stream
fileName& name()
virtual fileName& name()
{
return name_;
}
......@@ -165,7 +165,7 @@ public:
// Read functions
//- Return next token from stream
virtual Istream& read(token&);
virtual Istream& read(token& t);
//- Read a character
virtual Istream& read(char&);
......@@ -203,8 +203,8 @@ public:
// Print
//- Print description of IOstream to Ostream
void print(Ostream&) const;
//- Print description of stream to Ostream
void print(Ostream& os) const;
};
......
......@@ -72,7 +72,7 @@ public:
// Member Functions
// Write
// Write
//- Process unbuffered
virtual std::streamsize xsputn(const char* str, std::streamsize n)
......@@ -109,7 +109,7 @@ public:
// Member Functions
// Access
// Access
//- This hides both signatures of std::basic_ios::rdbuf()
sha1streambuf* rdbuf()
......@@ -139,16 +139,16 @@ class OSHA1stream
// Private Member Functions
//- Disallow default bitwise copy construct
OSHA1stream(const OSHA1stream&);
OSHA1stream(const OSHA1stream&) = delete;
//- Disallow default bitwise assignment
void operator=(const OSHA1stream&);
void operator=(const OSHA1stream&) = delete;
public:
// Constructors
//- Construct and set stream status
//- Construct with an empty digest
OSHA1stream
(
streamFormat format=ASCII,
......@@ -158,7 +158,7 @@ public:
OSstream
(
*(new osha1stream),
"OSHA1stream.sinkFile_",
"OSHA1stream",
format,
version
)
......@@ -174,7 +174,7 @@ public:
// Member functions
// Access
// Access
//- Full access to the sha1
Foam::SHA1& sha1()
......@@ -188,7 +188,8 @@ public:
return sha1().digest();
}
// Edit
// Edit
//- Clear the SHA1 calculation
void rewind()
......
......@@ -134,10 +134,10 @@ public:
// Private Member Functions
//- Disallow default bitwise copy construct
compound(const compound&);
compound(const compound&) = delete;
//- Disallow default bitwise assignment
void operator=(const compound&);
void operator=(const compound&) = delete;
public:
......@@ -195,11 +195,6 @@ public:
virtual label size() const = 0;
// Check
// Edit
// Write
virtual void write(Ostream&) const = 0;
......
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