BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / db / IOstreams / token / token.C
blobee95a087cbf2ef04da53e6a87209ebf986510f51
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
26 #include "token.H"
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
41     FatalIOError
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,
58     Istream& is
61     IstreamConstructorTable::iterator cstrIter =
62         IstreamConstructorTablePtr_->find(compoundType);
64     if (cstrIter == IstreamConstructorTablePtr_->end())
65     {
66         FatalErrorIn("token::compound::New(const word&, Istream&)")
67             << "Unknown compound type " << compoundType << nl << nl
68             << "Valid compound types:" << endl
69             << IstreamConstructorTablePtr_->sortedToc()
70             << abort(FatalError);
71     }
73     return autoPtr<Foam::token::compound>(cstrIter()(is));
77 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
79 bool Foam::token::compound::isCompound(const word& name)
81     return
82     (
83         IstreamConstructorTablePtr_
84      && IstreamConstructorTablePtr_->found(name)
85     );
89 Foam::token::compound& Foam::token::transferCompoundToken()
91     if (type_ == COMPOUND)
92     {
93         if (compoundTokenPtr_->empty())
94         {
95             FatalErrorIn("token::transferCompoundToken()")
96                 << "compound has already been transfered from token\n    "
97                 << info() << abort(FatalError);
98         }
99         else
100         {
101             compoundTokenPtr_->empty() = true;
102         }
104         return *compoundTokenPtr_;
105     }
106     else
107     {
108         parseError("compound");
109         return *compoundTokenPtr_;
110     }
114 // ************************************************************************* //