mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
OpenFOAM library: Add better error messaging from compound token transfer
This commit is contained in:
@ -56,7 +56,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
||||
{
|
||||
L = dynamicCast<token::Compound<List<T> > >
|
||||
(
|
||||
firstToken.transferCompoundToken()
|
||||
firstToken.transferCompoundToken(is)
|
||||
);
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
|
||||
@ -59,7 +59,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
(
|
||||
dynamicCast<token::Compound<List<T> > >
|
||||
(
|
||||
firstToken.transferCompoundToken()
|
||||
firstToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,133 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2004-2010 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 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/>.
|
||||
|
||||
Class
|
||||
Foam::CompoundToken
|
||||
|
||||
Description
|
||||
An abstract base class for managing compound tokens
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CompoundToken_H
|
||||
#define CompoundToken_H
|
||||
|
||||
#include "refCount.H"
|
||||
#include "typeInfo.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class CompoundToken;
|
||||
Ostream& operator<<(Ostream&, const CompoundToken&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CompoundToken Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class CompoundToken
|
||||
:
|
||||
public refCount
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CompoundToken(const CompoundToken&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CompoundToken&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
virtual const word& type() const = 0;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
CompoundToken,
|
||||
Istream,
|
||||
(const word& type, Istream& is),
|
||||
(type, is)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
CompoundToken()
|
||||
{}
|
||||
|
||||
//- Return the clone as this and increment reference count
|
||||
virtual autoPtr<CompoundToken> clone() const = 0;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select null constructed
|
||||
static autoPtr<CompoundToken> New(const word& type, Istream& is);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~CompoundToken();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
// Check
|
||||
|
||||
// Edit
|
||||
|
||||
// Write
|
||||
|
||||
virtual void write(Istream&) = 0;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const CompoundToken&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -63,11 +63,11 @@ Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
|
||||
|
||||
if (cstrIter == IstreamConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn("token::compound::New(const word&, Istream&)")
|
||||
FatalIOErrorIn("token::compound::New(const word&, Istream&)", is)
|
||||
<< "Unknown compound type " << compoundType << nl << nl
|
||||
<< "Valid compound types:" << endl
|
||||
<< IstreamConstructorTablePtr_->sortedToc()
|
||||
<< abort(FatalError);
|
||||
<< abort(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<Foam::token::compound>(cstrIter()(is));
|
||||
@ -86,15 +86,15 @@ bool Foam::token::compound::isCompound(const word& name)
|
||||
}
|
||||
|
||||
|
||||
Foam::token::compound& Foam::token::transferCompoundToken()
|
||||
Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is)
|
||||
{
|
||||
if (type_ == COMPOUND)
|
||||
{
|
||||
if (compoundTokenPtr_->empty())
|
||||
{
|
||||
FatalErrorIn("token::transferCompoundToken()")
|
||||
FatalIOErrorIn("token::transferCompoundToken(const Istream& is)", is)
|
||||
<< "compound has already been transfered from token\n "
|
||||
<< info() << abort(FatalError);
|
||||
<< info() << abort(FatalIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -351,7 +351,7 @@ public:
|
||||
|
||||
inline bool isCompound() const;
|
||||
inline const compound& compoundToken() const;
|
||||
compound& transferCompoundToken();
|
||||
compound& transferCompoundToken(const Istream& is);
|
||||
|
||||
inline label lineNumber() const;
|
||||
inline label& lineNumber();
|
||||
|
||||
@ -147,7 +147,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<scalar> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -184,7 +184,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<vector> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -224,7 +224,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
||||
token::Compound<List<sphericalTensor> >
|
||||
>
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -264,7 +264,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
||||
token::Compound<List<symmTensor> >
|
||||
>
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -301,7 +301,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<tensor> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ genericPointPatchField<Type>::genericPointPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<scalar> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -167,7 +167,7 @@ genericPointPatchField<Type>::genericPointPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<vector> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -208,7 +208,7 @@ genericPointPatchField<Type>::genericPointPatchField
|
||||
token::Compound<List<sphericalTensor> >
|
||||
>
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -249,7 +249,7 @@ genericPointPatchField<Type>::genericPointPatchField
|
||||
token::Compound<List<symmTensor> >
|
||||
>
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
@ -287,7 +287,7 @@ genericPointPatchField<Type>::genericPointPatchField
|
||||
(
|
||||
dynamicCast<token::Compound<List<tensor> > >
|
||||
(
|
||||
fieldToken.transferCompoundToken()
|
||||
fieldToken.transferCompoundToken(is)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user