uint32.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Primitive
25  uint32
26 
27 Description
28  32bit uinteger
29 
30 SourceFiles
31  uint32.C
32  uint32IO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef uint32_H
37 #define uint32_H
38 
39 #include <cstdint>
40 #include <climits>
41 #include <cstdlib>
42 
43 #include "word.H"
44 #include "pTraits.H"
45 #include "direction.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class Istream;
53 class Ostream;
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 //- Return a word representation of an uint32
58 word name(const uint32_t);
59 
60 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
61 
62 uint32_t readUint32(Istream&);
63 bool read(const char*, uint32_t&);
64 Istream& operator>>(Istream&, uint32_t&);
65 Ostream& operator<<(Ostream&, const uint32_t);
66 
67 //- Template specialisation for pTraits<uint32_t>
68 template<>
69 class pTraits<uint32_t>
70 {
71  uint32_t p_;
72 
73 public:
74 
75  //- Component type
76  typedef uint32_t cmptType;
77 
78 
79  // Member constants
80 
81  //- Dimensionality of space
82  static const direction dim = 3;
83 
84  //- Rank of uint32_t is 0
85  static const direction rank = 0;
86 
87  //- Number of components in uint32_t is 1
88  static const direction nComponents = 1;
89 
90 
91  // Static Data Members
92 
93  static const char* const typeName;
94  static const char* const componentNames[];
95  static const uint32_t zero;
96  static const uint32_t one;
97  static const uint32_t min;
98  static const uint32_t max;
99  static const uint32_t rootMax;
100  static const uint32_t rootMin;
101 
102 
103  // Constructors
104 
105  //- Construct from primitive
106  explicit pTraits(const uint32_t&);
107 
108  //- Construct from Istream
109  pTraits(Istream&);
110 
111 
112  // Member Functions
113 
114  //- Access to the uint32_t value
115  operator uint32_t() const
116  {
117  return p_;
118  }
119 
120  //- Access to the uint32_t value
121  operator uint32_t&()
122  {
123  return p_;
124  }
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #endif
135 
136 // ************************************************************************* //
static const uint32_t rootMax
Definition: uint32.H:99
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Traits class for primitives.
Definition: pTraits.H:50
bool read(const char *, int32_t &)
Definition: int32IO.C:85
uint32_t readUint32(Istream &)
Definition: uint32IO.C:74
Istream & operator>>(Istream &, directionInfo &)
static const uint32_t zero
Definition: uint32.H:95
static const char *const typeName
Definition: uint32.H:93
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static const uint32_t rootMin
Definition: uint32.H:100
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc...
Ostream & operator<<(Ostream &, const ensightPart &)
static const uint32_t max
Definition: uint32.H:98
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:60
static const uint32_t min
Definition: uint32.H:97
static const uint32_t one
Definition: uint32.H:96
uint32_t cmptType
Component type.
Definition: uint32.H:76
Namespace for OpenFOAM.