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-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
27Primitive
28 bool
29
30Description
31 System bool
32
33SourceFiles
34 bool.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef bool_H
39#define bool_H
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46// Forward Declarations
47class Istream;
48class Ostream;
49
50// IOstream Operators
51
52//- Read bool from stream using Foam::Switch(Istream&)
53Istream& operator>>(Istream& is, bool& b);
54
55//- Write bool to a stream as an label (integer) value
56Ostream& operator<<(Ostream& os, const bool b);
57
58//- Read bool from stream using Foam::Switch(Istream&)
59bool readBool(Istream& is);
60
61} // End namespace Foam
62
63
64// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65
66#include "pTraits.H"
67#include "direction.H"
68
69namespace Foam
70{
71
72// Template specialisation for pTraits<bool>
73template<>
75{
76 bool p_;
77
78public:
79
80 // Typedefs
81
82 //- Component type
83 typedef bool cmptType;
84
85 //- Magnitude type
86 typedef bool magType;
87
88
89 // Member Constants
90
91 //- Dimensionality of space
92 static constexpr direction dim = 3;
93
94 //- Rank of bool is 0
95 static constexpr direction rank = 0;
96
97 //- Number of components in bool is 1
98 static constexpr direction nComponents = 1;
99
100
101 // Static Data Members
102
103 static const char* const typeName;
104 static const char* const componentNames[];
105 static const bool zero;
106 static const bool one;
107
108
109 // Constructors
110
111 //- Copy construct from primitive
112 explicit pTraits(bool val) noexcept
113 :
114 p_(val)
115 {}
116
117 //- Read construct from Istream
118 explicit pTraits(Istream& is);
119
120
121 // Member Functions
122
123 //- Return the value
124 operator bool() const noexcept
125 {
126 return p_;
127 }
128
129 //- Access the value
130 operator bool&() noexcept
131 {
132 return p_;
133 }
134};
135
136
137// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138
139} // End namespace Foam
140
141// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142
143#endif
144
145// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
pTraits(bool val) noexcept
Copy construct from primitive.
Definition: bool.H:112
bool magType
Magnitude type.
Definition: bool.H:86
static const bool one
Definition: bool.H:106
static const bool zero
Definition: bool.H:105
bool cmptType
Component type.
Definition: bool.H:83
static const char *const typeName
Definition: bool.H:103
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
bool
Definition: EEqn.H:20
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)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
uint8_t direction
Definition: direction.H:56
const direction noexcept
Definition: Scalar.H:223
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
Definition: bool.C:69
volScalarField & b
Definition: createFields.H:27