1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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
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 \*---------------------------------------------------------------------------*/
29 #include "contiguous.H"
31 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
34 void Foam::UList<T>::writeEntry(Ostream& os) const
39 && token::compound::isCompound
41 "List<" + word(pTraits<T>::typeName) + '>'
45 os << word("List<" + word(pTraits<T>::typeName) + '>') << " ";
53 void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
55 os.writeKeyword(keyword);
57 os << token::END_STATEMENT << endl;
62 Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
64 // Write list contents depending on data format
65 if (os.format() == IOstream::ASCII || !contiguous<T>())
69 if (L.size() > 1 && contiguous<T>())
85 // Write size and start delimiter
86 os << L.size() << token::BEGIN_BLOCK;
91 // Write end delimiter
92 os << token::END_BLOCK;
94 else if (L.size() < 11 && contiguous<T>())
96 // Write size and start delimiter
97 os << L.size() << token::BEGIN_LIST;
102 if (i > 0) os << token::SPACE;
106 // Write end delimiter
107 os << token::END_LIST;
111 // Write size and start delimiter
112 os << nl << L.size() << nl << token::BEGIN_LIST;
120 // Write end delimiter
121 os << nl << token::END_LIST << nl;
126 os << nl << L.size() << nl;
129 os.write(reinterpret_cast<const char*>(L.v_), L.byteSize());
133 // Check state of IOstream
134 os.check("Ostream& operator<<(Ostream&, const UList&)");
140 // ************************************************************************* //