Loading...
Searching...
No Matches
bool.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-2016 OpenFOAM Foundation
9 Copyright (C) 2019-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
27Primitive
28 bool
29
30Description
31 System bool
32
33SourceFiles
34 bool.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_primitives_bool_H
39#define Foam_primitives_bool_H
40
41#include "pTraits.H"
42#include "direction.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// IOstream Operators
50
51//- Read bool from stream using Foam::Switch(Istream&)
52Istream& operator>>(Istream& is, bool& b);
53
54//- Write bool to a stream as an label (integer) value
55Ostream& operator<<(Ostream& os, const bool b);
56
57//- Read bool from stream using Foam::Switch(Istream&)
58bool readBool(Istream& is);
59
60
61/*---------------------------------------------------------------------------*\
62 Specialization pTraits<bool>
63\*---------------------------------------------------------------------------*/
64
65//- Template specialisation for pTraits<bool>
66template<>
67class pTraits<bool>
68{
69 bool p_;
70
71public:
72
73 // Typedefs
74
75 //- Component type
76 typedef bool cmptType;
77
78 //- Magnitude type
79 typedef bool magType;
80
81
82 // Member Constants
83
84 //- Dimensionality of space
85 static constexpr direction dim = 3;
86
87 //- Rank of bool is 0
88 static constexpr direction rank = 0;
89
90 //- Number of components in bool is 1
91 static constexpr direction nComponents = 1;
92
93
94 // Static Data Members
96 static const char* const typeName;
97 static const char* const componentNames[];
98 static const bool zero;
99 static const bool one;
100 static bool dummy;
101
102 //- Return reference to a (false) dummy value
103 static const bool& null() noexcept;
104
106 // Constructors
107
108 //- Copy construct from primitive
109 explicit pTraits(bool val) noexcept : p_(val) {}
111 //- Read construct from Istream
112 explicit pTraits(Istream& is);
115 // Member Functions
116
117 //- Return the value
118 operator bool() const noexcept { return p_; }
119
120 //- Access the value
121 operator bool&() noexcept { return p_; }
122};
123
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126
127} // End namespace Foam
128
129// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130
131#endif
132
133// ************************************************************************* //
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
static const char *const componentNames[]
Definition bool.H:30
pTraits(bool val) noexcept
Copy construct from primitive.
Definition bool.H:127
static const bool & null() noexcept
Return reference to a (false) dummy value.
Definition bool.C:39
bool magType
Magnitude type.
Definition bool.H:87
static const bool one
Definition bool.H:113
static constexpr direction nComponents
Number of components in bool is 1.
Definition bool.H:105
static constexpr direction rank
Rank of bool is 0.
Definition bool.H:100
static constexpr direction dim
Dimensionality of space.
Definition bool.H:95
static bool dummy
Dummy for return reference.
Definition bool.H:114
static const bool zero
Definition bool.H:112
bool cmptType
Component type.
Definition bool.H:82
static const char *const typeName
Definition bool.H:110
pTraits(const Base &obj)
Copy construct from base class.
Definition pTraits.H:72
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
uint8_t direction
Definition direction.H:49
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