uint32.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 | Copyright (C) 2014-2016 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 #define __STDC_LIMIT_MACROS
40 #include <stdint.h>
41 #include <climits>
42 #include <cstdlib>
43 
44 #include "word.H"
45 #include "pTraits.H"
46 #include "direction.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class Istream;
54 class Ostream;
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 //- Return a word representation of an uint32
59 word name(const uint32_t);
60 
61 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
62 
63 uint32_t readUint32(Istream&);
64 bool read(const char*, uint32_t&);
65 Istream& operator>>(Istream&, uint32_t&);
66 Ostream& operator<<(Ostream&, const uint32_t);
67 
68 //- Template specialization for pTraits<uint32_t>
69 template<>
70 class pTraits<uint32_t>
71 {
72  uint32_t p_;
73 
74 public:
75 
76  //- Component type
77  typedef uint32_t cmptType;
78 
79 
80  // Member constants
81 
82  //- Dimensionality of space
83  static const direction dim = 3;
84 
85  //- Rank of uint32_t is 0
86  static const direction rank = 0;
87 
88  //- Number of components in uint32_t is 1
89  static const direction nComponents = 1;
90 
91 
92  // Static data members
93 
94  static const char* const typeName;
95  static const char* const componentNames[];
96  static const uint32_t zero;
97  static const uint32_t one;
98  static const uint32_t min;
99  static const uint32_t max;
100  static const uint32_t rootMax;
101  static const uint32_t rootMin;
102 
103 
104  // Constructors
105 
106  //- Construct from primitive
107  explicit pTraits(const uint32_t&);
108 
109  //- Construct from Istream
110  pTraits(Istream&);
111 
112 
113  // Member Functions
114 
115  //- Access to the uint32_t value
116  operator uint32_t() const
117  {
118  return p_;
119  }
120 
121  //- Access to the uint32_t value
122  operator uint32_t&()
123  {
124  return p_;
125  }
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
static const uint32_t rootMax
Definition: uint32.H:100
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
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:96
static const char *const typeName
Definition: uint32.H:94
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static const uint32_t rootMin
Definition: uint32.H:101
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:99
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:60
static const uint32_t min
Definition: uint32.H:98
static const uint32_t one
Definition: uint32.H:97
uint32_t cmptType
Component type.
Definition: uint32.H:77
Namespace for OpenFOAM.