1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 const char* const Foam::token::typeName = "token";
31 Foam::token Foam::token::undefinedToken;
33 defineTypeNameAndDebug(Foam::token::compound, 0);
34 defineRunTimeSelectionTable(Foam::token::compound, Istream);
37 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
39 void Foam::token::parseError(const char* expected) const
42 << "Parse error, expected a " << expected
43 << ", found \n " << info() << endl;
47 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
49 Foam::token::compound::~compound()
53 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
55 Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
57 const word& compoundType,
61 IstreamConstructorTable::iterator cstrIter =
62 IstreamConstructorTablePtr_->find(compoundType);
64 if (cstrIter == IstreamConstructorTablePtr_->end())
66 FatalErrorIn("token::compound::New(const word&, Istream&)")
67 << "Unknown compound type " << compoundType << nl << nl
68 << "Valid compound types:" << endl
69 << IstreamConstructorTablePtr_->sortedToc()
73 return autoPtr<Foam::token::compound>(cstrIter()(is));
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 bool Foam::token::compound::isCompound(const word& name)
83 IstreamConstructorTablePtr_
84 && IstreamConstructorTablePtr_->found(name)
89 Foam::token::compound& Foam::token::transferCompoundToken()
91 if (type_ == COMPOUND)
93 if (compoundTokenPtr_->empty())
95 FatalErrorIn("token::transferCompoundToken()")
96 << "compound has already been transfered from token\n "
97 << info() << abort(FatalError);
101 compoundTokenPtr_->empty() = true;
104 return *compoundTokenPtr_;
108 parseError("compound");
109 return *compoundTokenPtr_;
114 // ************************************************************************* //