Loading...
Searching...
No Matches
int16.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) 2018-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Primitive
27 int16_t
29Description
30 16bit signed integer. I/O is done as an int32.
31
32SourceFiles
33 int16.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_primitives_int16_H
38#define Foam_primitives_int16_H
39
40#include <cstdint>
41
42#include "direction.H"
43#include "pTraits.H"
44#include "word.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53//- A word representation of int16 value
54inline word name(const int16_t val)
55{
56 return word(std::to_string(int(val)), false); // Needs no stripping
57}
58
59//- A word representation of int16 value
60template<>
61struct nameOp<int16_t>
62{
63 word operator()(const int16_t val) const
64 {
65 return word(std::to_string(int(val)), false); // Needs no stripping
66 }
67};
68
69
70// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
71
72Istream& operator>>(Istream& is, int16_t& val);
73Ostream& operator<<(Ostream& os, const int16_t val);
74
75
76/*---------------------------------------------------------------------------*\
77 Specialization pTraits<int16_t>
78\*---------------------------------------------------------------------------*/
79
80//- Template specialization for pTraits<int16_t>
81template<>
82class pTraits<int16_t>
83{
84 int16_t p_;
85
86public:
87
88 // Typedefs
89
90 //- Component type
91 typedef int16_t cmptType;
92
93
94 // Member Constants
96 //- Dimensionality of space
97 static constexpr direction dim = 3;
98
99 //- Rank of int16_t is 0
100 static constexpr direction rank = 0;
101
102 //- Number of components in int16_t is 1
103 static constexpr direction nComponents = 1;
104
105
106 // Limits
107
108 static constexpr int16_t min_ = INT16_MIN;
109 static constexpr int16_t max_ = INT16_MAX;
110
111
112 // Static Data Members
114 static const char* const typeName;
115 static const char* const componentNames[];
116 static const int16_t zero;
117 static const int16_t one;
118 static const int16_t min;
119 static const int16_t max;
120 static const int16_t rootMax;
121 static const int16_t rootMin;
122
123
124 // Constructors
125
126 //- Copy construct from primitive
127 explicit pTraits(int16_t val) noexcept : p_(val) {}
129 //- Read construct from Istream
130 explicit pTraits(Istream& is);
132
133 // Member Functions
134
135 //- Return the value
136 operator int16_t() const noexcept { return p_; }
137
138 //- Access the value
139 operator int16_t&() noexcept { return p_; }
140};
141
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145} // End namespace Foam
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149#endif
150
151// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
static const char *const componentNames[]
Definition int16.H:28
static const int16_t min
Definition int16.H:128
static const int16_t rootMax
Definition int16.H:130
static constexpr int16_t min_
Definition int16.H:118
static const int16_t max
Definition int16.H:129
static constexpr int16_t max_
Definition int16.H:119
static constexpr direction nComponents
Number of components in int16_t is 1.
Definition int16.H:113
static constexpr direction rank
Rank of int16_t is 0.
Definition int16.H:108
static constexpr direction dim
Dimensionality of space.
Definition int16.H:103
pTraits(int16_t val) noexcept
Copy construct from primitive.
Definition int16.H:139
int16_t cmptType
Component type.
Definition int16.H:95
static const int16_t rootMin
Definition int16.H:131
static const int16_t zero
Definition int16.H:126
pTraits(Istream &is)
Read construct from Istream.
static const int16_t one
Definition int16.H:127
static const char *const typeName
Definition int16.H:124
pTraits(const Base &obj)
Copy construct from base class.
Definition pTraits.H:72
A class for handling words, derived from Foam::string.
Definition word.H:66
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
OBJstream os(runTime.globalPath()/outputName)
auto & name
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
word operator()(const int16_t val) const
Definition int16.H:63
Extract name (as a word) from an object, typically using its name() method.
Definition word.H:341