/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "PtrList.H" #include "SLList.H" #include "Istream.H" #include "Ostream.H" #include "INew.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template template void Foam::PtrList::read(Istream& is, const INew& inewt) { is.fatalCheck("PtrList::read(Istream&, const INew&)"); token firstToken(is); is.fatalCheck ( "PtrList::read(Istream&, const INew&) : " "reading first token" ); if (firstToken.isLabel()) { // Read size of list label s = firstToken.labelToken(); setSize(s); // Read beginning of contents char delimiter = is.readBeginList("PtrList"); if (s) { if (delimiter == token::BEGIN_LIST) { forAll(*this, i) { set(i, inewt(is)); is.fatalCheck ( "PtrList::read(Istream&, const INew&) : " "reading entry" ); } } else { T* tPtr = inewt(is).ptr(); set(0, tPtr); is.fatalCheck ( "PtrList::read(Istream&, const INew&) : " "reading the single entry" ); for (label i=1; iclone()); } } } // Read end of contents is.readEndList("PtrList"); } else if (firstToken.isPunctuation()) { if (firstToken.pToken() != token::BEGIN_LIST) { FatalIOErrorInFunction ( is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } SLList sllPtrs; token lastToken(is); while ( !( lastToken.isPunctuation() && lastToken.pToken() == token::END_LIST ) ) { is.putBack(lastToken); if (is.eof()) { FatalIOErrorInFunction ( is ) << "Premature EOF after reading " << lastToken.info() << exit(FatalIOError); } sllPtrs.append(inewt(is).ptr()); is >> lastToken; } setSize(sllPtrs.size()); label i = 0; for ( typename SLList::iterator iter = sllPtrs.begin(); iter != sllPtrs.end(); ++iter ) { set(i++, iter()); } } else { FatalIOErrorInFunction ( is ) << "incorrect first token, expected or '(', found " << firstToken.info() << exit(FatalIOError); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template template Foam::PtrList::PtrList(Istream& is, const INew& inewt) { read(is, inewt); } template Foam::PtrList::PtrList(Istream& is) { read(is, INew()); } // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template Foam::Istream& Foam::operator>>(Istream& is, PtrList& L) { L.clear(); L.read(is, INew()); return is; } // ************************************************************************* //