1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
36 void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
38 is.fatalCheck("PtrList<T>::read(Istream&, const INew&)");
44 "PtrList<T>::read(Istream&, const INew&) : "
48 if (firstToken.isLabel())
51 label s = firstToken.labelToken();
55 // Read beginning of contents
56 char delimiter = is.readBeginList("PtrList");
60 if (delimiter == token::BEGIN_LIST)
68 "PtrList<T>::read(Istream&, const INew&) : "
75 T* tPtr = inewt(is).ptr();
80 "PtrList<T>::read(Istream&, const INew&) : "
81 "reading the single entry"
84 for (label i=1; i<s; i++)
86 set(i, tPtr->clone());
91 // Read end of contents
92 is.readEndList("PtrList");
94 else if (firstToken.isPunctuation())
96 if (firstToken.pToken() != token::BEGIN_LIST)
100 "PtrList<T>::read(Istream&, const INew&)",
102 ) << "incorrect first token, '(', found " << firstToken.info()
103 << exit(FatalIOError);
112 lastToken.isPunctuation()
113 && lastToken.pToken() == token::END_LIST
117 is.putBack(lastToken);
118 sllPtrs.append(inewt(is).ptr());
122 setSize(sllPtrs.size());
127 typename SLList<T*>::iterator iter = sllPtrs.begin();
128 iter != sllPtrs.end();
139 "PtrList<T>::read(Istream&, const INew&)",
141 ) << "incorrect first token, expected <int> or '(', found "
143 << exit(FatalIOError);
148 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
152 Foam::PtrList<T>::PtrList(Istream& is, const INew& inewt)
159 Foam::PtrList<T>::PtrList(Istream& is)
165 // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
168 Foam::Istream& Foam::operator>>(Istream& is, PtrList<T>& L)
171 L.read(is, INew<T>());
177 // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
180 Foam::Ostream& Foam::operator<<(Ostream& os, const PtrList<T>& L)
182 // Write size and start delimiter
183 os << nl << L.size() << nl << token::BEGIN_LIST;
191 // Write end delimiter
192 os << nl << token::END_LIST << nl;
194 // Check state of IOstream
195 os.check("Ostream& operator<<(Ostream&, const PtrList&)");
201 // ************************************************************************* //