LabelledItemI.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "IOstreams.H"
30
31// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
32
33template<class T>
34inline Foam::Istream& Foam::operator>>
35(
36 Istream& is,
37 LabelledItem<T>& item
38)
39{
40 is.readBegin("LabelledItem");
41 is >> static_cast<T&>(item) >> item.index();
42 is.readEnd("LabelledItem");
43
44 is.check(FUNCTION_NAME);
45 return is;
46}
47
48
49template<class T>
50inline Foam::Ostream& Foam::operator<<
51(
52 Ostream& os,
53 const LabelledItem<T>& item
54)
55{
56 // Output like Tuple2
57 os << token::BEGIN_LIST
58 << static_cast<const T&>(item) << token::SPACE
59 << item.index()
60 << token::END_LIST;
61
62 return os;
63}
64
65
66// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: Istream.C:111
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
const volScalarField & T
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME