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 -------------------------------------------------------------------------------
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 Primitive
28  bool
29 
30 Description
31  System bool
32 
33 SourceFiles
34  bool.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef bool_H
39 #define bool_H
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward Declarations
47 class Istream;
48 class Ostream;
49 
50 // IOstream Operators
51 
52 //- Read bool from stream using Foam::Switch(Istream&)
53 Istream& operator>>(Istream& is, bool& b);
54 
55 //- Write bool to a stream as an label (integer) value
56 Ostream& operator<<(Ostream& os, const bool b);
57 
58 //- Read bool from stream using Foam::Switch(Istream&)
59 bool readBool(Istream& is);
60 
61 } // End namespace Foam
62 
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 #include "pTraits.H"
67 #include "direction.H"
68 
69 namespace Foam
70 {
71 
72 // Template specialisation for pTraits<bool>
73 template<>
74 class pTraits<bool>
75 {
76  bool p_;
77 
78 public:
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 
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
111  //- Copy construct from primitive
112  explicit pTraits(bool val) noexcept
113  :
114  p_(val)
115  {}
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 #endif
144 
145 // ************************************************************************* //
uint8_t direction
Definition: direction.H:46
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool magType
Magnitude type.
Definition: bool.H:92
pTraits(const Base &obj)
Copy construct from base class.
Definition: pTraits.H:61
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
Direction is an 8-bit unsigned integer type used to represent Cartesian directions, components etc.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:58
bool cmptType
Component type.
Definition: bool.H:87
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
Definition: bool.C:62
Namespace for OpenFOAM.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:57