Loading...
Searching...
No Matches
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-2025 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 "bool.H"
30#include "Switch.H"
31#include "error.H"
32#include "IOstreams.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36const char* const Foam::pTraits<bool>::typeName = "bool";
37const char* const Foam::pTraits<bool>::componentNames[] = { "" };
38
39const bool Foam::pTraits<bool>::zero = false;
40const bool Foam::pTraits<bool>::one = true;
42
43
44// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
45
47{
48 dummy = false;
49 return dummy;
50}
51
52
53// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54
57 is >> p_;
58}
59
60
61// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
62
64{
65 b = static_cast<bool>(Switch(is));
66 return is;
67}
68
69
70Foam::Ostream& Foam::operator<<(Ostream& os, const bool b)
71{
72 // Emit as label (not byte etc) for proper send/receive in parallel
73 os.write(static_cast<label>(b));
74 os.check(FUNCTION_NAME);
75 return os;
76}
77
78
79bool Foam::readBool(Istream& is)
80{
81 return static_cast<bool>(Switch(is));
82}
83
84
85// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
System bool.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
static bool dummy
Dummy for return reference.
Definition bool.H:114
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
pTraits(const Base &obj)
Copy construct from base class.
Definition pTraits.H:72
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition scalarImpl.H:265
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&).
Definition bool.C:72
volScalarField & b