int64.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-2015 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 #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 #ifndef UINT64_MIN
49 #define UINT64_MIN 0
50 #endif
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 class Istream;
58 class Ostream;
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 //- Return a word representation of an int64
63 word name(const int64_t);
64 
65 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
66 
67 int64_t readInt64(Istream&);
68 bool read(const char*, int64_t&);
69 Istream& operator>>(Istream&, int64_t&);
70 Ostream& operator<<(Ostream&, const int64_t);
71 
72 #ifdef MSWIN
73 inline
74 Istream& operator>>(Istream& is, off_t& value)
75 {
76  int64_t tmp = 0;
77  is >> tmp;
78  value = tmp;
79 
80  return is;
81 }
82 
83 inline
84 Ostream& operator<<(Ostream& os, const off_t value)
85 {
86  os << int64_t(value);
87 
88  return os;
89 }
90 #endif
91 
92 //- Template specialization for pTraits<int64_t>
93 template<>
94 class pTraits<int64_t>
95 {
96  int64_t p_;
97 
98 public:
99 
100  //- Component type
101  typedef int64_t cmptType;
102 
103  // Member constants
104 
105  enum
106  {
107  dim = 3,
108  rank = 0,
109  nComponents = 1
110  };
111 
112 
113  // Static data members
114 
115  static const char* const typeName;
116  static const char* componentNames[];
117  static const int64_t zero;
118  static const int64_t one;
119  static const int64_t min;
120  static const int64_t max;
121  static const int64_t rootMax;
122  static const int64_t rootMin;
123 
124 
125  // Constructors
126 
127  //- Construct from primitive
128  explicit pTraits(const int64_t&);
129 
130  //- Construct from Istream
131  pTraits(Istream&);
132 
133 
134  // Member Functions
135 
136  //- Access to the int64_t value
137  operator int64_t() const
138  {
139  return p_;
140  }
141 
142  //- Access to the int value
143  operator int64_t&()
144  {
145  return p_;
146  }
147 };
148 
149 
150 inline int64_t mag(const int64_t l)
151 {
152  return ::labs(l);
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
Foam::pTraits< int64_t >::p_
int64_t p_
Definition: int64.H:96
Foam::pTraits< int64_t >::min
static const int64_t min
Definition: int64.H:119
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::pTraits< int64_t >::rootMax
static const int64_t rootMax
Definition: int64.H:121
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::readInt64
int64_t readInt64(Istream &)
Definition: int64IO.C:78
Foam::pTraits< int64_t >::zero
static const int64_t zero
Definition: int64.H:117
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::pTraits< int64_t >::max
static const int64_t max
Definition: int64.H:120
Foam::pTraits::pTraits
pTraits(const PrimitiveType &p)
Construct from primitive.
Definition: pTraits.H:60
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
pTraits.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
direction.H
Direction is an integer type used to represent the Cartesian directions etc. Currently it is a typede...
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::pTraits< int64_t >::rootMin
static const int64_t rootMin
Definition: int64.H:122
Foam::pTraits< int64_t >::one
static const int64_t one
Definition: int64.H:118
word.H
Foam::pTraits< int64_t >::cmptType
int64_t cmptType
Component type.
Definition: int64.H:101
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::pTraits< int64_t >::typeName
static const char *const typeName
Definition: int64.H:115