Merge branch 'master' into cvm

This commit is contained in:
graham
2010-01-04 11:47:57 +00:00
22 changed files with 693 additions and 555 deletions

View File

@ -78,17 +78,6 @@ Foam::IFstreamAllocator::~IFstreamAllocator()
}
std::istream& Foam::IFstreamAllocator::stdStream()
{
if (!ifPtr_)
{
FatalErrorIn("IFstreamAllocator::stdStream()")
<< "No stream allocated" << abort(FatalError);
}
return *ifPtr_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IFstream::IFstream
@ -143,6 +132,28 @@ Foam::IFstream::~IFstream()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::istream& Foam::IFstream::stdStream()
{
if (!ifPtr_)
{
FatalErrorIn("IFstream::stdStream()")
<< "No stream allocated" << abort(FatalError);
}
return *ifPtr_;
}
const std::istream& Foam::IFstream::stdStream() const
{
if (!ifPtr_)
{
FatalErrorIn("IFstream::stdStream() const")
<< "No stream allocated" << abort(FatalError);
}
return *ifPtr_;
}
void Foam::IFstream::print(Ostream& os) const
{
// Print File data

View File

@ -51,7 +51,7 @@ namespace Foam
class IFstream;
/*---------------------------------------------------------------------------*\
Class IFstreamAllocator Declaration
Class IFstreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A std::istream with ability to handle compressed files
@ -74,19 +74,11 @@ class IFstreamAllocator
// Destructor
~IFstreamAllocator();
public:
// Member functions
//- Access to underlying std::istream (for e.g. lexer)
istream& stdStream();
};
/*---------------------------------------------------------------------------*\
Class IFstream Declaration
Class IFstream Declaration
\*---------------------------------------------------------------------------*/
class IFstream
@ -136,6 +128,16 @@ public:
return pathname_;
}
// STL stream
//- Access to underlying std::istream
virtual istream& stdStream();
//- Const access to underlying std::istream
virtual const istream& stdStream() const;
// Print
//- Print description of IOstream to Ostream

View File

@ -81,17 +81,6 @@ Foam::OFstreamAllocator::~OFstreamAllocator()
}
std::ostream& Foam::OFstreamAllocator::stdStream()
{
if (!ofPtr_)
{
FatalErrorIn("OFstreamAllocator::stdStream()")
<< "No stream allocated." << abort(FatalError);
}
return *ofPtr_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::OFstream::OFstream
@ -131,7 +120,7 @@ Foam::OFstream::OFstream
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::OFstream::~OFstream()
{}
@ -139,6 +128,28 @@ Foam::OFstream::~OFstream()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::ostream& Foam::OFstream::stdStream()
{
if (!ofPtr_)
{
FatalErrorIn("OFstream::stdStream()")
<< "No stream allocated." << abort(FatalError);
}
return *ofPtr_;
}
const std::ostream& Foam::OFstream::stdStream() const
{
if (!ofPtr_)
{
FatalErrorIn("OFstreamAllocator::stdStream() const")
<< "No stream allocated." << abort(FatalError);
}
return *ofPtr_;
}
void Foam::OFstream::print(Ostream& os) const
{
os << " OFstream: ";

View File

@ -51,7 +51,7 @@ namespace Foam
class OFstream;
/*---------------------------------------------------------------------------*\
Class OFstreamAllocator Declaration
Class OFstreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A std::ostream with ability to handle compressed files
@ -74,18 +74,11 @@ class OFstreamAllocator
~OFstreamAllocator();
public:
// Member functions
//- Access to underlying std::ostream
ostream& stdStream();
};
/*---------------------------------------------------------------------------*\
Class OFstream Declaration
Class OFstream Declaration
\*---------------------------------------------------------------------------*/
class OFstream
@ -138,6 +131,15 @@ public:
}
// STL stream
//- Access to underlying std::ostream
virtual ostream& stdStream();
//- Const access to underlying std::ostream
virtual const ostream& stdStream() const;
// Print
//- Print description of IOstream to Ostream
@ -146,8 +148,8 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global predefined null output stream
//- Global predefined null output stream "/dev/null"
extern OFstream Snull;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -551,7 +551,7 @@ Foam::Istream& Foam::ISstream::read(char* buf, std::streamsize count)
Foam::Istream& Foam::ISstream::rewind()
{
stream().rdbuf()->pubseekpos(0);
stdStream().rdbuf()->pubseekpos(0);
return *this;
}

View File

@ -72,23 +72,6 @@ class ISstream
void operator=(const ISstream&);
protected:
// Protected member functions
//- Return the stream reference
istream& stream()
{
return is_;
}
//- Return the const stream reference
const istream& stream() const
{
return is_;
}
public:
// Constructors
@ -185,6 +168,21 @@ public:
virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
// STL stream
//- Access to underlying std::istream
virtual istream& stdStream()
{
return is_;
}
//- Const access to underlying std::istream
virtual const istream& stdStream() const
{
return is_;
}
// Print
//- Print description of IOstream to Ostream

View File

@ -67,21 +67,6 @@ class OSstream
void operator=(const OSstream&);
protected:
//- Return the stream reference
ostream& stream()
{
return os_;
}
//- Return the const stream reference
const ostream& stream() const
{
return os_;
}
public:
// Constructors
@ -187,6 +172,21 @@ public:
virtual int precision(const int);
// STL stream
//- Access to underlying std::ostream
virtual ostream& stdStream()
{
return os_;
}
//- Const access to underlying std::ostream
virtual const ostream& stdStream() const
{
return os_;
}
// Print
//- Print description of IOstream to Ostream

View File

@ -97,7 +97,7 @@ public:
~IStringStream()
{
delete &dynamic_cast<std::istringstream&>(stream());
delete &dynamic_cast<std::istringstream&>(stdStream());
}
@ -108,7 +108,10 @@ public:
//- Return the string
string str() const
{
return dynamic_cast<const std::istringstream&>(stream()).str();
return dynamic_cast<const std::istringstream&>
(
stdStream()
).str();
}

View File

@ -83,7 +83,7 @@ public:
(
dynamic_cast<const std::ostringstream&>
(
oss.stream()
oss.stdStream()
).str()
)
),
@ -98,7 +98,7 @@ public:
~OStringStream()
{
delete &dynamic_cast<std::ostringstream&>(stream());
delete &dynamic_cast<std::ostringstream&>(stdStream());
}
@ -109,7 +109,10 @@ public:
//- Return the string
string str() const
{
return dynamic_cast<const std::ostringstream&>(stream()).str();
return dynamic_cast<const std::ostringstream&>
(
stdStream()
).str();
}
@ -119,9 +122,9 @@ public:
void rewind()
{
# if __GNUC__ < 4 && __GNUC_MINOR__ < 4
stream().rdbuf()->pubsetbuf(" ", 1);
stdStream().rdbuf()->pubsetbuf(" ", 1);
# else
stream().rdbuf()->pubseekpos(0);
stdStream().rdbuf()->pubseekpos(0);
# endif
}

