mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- should have been part of commit 9d36d3c08a
which allows us to upcast a word to a fileName.
85 lines
2.3 KiB
C
85 lines
2.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
-------------------------------------------------------------------------------
|
|
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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "fileName.H"
|
|
#include "IOstreams.H"
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
Foam::fileName::fileName(Istream& is)
|
|
:
|
|
string()
|
|
{
|
|
is >> *this;
|
|
}
|
|
|
|
|
|
Foam::Istream& Foam::operator>>(Istream& is, fileName& val)
|
|
{
|
|
token t(is);
|
|
|
|
if (!t.good())
|
|
{
|
|
FatalIOErrorInFunction(is)
|
|
<< "Bad token - could not get string"
|
|
<< exit(FatalIOError);
|
|
is.setBad();
|
|
return is;
|
|
}
|
|
|
|
if (t.isStringType())
|
|
{
|
|
// Also accept a plain word as a fileName
|
|
val = t.stringToken();
|
|
}
|
|
else
|
|
{
|
|
FatalIOErrorInFunction(is)
|
|
<< "Wrong token type - expected string, found "
|
|
<< t.info()
|
|
<< exit(FatalIOError);
|
|
is.setBad();
|
|
return is;
|
|
}
|
|
|
|
val.stripInvalid();
|
|
|
|
is.check(FUNCTION_NAME);
|
|
return is;
|
|
}
|
|
|
|
|
|
Foam::Ostream& Foam::operator<<(Ostream& os, const fileName& val)
|
|
{
|
|
os.write(val);
|
|
os.check(FUNCTION_NAME);
|
|
return os;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|