1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 const char* const Foam::token::typeName = "token";
32 Foam::token Foam::token::undefinedToken;
34 defineTypeNameAndDebug(Foam::token::compound, 0);
35 defineRunTimeSelectionTable(Foam::token::compound, Istream);
38 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
40 void Foam::token::parseError(const char* expected) const
43 << "Parse error, expected a " << expected
44 << ", found \n " << info() << endl;
48 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
50 Foam::token::compound::~compound()
54 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
56 Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
58 const word& compoundType,
62 IstreamConstructorTable::iterator cstrIter =
63 IstreamConstructorTablePtr_->find(compoundType);
65 if (cstrIter == IstreamConstructorTablePtr_->end())
67 FatalErrorIn("token::compound::New(const word&, Istream&)")
68 << "Unknown compound type " << compoundType << nl << nl
69 << "Valid compound types:" << endl
70 << IstreamConstructorTablePtr_->toc()
74 return autoPtr<Foam::token::compound>(cstrIter()(is));
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 bool Foam::token::compound::isCompound(const word& name)
84 IstreamConstructorTablePtr_
85 && IstreamConstructorTablePtr_->found(name)
90 Foam::token::compound& Foam::token::transferCompoundToken()
92 if (type_ == COMPOUND)
94 if (compoundTokenPtr_->empty())
96 FatalErrorIn("token::transferCompoundToken()")
97 << "compound has already been transfered from token\n "
98 << info() << abort(FatalError);
102 compoundTokenPtr_->empty() = true;
105 return *compoundTokenPtr_;
109 parseError("compound");
110 return *compoundTokenPtr_;
115 // ************************************************************************* //