View File

@ -170,7 +170,7 @@ public:
~OSHA1stream()
{
delete &dynamic_cast<osha1stream&>(stream());
delete &dynamic_cast<osha1stream&>(stdStream());
}
@ -181,7 +181,7 @@ public:
//- Full access to the sha1
Foam::SHA1& sha1()
{
return dynamic_cast<osha1stream&>(stream()).sha1();
return dynamic_cast<osha1stream&>(stdStream()).sha1();
}
//- Return SHA1::Digest for the data processed until now

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::CocoParserErrors
Description
Templated class to shadow the error handling for Coco/R parsers
\*---------------------------------------------------------------------------*/
#ifndef CocoParserErrors_H
#define CocoParserErrors_H
#include "error.H"
#include "wchar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class CocoParserErrors Declaration
\*---------------------------------------------------------------------------*/
template<class BaseClass>
class CocoParserErrors
:
public BaseClass
{
// Private data
//- The name issued in warnings and errors
word name_;
public:
// Constructors
//- Construct with given name
CocoParserErrors(const word& name)
:
BaseClass(),
name_(name)
{}
//- Destructor
virtual ~CocoParserErrors()
{}
// Member functions
//- Return the name issued for warnings
virtual const word& name() const
{
return name_;
}
//- Return the name issued for warnings
virtual word& name()
{
return name_;
}
// Error Handling
//- Handle a general warning 'msg'
virtual void Warning(const wchar_t* msg)
{
WarningIn(name_)
<< msg << endl;
}
//- Handle a general warning 'msg'
virtual void Warning(int line, int col, const wchar_t* msg)
{
WarningIn(name_)
<<"line " << line << " col " << col << ": "
<< msg << endl;
}
//- Handle general error 'msg' (eg, a semantic error)
virtual void Error(int line, int col, const wchar_t* msg)
{
FatalErrorIn(name_)
<< "line " << line << " col " << col <<": " << msg << endl
<< exit(FatalError);
}
//- Handle general error 'msg' (eg, a semantic error)
virtual void Error(const wchar_t* msg)
{
FatalErrorIn(name_)
<< msg << endl
<< exit(FatalError);
}
//- Handle a general exception 'msg'
virtual void Exception(const wchar_t* msg)
{
this->Error(msg);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -91,7 +91,7 @@ Foam::Ostream& Foam::ensightFile::write
std::streamsize count
)
{
stream().write(buf, count);
stdStream().write(buf, count);
return *this;
}
@ -126,7 +126,7 @@ Foam::Ostream& Foam::ensightFile::write(const string& value)
}
else
{
stream() << buf;
stdStream() << buf;
}
return *this;
@ -147,8 +147,8 @@ Foam::Ostream& Foam::ensightFile::write(const label value)
}
else
{
stream().width(10);
stream() << value;
stdStream().width(10);
stdStream() << value;
}
return *this;
@ -173,8 +173,8 @@ Foam::Ostream& Foam::ensightFile::write
}
else
{
stream().width(fieldWidth);
stream() << value;
stdStream().width(fieldWidth);
stdStream() << value;
}
return *this;
@ -195,8 +195,8 @@ Foam::Ostream& Foam::ensightFile::write(const scalar value)
}
else
{
stream().width(12);
stream() << value;
stdStream().width(12);
stdStream() << value;
}
return *this;
@ -207,7 +207,7 @@ void Foam::ensightFile::newline()
{
if (format() == IOstream::ASCII)
{
stream() << nl;
stdStream() << nl;
}
}