int64.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-2023 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  int64
26 
27 Description
28  64bit integer
29 
30 SourceFiles
31  int64.C
32  int64IO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef int64_H
37 #define int64_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 #ifndef UINT64_MIN
48 #define UINT64_MIN 0
49 #endif
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 class Istream;
57 class Ostream;
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 //- Return a word representation of an int64
62 word name(const int64_t);
63 
64 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
65 
66 int64_t readInt64(Istream&);
67 bool read(const char*, int64_t&);
68 Istream& operator>>(Istream&, int64_t&);
69 Ostream& operator<<(Ostream&, const int64_t);
70 
71 inline void writeEntry(Ostream& os, const int64_t value)
72 {
73  os << value;
74 }
75 
76 
77 //- Template specialisation for pTraits<int64_t>
78 template<>
79 class pTraits<int64_t>
80 {
81  int64_t p_;
82 
83 public:
84 
85  //- Component type
86  typedef int64_t cmptType;
87 
88 
89  // Member constants
90 
91  //- Dimensionality of space
92  static const direction dim = 3;
93 
94  //- Rank of int64_t is 0
95  static const direction rank = 0;
96 
97  //- Number of components in int64_t is 1
98  static const 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 int64_t zero;
106  static const int64_t one;
107  static const int64_t min;
108  static const int64_t max;
109 
110 
111  // Constructors
112 
113  //- Construct from primitive
114  explicit pTraits(const int64_t&);
115 
116  //- Construct from Istream
117  pTraits(Istream&);
118 
119 
120  // Member Functions
121 
122  //- Access to the int64_t value
123  operator int64_t() const
124  {
125  return p_;
126  }
127 
128  //- Access to the int value
129  operator int64_t&()
130  {
131  return p_;
132  }
133 };
134 
135 
136 inline int64_t mag(const int64_t l)
137 {
138  return ::labs(l);
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
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:57
static const char *const typeName
Definition: int64.H:103
static const int64_t max
Definition: int64.H:108
static const int64_t one
Definition: int64.H:106
int64_t cmptType
Component type.
Definition: int64.H:86
static const int64_t min
Definition: int64.H:107
static const int64_t zero
Definition: int64.H:105
Traits class for primitives.
Definition: pTraits.H:53
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:60
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc.
Namespace for OpenFOAM.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Istream & operator>>(Istream &, pistonPointEdgeData &)
dimensioned< scalar > mag(const dimensioned< Type > &)
int64_t readInt64(Istream &)
Definition: int64IO.C:76
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
uint8_t direction
Definition: direction.H:45