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
27 \*---------------------------------------------------------------------------*/
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 template<class LListBase, class T>
37 void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
39 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
45 "operator>>(Istream&, ILList<LListBase, T>&) : reading first token"
48 if (firstToken.isLabel())
50 label s = firstToken.labelToken();
52 // Read beginning of contents
53 char delimiter = is.readBeginList("ILList<LListBase, T>");
57 if (delimiter == token::BEGIN_LIST)
59 for (label i=0; i<s; i++)
61 append(iNew(is).ptr());
65 "operator>>(Istream&, ILList<LListBase, T>&) : "
72 T* tPtr = iNew(is).ptr();
77 "operator>>(Istream&, ILList<LListBase, T>&) : "
81 for (label i=1; i<s; i++)
88 // Read end of contents
89 is.readEndList("ILList<LListBase, T>");
91 else if (firstToken.isPunctuation())
93 if (firstToken.pToken() != token::BEGIN_LIST)
97 "operator>>(Istream&, ILList<LListBase, T>&)",
99 ) << "incorrect first token, '(', found " << firstToken.info()
100 << exit(FatalIOError);
104 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
109 lastToken.isPunctuation()
110 && lastToken.pToken() == token::END_LIST
114 is.putBack(lastToken);
115 append(iNew(is).ptr());
118 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
123 FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is)
124 << "incorrect first token, expected <int> or '(', found "
126 << exit(FatalIOError);
129 is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
133 template<class LListBase, class T>
135 Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew)
141 template<class LListBase, class T>
142 Foam::ILList<LListBase, T>::ILList(Istream& is)
148 // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
150 template<class LListBase, class T>
151 Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L)
154 L.read(is, INew<T>());
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 // ************************************************************************* //