bool.C
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-2016 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "bool.H"
30 #include "Switch.H"
31 #include "error.H"
32 #include "IOstreams.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 const char* const Foam::pTraits<bool>::typeName = "bool";
37 const bool Foam::pTraits<bool>::zero = false;
38 const bool Foam::pTraits<bool>::one = true;
39 
40 const char* const Foam::pTraits<bool>::componentNames[] = { "" };
41 
43 :
44  p_(p)
45 {}
46 
47 
49 {
50  is >> p_;
51 }
52 
53 
55 {
56  b = static_cast<bool>(Switch(is));
57  return is;
58 }
59 
60 
62 {
63  // Emit as label (not byte etc) for proper send/receive in parallel
64  os.write(label(b));
65  os.check(FUNCTION_NAME);
66  return os;
67 }
68 
69 
71 {
72  return static_cast<bool>(Switch(is));
73 }
74 
75 
76 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
error.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::readBool
bool readBool(Istream &is)
Definition: bool.C:70
Foam::pTraits::pTraits
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:62
Switch.H
bool.H
System bool.
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102